mindspore.ops.chunk

View Source On Gitee
mindspore.ops.chunk(input, chunks, axis=0)[source]

Split the input tensor into multiple sub-tensors along the specified axis.

Note

This function may return less than the specified number of chunks!

Parameters
  • input (Tensor) – A tensor to be split.

  • chunks (int) – The number of splits.

  • axis (int, optional) – The axis along which to split. Default 0 .

Returns

Tuple of tensors.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.ops.arange(0, 9, dtype=mindspore.float32)
>>> output = mindspore.ops.chunk(input, 3)
>>> print(output)
(Tensor(shape=[3], dtype=Float32, value= [ 0.00000000e+00,  1.00000000e+00,  2.00000000e+00]),
 Tensor(shape=[3], dtype=Float32, value= [ 3.00000000e+00,  4.00000000e+00,  5.00000000e+00]),
 Tensor(shape=[3], dtype=Float32, value= [ 6.00000000e+00,  7.00000000e+00,  8.00000000e+00]))