giagrad.Tensor.swapaxes#

Tensor.swapaxes(axis0, axis1)[source]#

Permutes two specific axes.

Note

The returned tensor shares the storage with the input tensor, so changing the contents of one will change the contents of the other.

Parameters:
  • axis0 (int) – First axis.

  • axis1 (int) – Second axis.

Examples

>>> t = Tensor.empty(1, 2, 3, 2, dtype=int).uniform(-100, 100)
>>> t
tensor: [[[[-91  22]
           [ 54 -47]
           [ 21 -88]]
...
          [[  3 -78]
           [ 34  68]
           [-51  29]]]]
>>> t.swapaxes(2, 3)
tensor: [[[[-91  54  21]
           [ 22 -47 -88]]
...
          [[  3  34 -51]
           [-78  68  29]]]] fn: Swapaxes(2, 3)