mindspore.ops.tensor_scatter_add
- mindspore.ops.tensor_scatter_add(input_x, indices, updates)[source]
Return a new tensor by adding the values from updates in input_x indicated by indices .
Note
On GPU, if some values of the indices are out of bound, instead of raising an index error, the corresponding updates will not be updated to self tensor.
On CPU, if some values of the indices are out of bound, raising an index error.
On Ascend, out of bound checking is not supported, if some values of the indices are out of bound, unknown errors may be caused.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> input_x = mindspore.tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]), mindspore.float32) >>> indices = mindspore.tensor(np.array([[0, 0], [0, 0]]), mindspore.int32) >>> updates = mindspore.tensor(np.array([1.0, 2.2]), mindspore.float32) >>> output = mindspore.ops.tensor_scatter_add(input_x, indices, updates) >>> print(output) [[ 3.1 0.3 3.6] [ 0.4 0.5 -3.2]]