mindspore.ops.InplaceAdd

class mindspore.ops.InplaceAdd(indices)[source]

Adds v into specified rows of x. Computes y = x; y[i,] += v.

Refer to mindspore.ops.inplace_add() for more details.

Supported Platforms:

Ascend CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> indices = (0, 1)
>>> x = Tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32)
>>> input_v = Tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32)
>>> inplaceAdd = ops.InplaceAdd(indices)
>>> output = inplaceAdd(x, input_v)
>>> print(output)
[[1.5 3. ]
 [4.  5.5]
 [5.  6. ]]