fn
transpose
→Tensortranspose(input: Tensor)Swap the last two dimensions of input.
The zero-argument form: for a 2-D tensor this is the matrix transpose; for higher-rank tensors the final two axes are swapped (batch dims are preserved). Implemented as a stride manipulation — no data is copied.
Parameters
inputTensorSource tensor with
ndim >= 2.Returns
TensorNon-contiguous view with last two axes swapped.
Notes
To swap arbitrary axes use permute or movedim.
Because the output is non-contiguous, downstream ops requiring a flat
layout should follow with contiguous.
Examples
>>> import lucid
>>> x = lucid.zeros(2, 3, 4)
>>> lucid.transpose(x).shape
(2, 4, 3)