mindspore.ops.stack

View Source On Gitee
mindspore.ops.stack(tensors, axis=0)[source]

Stack input tensors in specified axis.

Parameters
  • tensors (Union[tuple, list]) – The input tensors.

  • axis (int) – Axis to stack. Default 0 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input_x1 = mindspore.tensor([0, 1], mindspore.float32)
>>> input_x2 = mindspore.tensor([2, 3], mindspore.float32)
>>> output = mindspore.ops.stack((input_x1, input_x2), 0)
>>> print(output)
[[0. 1.]
 [2. 3.]]