mindspore.ops.narrow
- mindspore.ops.narrow(input, axis, start, length)[source]
Slice the tensor from the start position with a length of length along axis .
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> x = mindspore.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], mindspore.int32) >>> output = mindspore.ops.narrow(x, 0, 0, 2) >>> print(output) [[ 1 2 3] [ 4 5 6]] >>> output = mindspore.ops.narrow(x, 1, 1, 2) >>> print(output) [[ 2 3] [ 5 6] [ 8 9]]