Skip to content
class

ErfBackward

ErfBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for the element-wise error function y=erf(x)=(2/π)∫0xe−t2 dty = \mathrm{erf}(x) = (2/\sqrt{\pi})\int_0^x e^{-t^2}\,dt.

Saves the input x so the backward pass can build e−x2e^{-x^2}. Defined on all of R\mathbb{R} with range (−1,1)(-1, 1).

Math

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

Attributes

schema_v1OpSchema
Registered as "erf" with AmpPolicy::Promote.

Notes

Dispatch: Accelerate erf kernel (CPU) / MLX erf (GPU).

Static methods

1
static

dispatch

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

Forward — calls IBackend::erf to compute y=erf(x)y = \mathrm{erf}(x).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Backward — ∂y/∂x=(2/π) e−x2\partial y/\partial x = (2/\sqrt{\pi})\,e^{-x^2}, scaled by grad_out.

fn

grad_formula_impl

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

Graph-mode backward: ∂x=(2/π) e−x2 g\partial x = (2/\sqrt{\pi})\,e^{-x^2}\,g kept inside the autograd graph.