Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for the multi-axis reduction sum .
The gradient broadcasts unchanged from the reduced shape back to the
input shape because for every element
participating in the sum. kSavesInput = false and no output is
saved — the rule is independent of both the forward input and output.
Math
Attributes
schema_v1OpSchemaRegistered as
"sum" with AmpPolicy::Promote — integer and boolean inputs are promoted to int64 before reduction so the sum cannot overflow narrow integer dtypes (parity fix found during the M4 Max training sanity check, where bool.sum() previously dropped to any() semantics on GPU).kSavesInputboolfalse. Backward depends only on shape metadata.Notes
Dispatch: Accelerate strided reductions (CPU) / MLX sum (GPU).
For empty reductions the output is (additive identity).
Static methods
1Methods
2Backward — broadcasts grad_out back to the input shape (ones gradient).
Graph-mode scaling helper — sum requires no scaling, so the broadcast-expanded gradient is returned unchanged.