* 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)
| 58 | * @doc {heading: 'Operations', subheading: 'Slicing and Joining'} |
| 59 | */ |
| 60 | function 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 | |
| 87 | export const tensorScatterUpdate = op({tensorScatterUpdate_}); |
nothing calls this directly
no test coverage detected
searching dependent graphs…