mindspore.ops.InplaceUpdateV2

View Source On Gitee
class mindspore.ops.InplaceUpdateV2[source]

Updates specified values in x to v according to indices.

Warning

This is an experimental API that is subject to change or deletion.

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

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

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

  • 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.

Supported Platforms:

GPU 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)
>>> v = Tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32)
>>> inplace_update_v2 = ops.InplaceUpdateV2()
>>> output = inplace_update_v2(x, indices, v)
>>> print(output)
[[0.5 1. ]
 [1.  1.5]
 [5.  6. ]]