mindspore.ops.select_scatter

mindspore.ops.select_scatter(input, src, axis, index)[source]

On the specified dimension axis of input , src is scattered into input on the specified index of input .

Parameters
  • input (Tensor) – The target Tensor.

  • src (Tensor) – The source Tensor.

  • axis (int) – The dimension of input to be embedded.

  • index (int) – The location of scattering on the specified dimension.

Returns

Tensor after embedding, has the same shape and type as input .

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> a = ms.ops.zeros((2, 3, 3))
>>> b = ms.ops.ones((2, 3))
>>> output = ms.ops.select_scatter(a, b, axis=1, index=1)
>>> print(output)
[[[0. 0. 0.]
  [1. 1. 1.]
  [0. 0. 0.]]
 [[0. 0. 0.]
  [1. 1. 1.]
  [0. 0. 0.]]]