Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for the multi-axis reduction product .
The gradient is the "product of all other elements", which can be
recovered cheaply from the saved output:
. Both the forward input
() and the forward output () are saved so grad_formula can
reconstruct the ratio without rerunning the reduction.
Because no single IBackend overload spans every Accelerate /
MLX combination, prod provides explicit cpu_kernel and
gpu_kernel overloads instead of a shared dispatch.
Math
Attributes
schema_v1OpSchema"prod" with AmpPolicy::Promote.kSavesInputbooltrue.kSavesOutputbooltrue.Notes
CPU path iterates axes in descending order so the lower indices
remain valid as dimensions are successively collapsed. GPU path
delegates to mlx::core::prod with keepdims. Empty
reductions return (multiplicative identity). Zero elements in
make the division step undefined; the reference framework
returns NaN there and Lucid follows.
Static methods
2cpu_kernel
CpuStorage cpu_kernel(const CpuStorage & a, const int & in_shape, const int & axes, bool keepdims, Dtype dt)CPU path: iterates axes in descending order (innermost last) to produce a correct sequential multi-axis product using Accelerate primitives.
gpu_kernel
GpuStorage gpu_kernel(const GpuStorage & a, const int & in_shape, const int & axes, bool keepdims, Dtype dt)GPU path: delegates to mlx::core::prod with keepdims.