Tensor Transpose
Shippingtensor_transposePermute or reverse array axes (numpy transpose / .T); a pure reindex that preserves the unit
Signature
Inputs
aVector|Matrix|Tensorrequired— The array whose axes are permuted.
Outputs
resultVector|Matrix|Tensor— The axis-permuted view materialized as a new array; same elements, reordered shape, unit unchanged.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
order | text | Comma-separated axis permutation, e.g. "1, 0" or "2, 0, 1". Empty = reverse all axes (numpy .T). Negative axes count from the end. |
Description
Tensor Transpose permutes the axes of an array, matching numpy's transpose. The order parameter is a comma-separated axis permutation: "1, 0" swaps the two axes of a matrix (an ordinary transpose), "2, 0, 1" rotates a rank-3 tensor's axes. An empty order reverses all axes — exactly numpy's .T. Negative axes count from the end, so "-1, 0" addresses the last axis first.
This is a pure reindex: no arithmetic touches the values, they are merely relabeled by position. Consequently the physical unit is preserved unchanged. For a 2-D matrix the operation is the familiar where ; for higher ranks it generalizes to an arbitrary axis relabeling.
Mathematics
Examples
Matrix transpose
Feed the matrix [[0,1,2],[3,4,5]] with order = "1, 0" (or empty). The result is the transpose:
[[0, 3],
[1, 4],
[2, 5]]Rank-3 axis rotation
A tensor of shape with order = "2, 0, 1" becomes shape : the old last axis moves to front, and the first two shift back one position.
Applications
- Turning a row layout into a column layout (or vice versa) before matmul or concatenation so shapes align.
- Reordering the axes of a data cube (e.g. moving a channel/time axis to the front) to match a downstream node's expected layout.
- Realizing a numpy .T with no parameters for a quick full-axis reversal of any rank.
Neat
Because it is a metadata-only reindex on the value side, the unit rides through untouched — unlike stack/concat which drop or must reconcile units.
The empty-order fast path calls a dedicated full-reverse transpose, while an explicit list dispatches to a general permute — the same axis-list parser as tensor_reduce.
Negative-axis support means you can address 'the last axis' without knowing the rank, useful in rank-agnostic subgraphs.
Known issues
An `order` that is not a valid permutation of the array's axes (wrong length, repeats, or out-of-range index) is a hard error rather than a partial reorder.