mindspore.ops.slice_scatter
- mindspore.ops.slice_scatter(input, src, axis=0, start=None, end=None, step=1)[source]
Slice the input Tensor in the specified dimension and overlay the slice results with the source Tensor. The input is sliced along the specified dimension. The start position of the slice is start , the end position is end , and the step size is step . Then the slicing result is overwritten with src to get the output Tensor.
- Parameters
input (Tensor) – The target Tensor.
src (Tensor) – The source Tensor.
axis (int, optional) – The dimension of input to be sliced. Default:
0
.start (int, optional) – The start index to slice in the specified dimension. Default:
None
, start is0
.end (int, optional) – The end index to slice in the specified dimension. Default:
None
, end is the length of input in the specified dimension.step (int, optional) – Step size. Default:
1
, the distance from the next slice element is1
.
- 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((4, 6)) >>> b = ms.ops.ones((4, 3)) >>> output = ms.ops.slice_scatter(a, b, axis=1, start=0, end=5, step=2) >>> print(output) [[1. 0. 1. 0. 1. 0.] [1. 0. 1. 0. 1. 0.] [1. 0. 1. 0. 1. 0.] [1. 0. 1. 0. 1. 0.]]