torch.permute
function permute(input: Tensor, dims: number[]): voidReturns a view of the input tensor with its dimensions rearranged.
Parameters
inputTensor- The input tensor
dimsnumber[]- The new order of dimensions
Returns
Tensor with dimensions permuted according to dims
Examples
const x = torch.randn(2, 3, 4);
torch.permute(x, [2, 0, 1]).shape; // [4, 2, 3]