Cumulative sum of array elements along a single axis.
Output position j along axis equals the sum of input positions 1:j.
Arguments
- x
(
arrayish)
Arrayish value of any data type.- axis
(
integer(1))
Axis along which to accumulate. Negative values count from the end, i.e.-1refers to the last axis.
Value
arrayish
Has the same shape and data type as the input.
It is ambiguous if the input is ambiguous.
StableHLO
Lowers to hlo_reduce_window() with hlo_add() as the reducer.
Examples
x <- nv_matrix(1:6, nrow = 2)
prim_cumsum(x, axis = 1L)
#> AnvlArray
#> 1 3 5
#> 3 7 11
#> [ CPUi32{2,3} ]