Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped.
The resulting out tensor shares its underlying storage with the input tensor, so changing the content of one would change the content of the other.
input (oneflow.Tensor) – the input tensor.
dim0 (int) – the first dimension to be transposed.
dim1 (int) – the second dimension to be transposed.
A transposed tensor.
- Return type
>>> import numpy as np >>> import oneflow as flow >>> input = flow.tensor(np.random.randn(2, 6, 5, 3), dtype=flow.float32) >>> out = flow.transpose(input, 0, 1).shape >>> out oneflow.Size([6, 2, 5, 3])