Expand description
Special functions: lgamma, digamma, erf, erfc, the exponentially
scaled Bessel functions, the incomplete gamma and beta functions,
polygamma, and zeta.
Each function is written once, against Builder, in the masked,
vectorized style of XLA’s and JAX’s own implementations: loops carry a
mask of the elements that have not converged, and the elements that
have converged keep their state, so each element’s result does not
depend on the other elements. The kernels run the algorithms on scalars
(unary, binary, ternary); ruxla-prims runs the same code
on IR to lower the primitives that JAX lowers by tracing such code.
The algorithms follow:
- StableHLO’s decomposition of CHLO (
ChloLegalizeToStablehlo.cpp) forlgamma,digamma,erf,erfc,bessel_i1e,polygamma, andzeta, which XLA expands; jax._src.lax.specialforigamma,igammac,igamma_grad_a,random_gamma_grad,bessel_i0e, andregularized_incomplete_beta.
The operations are evaluated in the same order, so the results match XLA
up to the implementations of exp, log, sin, and the like, and up
to the fusion of multiplications and additions.
Structs§
- Carry
- The values a
Builder::while_loopcarries: masks and floats.
Traits§
- Builder
- The operations the special functions are written with.
Functions§
- bessel_
i0e exp(-|x|) I0(x), asjax._src.lax.special.bessel_i0e_impl.- bessel_
i1e exp(-|x|) I1(x), as StableHLO decomposeschlo.bessel_i1e.- digamma
- The digamma function, the derivative of
lgamma. - erf
- The error function.
- erf_inv
- The inverse error function: M. Giles’ approximation, as StableHLO
decomposes
chlo.erf_inv. - erfc
- The complementary error function.
- eval_
binary - Evaluates a special binary operation with a builder.
- eval_
unary - Evaluates a special unary operation with a builder.
- igamma
- The regularized lower incomplete gamma function
P(a, x). - igamma_
grad_ a - The derivative of
igamma(a, x)with respect toa. - igammac
- The regularized upper incomplete gamma function
Q(a, x). - lgamma
- The logarithm of the absolute value of the gamma function.
- polygamma
- The polygamma function
psi^(n)(x). - random_
gamma_ grad - The derivative of a sample
xofGamma(a, 1)with respect toa. - regularized_
incomplete_ beta - The regularized incomplete beta function
I_x(a, b), by the continued fraction of DLMF 8.17.22 evaluated with the modified Lentz algorithm. - zeta
- The Hurwitz zeta function
zeta(x, q).