torch.MatrixTransposeShape
export type MatrixTransposeShape<S extends Shape> = number extends S['length']
? DynamicShape
: S extends readonly [
...infer Batch extends number[],
infer M extends number,
infer N extends number,
]
? readonly [...Batch, N, M]
: DynamicShape;Sextends ShapeCompute output shape of matrix transpose (.mT, .mH). Swaps the last two dimensions of any tensor with ndim >= 2.
Examples
type R1 = MatrixTransposeShape<readonly [2, 3]>; // readonly [3, 2]
type R2 = MatrixTransposeShape<readonly [4, 2, 3]>; // readonly [4, 3, 2]
type R3 = MatrixTransposeShape<readonly [5]>; // DynamicShape (requires 2+ dims)