mindspore.ops.inplace_update
- mindspore.ops.inplace_update(x, v, indices)[source]
Updates specified rows with values in v.
Note
indices refers to the left-most dimension.
- Parameters
indices (Union[int, tuple], Tensor) – 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). If the type is Tensor, it supports dynamic shape. Otherwise, it only supports static shape.
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.
- Returns
Tensor, with the same type and shape as the input x.
- Raises
- Supported Platforms:
Ascend
CPU
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) >>> output = ops.inplace_update(x, v, indices) >>> print(output) [[0.5 1. ] [1. 1.5] [5. 6. ]]