mindspore.ops.InplaceUpdate

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

Updates specified rows with values in v.

Parameters

indices (Union[int, tuple]) – Indices into the left-most dimension of x, and determines which rows of x to update with v. It is a int or tuple, whose value is in [0, the first dimension size of x).

Inputs:
  • x (Tensor) - A tensor which to be inplace updated. It can be one of the following data types: float32, float16 and int32.

  • v (Tensor) - A tensor with the same type as x and the same dimension size as x except the first dimension, which must be the same as the size of indices.

Outputs:

Tensor, with the same type and shape as the input x.

Raises
  • TypeError – If indices is neither int nor tuple.

  • TypeError – If indices is a tuple and its element is not an int.

Supported Platforms:

Ascend

Examples

>>> indices = (0, 1)
>>> x = Tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32)
>>> v = Tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32)
>>> inplace_update = ops.InplaceUpdate(indices)
>>> output = inplace_update(x, v)
>>> print(output)
[[0.5 1. ]
 [1.  1.5]
 [5.  6. ]]