MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _NumpyScatterNd

Function _NumpyScatterNd

tensorflow/python/kernel_tests/scatter_nd_ops_test.py:62–76  ·  view source on GitHub ↗
(ref, indices, updates, op)

Source from the content-addressed store, hash-verified

60
61
62def _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
79def _NumpyUpdate(ref, indices, updates):

Callers 5

_NumpyUpdateFunction · 0.70
_NumpyAddFunction · 0.70
_NumpySubFunction · 0.70
_NumpyMulFunction · 0.70
_NumpyDivFunction · 0.70

Calls 6

tupleFunction · 0.85
reshapeMethod · 0.80
_FlatInnerDimsFunction · 0.70
_FlatOuterDimsFunction · 0.70
rangeFunction · 0.50
opFunction · 0.50

Tested by

no test coverage detected