nx_hifigan_gen.nx
buildroot/runtime/nx_hifigan_gen.nx
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
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
structs
| none |
consts
| 11 | const F_MAGIC_131072: i64 = 131072 |
| 12 | const F_MAGIC_4096: i64 = 4096 |
| 13 | const F_MAGIC_65536: i64 = 65536 |
| 15 | const SLOPE01: i64 = 0x3DCCCCCD // 0.1 (leaky_relu_slope from the real config) |
| 16 | const F_THIRD: i64 = 0x3EAAAAAB // 1/3 |
| 17 | const WC_VAL: i64 = 0x3CA3D70A // 0.02 (small synthetic weight so values stay bounded) |
functions
| 19 | func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 20 | func 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 } |
| 21 | func 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 |
| 22 | func 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 } |
| 23 | func 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 } |
| 26 | func 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 |
| 33 | func 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 |
| 42 | func generator_forward(mel: *i64, C_mel: i64, T: i64, init_ch: i64, up_rate: i64, up_kernel: i64, out: *i64) -> i64 |
| 72 | func main() -> i64 |