mindspore.ops.hstack

View Source On Gitee
mindspore.ops.hstack(tensors)[source]

Stacks tensors in sequence horizontally.

Note

  • Dynamic rank input of 8-D tensors with type float64 is not supported in graph mode (mode=mindspore.GRAPH_MODE).

  • This is equivalent to concatenation along the second axis, except for 1-D tensors where it concatenates along the first axis.

  • The tensors must have the same shape along all but the second axis, except 1-D tensors which can be any length.

Parameters

tensors (Union[tuple[Tensor], list[Tensor]]) – Tuple of tensors or list of tensors.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x1 = mindspore.tensor([1, 1, 1])
>>> x2 = mindspore.tensor([2, 2, 2])
>>> output = mindspore.ops.hstack((x1, x2))
>>> print(output)
[1. 1. 1. 2. 2. 2.]