Skip to contents

Permutes the dimensions of a tensor. You can also use t() for matrices.

Usage

nv_transpose(x, permutation = NULL)

# S3 method for class 'AnvilBox'
t(x)

Arguments

x

(tensorish)
Tensor to transpose.

permutation

(integer() | NULL)
New ordering of dimensions. If NULL (default), reverses the dimensions.

Value

tensorish
Has the same data type as x and shape nv_shape(x)[permutation].

See also

nvl_transpose() for the underlying primitive.

Examples

jit_eval({
  x <- nv_tensor(matrix(1:6, nrow = 2))
  t(x)
})
#> AnvilTensor
#>  1 2
#>  3 4
#>  5 6
#> [ CPUi32{3,2} ]