nx_f32_gelu.nx
buildroot/runtime/nx_f32_gelu.nx
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
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
| 11 | const K_MAGIC_3275911: i64 = 3275911 |
| 12 | const K_MAGIC_10000000: i64 = 10000000 |
| 13 | const K_MAGIC_254829592: i64 = 254829592 |
| 14 | const K_MAGIC_1000000000: i64 = 1000000000 |
| 15 | const K_MAGIC_284496736: i64 = 284496736 |
| 16 | const K_MAGIC_1421413741: i64 = 1421413741 |
| 17 | const K_MAGIC_1453152027: i64 = 1453152027 |
| 18 | const K_MAGIC_1061405429: i64 = 1061405429 |
functions
| 21 | func nx_f32_erf(z: i64) -> i64 called by 2: nx_f32_gelumain calls 8: nx_i32_to_f32nx_f32_divnx_f32_negnx_f32_ltnx_f32_addnx_f32_mul+2 |
| 44 | func nx_f32_gelu(x: i64) -> i64 called by 2: nx_f32_gelu_vecmain calls 6: nx_i32_to_f32nx_f32_divnx_f32_sqrtnx_f32_erfnx_f32_mulnx_f32_add |
| 53 | func nx_f32_gelu_vec(buf: *i64, n: i64) -> i64 |