cupy.cumulative_sum#

cupy.cumulative_sum(x, /, *, axis=None, dtype=None, out=None, include_initial=False)[source]#

Returns the cumulative sum of elements along a given axis.

This function is an Array API compatible alternative to cupy.cumsum().

Parameters:
  • x (cupy.ndarray) – Input array.

  • axis (int or None) – Axis along which the cumulative sum is computed. The default (None) is only allowed for one-dimensional arrays. For arrays with more than one dimension axis is required.

  • dtype – Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of x, unless x has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.

  • out (cupy.ndarray) – Alternative output array in which to place the result. It must have the same shape as the expected output but the type will be cast if necessary.

  • include_initial (bool) – Boolean indicating whether to include the initial value (zeros) as the first value in the output. With include_initial=True the shape of the output is different than the shape of the input. Default: False.

Returns:

The result array.

Return type:

cupy.ndarray