Skip to contents

Reverses the order of elements along specified axes.

Usage

prim_reverse(x, axes)

Arguments

x

(arrayish)
Arrayish value of any data type.

axes

(integer())
Axes to reverse. Negative values count from the end, i.e. -1 refers to the last axis.

Value

arrayish
Has the same data type and shape as x. It is ambiguous if the input is ambiguous.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_reverse().

See also

Examples

x <- nv_array(c(1, 2, 3, 4, 5))
prim_reverse(x, axes = 1L)
#> AnvlArray
#>  5
#>  4
#>  3
#>  2
#>  1
#> [ CPUf32{5} ]