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
  • ValueError – The shape of src is not the same as the shape scattered over input .

  • TypeError – If input is not a Tensor.

  • TypeError – If src is not a Tensor.

  • TypeError – If axis or index is not an integer.

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