warp.utils.array_sum#

warp.utils.array_sum(values, out=None, value_count=None, axis=None)[source]#

Compute the sum of array elements.

This function computes the sum of array elements, optionally along a specified axis. The operation can be performed on the entire array or along a specific dimension.

During matching-device APIC graph capture, non-empty calls require an explicit out array so replay can store the current result. Existing whole-array, explicit-count, composite-dtype, and positive-stride axis reductions are recorded. Negative strides raise NotImplementedError during APIC capture. Counts and reduction strides must fit the native signed 32-bit ABI, and participating addresses and strides must be aligned to the scalar type.

Parameters:
  • values (array) – Input array to sum. Its scalar type must be float32 or float64.

  • out (array | None) – Output array to store results. If None, a new array is created.

  • value_count (int | None) – Number of elements to process. If None, processes entire array.

  • axis (int | None) – Axis along which to compute sum. If None, computes sum of all elements.

Returns:

The sum result. Returns a float if axis is None and out is None, otherwise returns the out array.

Raises:
  • RuntimeError – If output array storage device or data type is incompatible with input array, or if a matching-device APIC-captured call uses a count or layout that the native reduction ABI cannot represent.

  • NotImplementedError – If a non-empty call under matching-device APIC graph capture omits out. Also raised if any input or output array has a negative stride under matching-device APIC graph capture, including for a zero-count call.

Return type:

array | float