code wiki / (root) / nx_f32_bn_fold.nx

nx_f32_bn_fold.nx

buildroot/runtime/nx_f32_bn_fold.nx

1565 B29 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind librarytopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_bn_fold.nx -- fold inference BatchNorm into the PRECEDING conv's weights + bias (offline), so a ResNet/ HRNet-class pose net (which uses BN, not GroupNorm) loads straight into the existing dense/grouped f32 conv with NO runtime BN kernel. For a conv output x = W*in + b followed by BN y = gamma*(x-mean)/sqrt(var+eps) + beta, the fold is exact per output channel: s = gamma/sqrt(var+eps); W' = W*s; b' = (b-mean)*s + beta. Then foldedconv(in) == BN(conv(in)) identically. Composes nx_f32_mul/add/sub/sqrt/div. This is the standard "BN-fold" every inference runtime does; it means the porter never needs a live BatchNorm op. license_tier: ORIGINAL

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_f32.nx nx_f32_div.nx nx_f32_bn_fold.nx nx_f32_bn_fold_gate.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_div.nx

imported by: nx_f32_bn_fold_gate.nx

structs

none

consts

none

functions

13func nx_f32_bn_fold(W: *i64, b: *i64, C_out: i64, wpc: i64, gamma: *i64, beta: *i64, mean: *i64, vari: *i64, eps: i64, W_out: *i64, b_out: *i64) -> i64