Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for Leaky ReLU if else .
The slope hyper-parameter is captured on the node so the eager backward
can rebuild the leaky mask without re-reading it from outside the graph.
Because the standard UnaryKernel::forward does not thread the slope
argument through dispatch(), an explicit forward() override is
used; cpu_kernel is provided alongside it so the per-device dispatcher
can still pick a CPU path when MLX is unavailable.
Math
\qquad \frac{\partial y}{\partial x} = \begin{cases} 1, & x > 0 \\ s, & x \le 0 \end{cases}$$ where $s$ is the configured slope.Attributes
schema_v1OpSchema"leaky_relu", AmpPolicy::KeepInput.slope_double0.01.Static methods
2cpu_kernel
CpuStorage cpu_kernel(const CpuStorage & a, const int & out_shape, Dtype dt, double slope)CPU kernel used by the dispatcher; mirrors forward but acts on a pre-resolved CPU storage.
Custom forward that captures slope on the backward node and wires the autograd edges manually (the default UnaryKernel::forward signature does not thread an extra parameter through dispatch()).
Parameters
aTensorImplPtrslopedoubles such that for .Returns
TensorImplPtrForward output with autograd edges wired to LeakyReluBackward.