Skip to main content
Log in

Mojo function

cumsum

cumsum[rank: Int, type: DType, exclusive: Bool, reverse: Bool](output: NDBuffer[type, rank, origin], input: NDBuffer[type, rank, origin], axis: Int)

Implements the CumSum operator from the ONNX spec: https://github.com/onnx/onnx/blob/main/docs/Operators.md#CumSum Computes cumulative sum of the input elements along the given axis. Cumulative sum can be inclusive or exclusive of the top element, and normal or reverse (direction along a given axis).

Parameters:

  • rank (Int): Rank of the input and output tensors.
  • type (DType): Type of the input and output tensors.
  • exclusive (Bool): If set to True, return exclusive sum (top element not included).
  • reverse (Bool): If set to True, perform cumsum operation in reverse direction.

Args:

  • output (NDBuffer[type, rank, origin]): The output tensor.
  • input (NDBuffer[type, rank, origin]): The input tensor.
  • axis (Int): The axis on which to perform the cumsum operation.