Skip to content
class

SiluBackward

SiluBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for the SiLU / Swish activation y=x⋅σ(x)y = x \cdot \sigma(x) (Hendrycks & Gimpel 2016 / Ramachandran et al. 2017).

Saves the input xx; the backward delegates to the backend so the fused gradient kernel (σ(x) (1+x(1−σ(x)))\sigma(x)\,(1 + x(1 - \sigma(x)))) runs as a single pass on MLX or a single Accelerate composition on CPU rather than the prior seven-op storage-primitive expansion.

Math

= \sigma(x)\,\bigl(1 + x\,(1 - \sigma(x))\bigr)$$ **References** Hendrycks & Gimpel, "Gaussian Error Linear Units (GELUs)", 2016. Ramachandran et al., "Searching for Activation Functions", 2017.

Attributes

schema_v1OpSchema
"silu", AmpPolicy::Promote.

Static methods

1
static

dispatch

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

Forward — calls IBackend::silu to compute y=x⋅σ(x)y = x \cdot \sigma(x).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Eager-mode backward: dispatches to IBackend::silu_backward with the saved input and the upstream gradient.

fn

grad_formula_impl

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

Graph-mode backward: the same derivative built from composable ops so the gradient itself stays differentiable. The fused backend kernel returns a Storage, which carries no graph — a second derivative has to come from the expression, not the kernel.