Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for the element-wise rectified linear unit .
Saves the input so the backward pass can rebuild the positive-input mask and gate the upstream gradient through it. At the non-differentiable point the subgradient is taken to be , which matches the reference framework's convention.
Math
Attributes
schema_v1OpSchema"relu", AmpPolicy::KeepInput (ReLU is well-defined on integer dtypes, so the AMP layer leaves the input dtype untouched).Notes
MLX exposes a native maximum(x, 0) kernel on the GPU stream; the CPU
path goes through vDSP_vmax against a zero buffer. grad_formula_impl
(used by create_graph=True) builds the mask as sign(relu(x)) so the
inverse-mask multiplication stays inside the autograd graph for second-order
differentiation.
Static methods
1Methods
2Eager-mode backward: , computed via a positive-input mask multiplied element-wise against the upstream gradient.
Parameters
gStoragedL/dy matching the forward output shape.Returns
StoragedL/dx at the input shape and dtype.
Graph-mode backward used when create_graph=True. Builds the mask as sign(relu(x)) (zero for , one for ) so the operation is itself differentiable for higher-order gradients.