CumsumOperation

Description

Returns the cumulative sum along the given axes.

Figure 1 CumsumOperation

Function Implementation

Input:

  • Array: The input of cumsum can be a multidimensional array.
  • Axis: You can select an axis (dimension) along which the cumulative sum operation is performed. By default, for a one-dimensional array, the cumulative sum is calculated backwards from the first element. For a multi-dimensional array, specify the axis along which the cumulative sum is performed.

Output:

  • Result of cumulative sum: The shape of the output is the same as that of the input. For each element, the sum includes the element and all previous elements.

Formula

If the input is a one-dimensional container of size N, the output is also a one-dimensional container of size N, where the values of the elements are:

Definition

struct CumsumParam {
    SVector<int64_t> axes;
    bool exclusive = false;
    bool reverse =  false;
    uint8_t rsv[14] = {0};
};

Parameters

Member

Type

Default Value

Description

axes

SVector<int64_t>

-

Calculates the accumulated sum along a specified axis (dimension). Only one axis index can be included.

The value of axes must be less than the number of dimensions of the input x.

exclusive

bool

false

Sequence number of the element from which the accumulation on an axis starts. The default value is false.

  • true: starts from the first element (not supported currently).
  • false: starts from element 0.

reverse

bool

false

Forward accumulation or reverse accumulation. The default value is false.

  • true: performs summation in reverse direction (not supported currently).
  • false: performs summation in forward direction.

rsv[14]

uint8_t

{0}

Reserved

Input

Parameter

Dimension

Data Type

Format

Description

x

[-1,…,-1]

The value -1 indicates that the size of the current dimension is not restricted.

float16

ND

Input tensor

Output

Parameter

Dimension

Data Type

Format

Description

y

[-1,…,-1]

The value -1 indicates that the size of the current dimension is not restricted.

float16

ND

Output tensor.

Restrictions

  • The value of axes must be less than the number of dimensions of input x.
  • The size of the axes array must be 1.
  • The value of reverse must be false.
  • The value of exclusive must be false.