tensor.cumsum
fn cumsum(self: @Tensor<T>, axis: usize, exclusive: Option<bool>, reverse: Option<bool>) -> Tensor<usize>;Performs cumulative sum of the input elements along the given axis.
Args
self(@Tensor<T>) - The input tensor.axis(usize) - The axis along which to compute the cumulative sum.exclusive(Option<bool>) - By default, it will do the sum inclusively meaning the first element is copied as is.reverse(Option<bool>) - If true, the cumulative sum is performed in the opposite direction. Defaults to false.
Panics
Panics if axis is not in the range of the input tensor's dimensions.
Returns
A new Tensor<T> instance containing the cumulative sum of the input tensor's elements along the given axis.
Examples
Case 1: cumsum with default parameters
Case 2: cumsum with exclusive = true
Case 3: cumsum with exclusive = true and reverse = true
Last updated
Was this helpful?