oneflow.hstack

oneflow.hstack(tensors)Tensor

Stack tensors in tensors horizontally (column wise).

This is equivalent to concatenation tensors in tensors along the first axis for 1-D tensors, and along the second axis for all other tensors.

When there are tensors with dimension less than 1, these tensors will be reshaped by oneflow.atleast_1d() to 1-dims tensors before stacking.

The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.hstack.html.

Parameters

tensors – (List[oneflow.Tensor]): sequence of tensors to stack

Returns

A Tensor

For example:

>>> import oneflow as flow
>>> x1 = flow.randn(5, 2)
>>> x2 = flow.randn(5, 3)
>>> flow.hstack([x1, x2]).shape
oneflow.Size([5, 5])
>>> x = flow.randn(5)
>>> flow.hstack([x, x]).shape
oneflow.Size([10])