transpose¶
- tripy.transpose(input: Tensor, dim0: int, dim1: int) Tensor [source]¶
Returns a new tensor that is a transposed version of the input tensor where
dim0
anddim1
are swapped.- Parameters:
input (Tensor) – The input tensor.
dim0 (int) – The first dimension to be transposed.
dim1 (int) – The second dimension to be transposed.
- Returns:
A new tensor.
- Return type:
Example
1input = tp.reshape(tp.arange(6, dtype=tp.float32), (2, 3)) 2output = tp.transpose(input, 0, 1)
>>> input tensor( [[0.0000, 1.0000, 2.0000], [3.0000, 4.0000, 5.0000]], dtype=float32, loc=gpu:0, shape=(2, 3)) >>> output tensor( [[0.0000, 3.0000], [1.0000, 4.0000], [2.0000, 5.0000]], dtype=float32, loc=gpu:0, shape=(3, 2))