helion.language.cumsum

helion.language.cumsum(input_tensor, dim, reverse=False)[source]

Compute the cumulative sum along a specified dimension.

Equivalent to hl.associative_scan(torch.add, input_tensor, dim, reverse).

Parameters:
  • input_tensor (Tensor) – Input tensor to compute cumulative sum

  • dim (int) – The dimension along which to compute cumulative sum

  • reverse (bool) – If True, performs the cumsum in reverse order

Returns:

Tensor with same shape as input containing cumulative sum

Return type:

torch.Tensor

See also

Note

  • Output has same shape as input

  • Reverse=True computes cumsum from right to left

  • Equivalent to torch.cumsum