Skip to main content

ClikaRT::ops::cumsum

function

cumsum()​

Tensor cumsum(
    Tensor input,
    int64_t dim,
    DataType dtype = DataType::Undefined
)

Cumulative sum along dim (inclusive scan).

outk=∑j≤kxj\mathrm{out}_k = \sum_{j \le k} x_j

Output mirrors input's shape; dtype widens the accumulation/output when set (Undefined keeps input's dtype).

Parameters

  • input: the input tensor.
  • dim: the axis to scan along.
  • dtype: output dtype; Undefined keeps input's dtype.

Returns: the scanned tensor, same shape as input.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when dim is out of range.
auto cu = ClikaRT::ops::cumsum(lengths, 0); // prefix sums

Declared in ClikaRT/compute/ops.h, line 4569