Exact real meanings of pointwise operators #
Over the reals, Spec.PointwiseOp.meaning is the mathematical function each PyTorch operator
approximates. It is defined except at poles and outside the real domain: the quotient and its floor
and truncation need a nonzero divisor, 1 / √x a positive x, and Real.rpow the domain
described in Context.realPointwise, while Spec.erf is total. A real result beyond the range of
a binary format, such as a quotient that rounds to an infinity in binary32, keeps its real value.
This module proves that the exact GELU assembled in PyTorch's order of operations is
x (1 + erf (x / √2)) / 2, and that PyTorch's flooring-division schedule, which binary formats run
with rounded operations, computes ⌊a / b⌋ in exact arithmetic. NN.Proofs.Probability.NormalCdf
proves that (1 + erf (x / √2)) / 2 is the standard normal distribution function Φ(x).
References #
- Dan Hendrycks and Kevin Gimpel, "Gaussian Error Linear Units (GELUs)", arXiv:1606.08415
Over the reals, the tanh GELU is Activation.Math.geluSpec, with √(2 / π) exact.
Truncation differs from the floor by one exactly when it overshoots the argument.
PyTorch's flooring-division schedule computes ⌊a / b⌋ in exact real arithmetic, with C's
fmod as a - b * trunc (a / b).