warp.utils.array_inner#
- warp.utils.array_inner(a, b, out=None, count=None, axis=None)[source]#
Compute the inner product of two arrays.
This function computes the dot product between two arrays with the same shape, optionally along a specified axis. When
axisisNone, it computes a single inner product over the flattened arrays. Partial reductions and inputs with different layouts use logical row-major order. Full reductions of inputs with the same compact layout may use physical storage order.During CPU graph capture, or CUDA graph capture with
apic=True, non-empty calls require an explicitoutarray so replay can store the current result. Existing whole-array, explicit-count, composite-dtype, and positive-stride axis reductions are recorded. Non-empty whole-array reductions that require contiguous copies are unsupported during API Capture (APIC) recording; make inputs contiguous before capture or specify an axis for strided reductions. Negative strides raiseNotImplementedErrorduring APIC recording. Counts and reduction strides must fit signed 32-bit integers, and participating addresses and strides must be aligned to the scalar type.- Parameters:
a (array) – First input array.
b (array) – Second input array. Must have the same shape and data type as
a.out (array | None) – Output array to store results. If
None, a new array is created.count (int | None) – Number of elements to process. Must not exceed the input size, or the selected axis length when
axisis specified. IfNone, processes the entire reduction.axis (int | None) – Axis along which to compute inner product. Negative values count from the last dimension. If
None, computes a single inner product over the flattened arrays.
- Returns:
The inner product result. Returns a float if
axisisNoneandoutisNone, otherwise returns theoutarray.- Raises:
ValueError – If
aandbhave different shapes.IndexError – If
axisis outside the valid range fora.RuntimeError – If
countexceeds the reduction size, array storage devices or data types are incompatible, or an APIC-recorded call uses an unsupported count or memory layout.NotImplementedError – If a non-empty call during APIC recording omits
out. Also raised if any input or output array has a negative stride during APIC recording, including for a zero-count call, or a non-empty whole-array reduction requires a contiguous copy during APIC recording.
- Return type: