Evaluate the cumulative sum (inclusive) along a given dimension. More...
Evaluate the cumulative sum (inclusive) along a given dimension.
For a 1D array \(X\), the inclusive cumulative sum calculates \(x_i = \sum_{p=0}^{i}x_p\) for every \(x \in X\). Here is a simple example for the 1D case:
float hA[] = {0, 1, 2, 3, 4};
array A(5, hA);
array accumA = accum(A);
For 2D arrays and higher dimensions, you can specify the dimension along which the cumulative sum will be calculated. Thus, the formula above will be calculated for all array slices along the specified dimension (in the 2D case for example, this looks like \(x_{i,j} = \sum_{p=0}^{j}x_{i,p}\) if the second dimension (dim1) was chosen). If no dimension is specified, then the first dimension (dim0) is used by default (only in the C++ API; the dimension is required to be specified in the C API):
float hB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
array B(3, 3, hB);
array accumB_dim0 = accum(B);
array accumB_dim1 = accum(B, 1);
The output array type may be different from the input array type. The following table defines corresponding output types for each input type:
Input Type Output Type f32, f64, c32, c64 same as input s32, s64, u32, u64 same as input s16 s32 u16, u8, b8 u32This function runs across all batches in the input simultaneously.
◆ accum()C++ Interface to evaluate the cumulative sum (inclusive) along a given dimension.
C Interface to evaluate the cumulative sum (inclusive) along a given dimension.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4