MCPcopy Create free account
hub / github.com/tensorflow/tfjs / tensorScatterUpdate_

Function tensorScatterUpdate_

tfjs-core/src/ops/tensor_scatter_update.ts:60–85  ·  view source on GitHub ↗

* Creates a new tensor by applying sparse updates to individual * values or slices to the passed in tensor according to * indices. This operator is the similar to scatterNd op, except that the * udpates are scattered on an existing tensor (as opposed to a zero-tensor). * * If indices contains d

(
    tensor: Tensor<R>|TensorLike, indices: Tensor|TensorLike,
    updates: Tensor|TensorLike)

Source from the content-addressed store, hash-verified

58 * @doc {heading: 'Operations', subheading: 'Slicing and Joining'}
59 */
60function tensorScatterUpdate_<R extends Rank>(
61 tensor: Tensor<R>|TensorLike, indices: Tensor|TensorLike,
62 updates: Tensor|TensorLike): Tensor<R> {
63 const $tensor = convertToTensor(tensor, 'tensor', 'tensorScatterupdate');
64 const $indices =
65 convertToTensor(indices, 'indices', 'tensorScatterupdate', 'int32');
66 const $updates = convertToTensor(updates, 'updates', 'tensorScatterupdate');
67 scatter_nd_util.validateInput($updates, $indices, $tensor.shape);
68 if ($tensor.dtype !== $updates.dtype) {
69 throw new Error(
70 `tensor and updates must have the same dtype, instead they are ${
71 $tensor.dtype} and ${$updates.dtype}.`);
72 }
73
74 const inputs: TensorScatterUpdateInputs = {
75 tensor: $tensor,
76 indices: $indices,
77 updates: $updates
78 };
79 const attrs: TensorScatterUpdateAttrs = {};
80
81 // tslint:disable-next-line: no-unnecessary-type-assertion
82 return ENGINE.runKernel(
83 TensorScatterUpdate, inputs as unknown as NamedTensorMap,
84 attrs as unknown as NamedAttrMap) as Tensor<R>;
85}
86
87export const tensorScatterUpdate = op({tensorScatterUpdate_});

Callers

nothing calls this directly

Calls 2

convertToTensorFunction · 0.90
runKernelMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…