Skip to contents

Permutes the dimensions of an array.

Usage

prim_transpose(operand, permutation)

Arguments

operand

(arrayish)
Arrayish value of any data type.

permutation

(integer())
Specifies the new ordering of dimensions. Must be a permutation of seq_len(ndims) where ndims is the number of dimensions of operand.

Value

arrayish
Has the same data type as the input and shape nv_shape(operand)[permutation]. It is ambiguous if the input is ambiguous.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to stablehlo::hlo_transpose().

See also

Examples

x <- nv_array(matrix(1:6, nrow = 2))
prim_transpose(x, permutation = c(2L, 1L))
#> AnvlArray
#>  1 2
#>  3 4
#>  5 6
#> [ CPUi32{3,2} ]