oneflow.dstack

oneflow.dstack(tensors)Tensor

Stack tensors in tensors depthwish (along third axis).

This is equivalent to concatenation tensors in tensors along the third axis after 1-D and 2-D tensors have been reshaped by oneflow.atleast_3d().

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

Parameters

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

Returns

A Tensor

For example:

>>> import oneflow as flow
>>> x1 = flow.randn(2, 3, 4)
>>> x2 = flow.randn(2, 3, 2)
>>> flow.dstack([x1, x2]).shape
oneflow.Size([2, 3, 6])
>>> x = flow.randn(6, 4)
>>> flow.dstack([x, x]).shape
oneflow.Size([6, 4, 2])