(ref, indices, updates, op)
| 60 | |
| 61 | |
| 62 | def _NumpyScatterNd(ref, indices, updates, op): |
| 63 | ixdim = indices.shape[-1] |
| 64 | num_updates = indices.size // ixdim |
| 65 | total_nd = len(ref.shape) |
| 66 | slice_size = 1 |
| 67 | for i in range(ixdim, total_nd): |
| 68 | slice_size *= ref.shape[i] |
| 69 | flat_indices = _FlatInnerDims(indices) |
| 70 | flat_updates = updates.reshape((num_updates, slice_size)) |
| 71 | output_flat = _FlatOuterDims(ref, ixdim + 1) |
| 72 | for ix_updates, ix_output in enumerate(flat_indices): |
| 73 | ix_output = tuple(ix_output) |
| 74 | output_flat[ix_output] = op(output_flat[ix_output], |
| 75 | flat_updates[ix_updates]) |
| 76 | return output_flat.reshape(ref.shape) |
| 77 | |
| 78 | |
| 79 | def _NumpyUpdate(ref, indices, updates): |
no test coverage detected