code wiki / (root) / nx_f32_gelu.nx

nx_f32_gelu.nx

buildroot/runtime/nx_f32_gelu.nx

2985 B57 linesdepth 5pulls 7 transitivereach 4 importersview sourcekind librarytopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_gelu.nx -- software-f32 EXACT GELU (erf-based, matching PyTorch nn.GELU default / HF "gelu"), the one transformer activation the f32 tower lacked (the LLM path uses SiLU/SwiGLU; ViT/ViTPose uses GELU). gelu(x) = 0.5*x*(1 + erf(x/sqrt2)). erf is the Abramowitz-Stegun 7.1.26 rational-times-exp approximation (|err| <= 1.5e-7, effectively f32-faithful), composing nx_f32_exp + the gated f32 arithmetic. Reusable ecosystem-wide for any ViT/BERT/GPT-2-class model port, not just the pose benchmark. license_tier: ORIGINAL

dependencies 5 imports · 2 importers

nx_syscalls.nx nx_f32.nx nx_f32_cvt.nx nx_f32_div.nx nx_f32_exp.nx nx_f32_gelu.nx nx_f32_gelu_gate.nx nx_vit_encoder_layer.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nxnx_f32_exp.nx

imported by: nx_f32_gelu_gate.nxnx_vit_encoder_layer.nx

structs

none

consts

11const K_MAGIC_3275911: i64 = 3275911
12const K_MAGIC_10000000: i64 = 10000000
13const K_MAGIC_254829592: i64 = 254829592
14const K_MAGIC_1000000000: i64 = 1000000000
15const K_MAGIC_284496736: i64 = 284496736
16const K_MAGIC_1421413741: i64 = 1421413741
17const K_MAGIC_1453152027: i64 = 1453152027
18const K_MAGIC_1061405429: i64 = 1061405429

functions

21func nx_f32_erf(z: i64) -> i64
44func nx_f32_gelu(x: i64) -> i64
53func nx_f32_gelu_vec(buf: *i64, n: i64) -> i64
called by 1: vit_encoder_layer calls 1: nx_f32_gelu