Sums array elements along the specified axes.
Arguments
- x
(
arrayish)
Arrayish value of any data type.- axes
(
integer())
Axes to reduce over. Negative values count from the end, i.e.-1refers to the last axis.- drop
(
logical(1))
Whether to drop the reduced axes from the output shape. IfTRUE, the reduced axes are removed. IfFALSE, the reduced axes are set to 1.
Value
arrayish
Has the same data type as the input.
When drop = TRUE, the shape is that of x with axes removed.
When drop = FALSE, the shape is that of x with axes set to 1.
It is ambiguous if the input is ambiguous.
StableHLO
Lowers to hlo_reduce() with hlo_add() as the reducer.
Examples
x <- nv_matrix(1:6, nrow = 2)
prim_reduce_sum(x, axes = 1L)
#> AnvlArray
#> 3
#> 7
#> 11
#> [ CPUi32{3} ]