Skip to content
fn

prod_axis_f32

void prod_axis_f32(const float * in, float * out, int outer, int reduce_dim, int inner)

Reduces a single axis by multiplicative product into a packed (outer, inner) output.

Identity element is 1; an empty reduce dimension yields 1 per cell. Uses the generic axis_reduce template — there is no vDSP equivalent. Note that floating-point products are not associative, so the result is deterministic only for a fixed loop order (the kernel iterates r from 0 to reduce_dim - 1).

Math

out[o,i]=∏r=0reduce_dim−1in[o,r,i].\text{out}[o, i] = \prod_{r=0}^{\text{reduce\_dim}-1} \text{in}[o, r, i].

Parameters

inconst float*
Source buffer of shape (outer, reduce_dim, inner).
outfloat*
Destination buffer of shape (outer, inner).
outer, reduce_dim, innerstd::size_t
Layout extents; see sum_axis_f32.

Notes

Overflow and underflow are unchecked. Callers that require log-sum-exp style stability must compute the product in log space themselves.