transpose

nvtripy.transpose(input: Tensor, dim0: int, dim1: int) Tensor[source]

Returns a new tensor that is a transposed version of the input tensor where dim0 and dim1 are swapped.

Parameters:
  • input (Tensor) – [dtype=T1] The input tensor.

  • dim0 (int) – The first dimension to be transposed.

  • dim1 (int) – The second dimension to be transposed.

Returns:

[dtype=T1] A new tensor.

Return type:

Tensor

DATA TYPE CONSTRAINTS:
Example
1input = tp.reshape(tp.arange(6, dtype=tp.float32), (2, 3))
2output = tp.transpose(input, 0, 1)
Local Variables
>>> input
tensor(
    [[0, 1, 2],
     [3, 4, 5]], 
    dtype=float32, loc=gpu:0, shape=(2, 3))

>>> output
tensor(
    [[0, 3],
     [1, 4],
     [2, 5]], 
    dtype=float32, loc=gpu:0, shape=(3, 2))