mindspore.ops.inplace_update

View Source On Gitee
mindspore.ops.inplace_update(x, v, indices)[source]

Updates x to v according to the indices.

Warning

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

for each i, …, j in indices :

x[extindices[i,...,j]]=v[i,...,j]
Parameters
  • x (Tensor) – The input tensor.

  • v (Tensor) – The input tensor to update to x.

  • indices (Union[int, tuple[int], Tensor]) – Indices into the input x along the 0th dimension.

Returns

Tensor

Supported Platforms:

GPU CPU

Examples

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