latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.transpose
- tensorplay.functional.transpose(input, dim0, dim1) Tensor[source]
Returns a tensor that is a transposed version of
input. The given dimensionsdim0anddim1are swapped.If
inputis a strided tensor then the resultingouttensor shares its underlying storage with theinputtensor, so changing the content of one would change the content of the other.If
inputis a the relevant documentation then the resultingouttensor does not share the underlying storage with theinputtensor.If
inputis a the relevant documentation with compressed layout (SparseCSR, SparseBSR, SparseCSC or SparseBSC) the argumentsdim0anddim1must be both batch dimensions, or must both be sparse dimensions. The batch dimensions of a sparse tensor are the dimensions preceding the sparse dimensions.Note
Transpositions which interchange the sparse dimensions of a SparseCSR or SparseCSC layout tensor will result in the layout changing between the two options. Transposition of the sparse dimensions of a ` SparseBSR` or SparseBSC layout tensor will likewise generate a result with the opposite layout.
- Parameters:
Example:
>>> x = tensorplay.randn(2, 3) >>> x tensor([[ 1.0028, -0.9893, 0.5809], [-0.1669, 0.7299, 0.4942]]) >>> tensorplay.transpose(x, 0, 1) tensor([[ 1.0028, -0.1669], [-0.9893, 0.7299], [ 0.5809, 0.4942]])See also
tensorplay.t().
Help improve this page
Found an error, an unclear step, or a missing example?

