jax.numpy.cumsum — JAX documentation (original) (raw)

jax.numpy.cumsum#

jax.numpy.cumsum(a, axis=None, dtype=None, out=None)[source]#

Cumulative sum of elements along an axis.

JAX implementation of numpy.cumsum().

Parameters:

Returns:

An array containing the accumulated sum along the given axis.

Return type:

Array

See also

Examples

x = jnp.array([[1, 2, 3], ... [4, 5, 6]]) jnp.cumsum(x) # flattened cumulative sum Array([ 1, 3, 6, 10, 15, 21], dtype=int32) jnp.cumsum(x, axis=1) # cumulative sum along axis 1 Array([[ 1, 3, 6], [ 4, 9, 15]], dtype=int32)