Skip to content
fn

layer_norm_forward_f64

void layer_norm_forward_f64(const double * x, const double * gamma, const double * beta, double * y, double * saved_mean, double * saved_rstd, int outer, int N, double eps)

Double-precision LayerNorm forward — generic template implementation that computes mean and variance with a two-pass loop (no vDSP equivalent exists for double at the same fusion level).

Math

yi=γixi−μσ2+ε+βi.y_i = \gamma_i \frac{x_i - \mu}{\sqrt{\sigma^2 + \varepsilon}} + \beta_i.

Parameters

xconst double*
Input buffer of shape (outer, N).
gamma, betaconst double*
Per-feature affine parameters of shape (N,).
ydouble*
Output buffer of shape (outer, N).
saved_mean, saved_rstddouble*
Per-row mean and reciprocal standard deviation, both shape (outer,).
outer, Nstd::size_t
Number of rows and length of the normalised axis.
epsdouble
Variance stabiliser.