We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
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)
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.