easy framework

Cumulative Sum

Compute the cumulative sum of a 1D tensor.

The cumulative sum at position i is the sum of all elements from index 0 to i (inclusive).

Input: A 1D tensor x of shape (n,).

Output: A 1D tensor of shape (n,) where element i is sum(x[0:i+1]).

API Reference:

  • PyTorch: torch.cumsum(x, dim=0)
  • JAX: jnp.cumsum(x)

Hints

cumsum reduction torch.cumsum jnp.cumsum
Detecting runtime...