mindspore.ops.inplace_index_add
- mindspore.ops.inplace_index_add(var, indices, updates, axis)[source]
Add updates to var according to the indices and axis.
for each i, …, j in indices :
where i is the index of the element in indices, and the axis of indices[i] is determined by the input axis.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
CPU
Examples
>>> import mindspore >>> import numpy as np >>> var = mindspore.Parameter(mindspore.tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32)) >>> indices = mindspore.tensor(np.array([0, 1]), mindspore.int32) >>> updates = mindspore.tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32) >>> mindspore.ops.inplace_index_add(var, indices, updates, axis=0) >>> print(var.asnumpy()) [[1.5 3. ] [4. 5.5] [5. 6. ]]