code wiki / (root) / nx_hifigan_gen.nx

nx_hifigan_gen.nx

buildroot/runtime/nx_hifigan_gen.nx

7168 B108 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tooltopic hifigan
docsdependenciesstructsconstsfunctions

about

nx_hifigan_gen.nx -- the HiFi-GAN GENERATOR GRAPH (composition of the verified nx_vocops atoms), configurable to the real fetched config (conv_pre → [leaky→upsample→MRF]×4 → leaky→conv_post→tanh). This gate runs the FULL forward end-to-end on a TINY synthetic config (same wiring, small channels = fast) and verifies: output length = T * prod(upsample_rates), channels collapse to 1, and every output is FINITE + tanh-bounded [-1,1]. When a real checkpoint is loaded (weights via nx_https_get_stream + nx_safetensors + weight_norm_apply), this same graph runs at the real 512-ch dims and produces audio -> nx_voice_eval measures the jump. license_tier: ORIGINAL expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_f32.nx nx_f32_activations.nx nx_vocops.nx nx_hifigan_gen.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_activations.nxnx_vocops.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cw sys_write sys_mmap generator_forward sys_mmap ↻ conv1d nx_f32_add nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ leaky_relu_vec leaky_relu nx_f32_mul ↻ conv_transpose1d nx_f32_add ↻ nx_f32_mul ↻ gen_mrf gen_resblock resblock1_1dil leaky_relu ↻ conv1d ↻ nx_f32_add ↻ vaddto nx_f32_add ↻ vscale nx_f32_mul ↻ vcopy nx_f32_tanh nx_f32_mul ↻ nx_f32_sigmoid nx_f32_neg

structs

none

consts

11const F_MAGIC_131072: i64 = 131072
12const F_MAGIC_4096: i64 = 4096
13const F_MAGIC_65536: i64 = 65536
15const SLOPE01: i64 = 0x3DCCCCCD // 0.1 (leaky_relu_slope from the real config)
16const F_THIRD: i64 = 0x3EAAAAAB // 1/3
17const WC_VAL: i64 = 0x3CA3D70A // 0.02 (small synthetic weight so values stay bounded)

functions

19func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
20func cn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
21func vcopy(dst: *i64, src: *i64, n: i64) -> i64 { var i: i64=0; while i<n { dst[i]=src[i]; i=i+1 } return 0 }
called by 1: generator_forward
22func vaddto(dst: *i64, src: *i64, n: i64) -> i64 { var i: i64=0; while i<n { dst[i]=nx_f32_add(dst[i], src[i]); i=i+1 } return 0 }
called by 1: gen_mrf calls 1: nx_f32_add
23func vscale(v: *i64, n: i64, s: i64) -> i64 { var i: i64=0; while i<n { v[i]=nx_f32_mul(v[i], s); i=i+1 } return 0 }
called by 1: gen_mrf calls 1: nx_f32_mul
26func gen_resblock(x: *i64, ch: i64, L: i64, K: i64, wc: *i64, bz: *i64, out: *i64, sa: *i64, sb: *i64, t1: *i64, t2: *i64) -> i64
called by 1: gen_mrf calls 1: resblock1_1dil
33func gen_mrf(x: *i64, ch: i64, L: i64, wc: *i64, bz: *i64, out: *i64, sa: *i64, sb: *i64, sc: *i64, t1: *i64, t2: *i64) -> i64
42func generator_forward(mel: *i64, C_mel: i64, T: i64, init_ch: i64, up_rate: i64, up_kernel: i64, out: *i64) -> i64
72func main() -> i64