Skip to content
class

ExpBackward

ExpBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for element-wise exponential y=exy = e^x.

Saves the output yy rather than the input because the backward formula is ∂y/∂x=ex=y\partial y / \partial x = e^x = y and reusing the saved output avoids a second vvexpf pass.

Math

\frac{\partial y}{\partial x} = e^x = y, \qquad \frac{\partial \mathcal{L}}{\partial x} = y\,\frac{\partial \mathcal{L}}{\partial y}.$$

Attributes

schema_v1OpSchema
Registered as "exp" with AmpPolicy::ForceFP32 — half- precision inputs are upcast to F32 prior to dispatch to avoid premature overflow / underflow.
kSavesInputbool
false.
kSavesOutputbool
true — saved tensor is y=exy = e^x.

Notes

Dispatch: Accelerate vvexpf/vvexp (CPU) / MLX exp (GPU). Large-magnitude positive inputs overflow to +inf; large-magnitude negative inputs flush to 0.

Static methods

1
static

dispatch

int dispatch(backend::IBackend & be, const int & a, const int & shape, Dtype dt)

Forward — calls IBackend::exp to compute y=exy = e^x.

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Backward — ∂y/∂x=ex=y\partial y/\partial x = e^x = y, scaled by grad_out.

fn

grad_formula_impl

int grad_formula_impl(const int & g, const int &, const int & out)

Graph-mode backward: ∂x=out⋅g\partial x = \mathrm{out} \cdot g using the saved output exe^x, kept inside the autograd graph.