code wiki / (root) / nx_hifigan_verify.nx

nx_hifigan_verify.nx

buildroot/runtime/nx_hifigan_verify.nx

10527 B149 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tooltopic hifigan
docsdependenciesstructsconstsfunctions

about

nx_hifigan_verify.nx -- VERIFY our sovereign HiFi-GAN against the transformers oracle (Qwen-style). Reads a REAL SpeechT5 mel (ref_mel_short.f32, [T,80] row-major) + the reference vocoder output (ref_audio_short.f32, [T*256]) produced by hifigan_oracle.py, runs OUR nx_hifigan forward on the same mel, and reports the max/mean abs error. Small error => our vocoder is CORRECT (produces the same human-grade audio as the reference). Also writes our audio as a 16kHz WAV so it can be published to /listen and HEARD. license_tier: ORIGINAL expect_exit: 0

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_f32.nx nx_f32_activations.nx nx_f32_cvt.nx nx_vocops.nx nx_hifigan_verify.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_activations.nxnx_f32_cvt.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 p sys_write sys_mmap read_all sys_openat_rd sys_mmap ↻ sys_read sys_close sys_exit pn sys_write ↻ sys_mmap ↻ u32le u16le nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ f32_sub nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ conv1d nx_f32_add ↻ 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 ↻

structs

none

consts

12const SLOPE01: i64 = 0x3DCCCCCD
13const F_THIRD: i64 = 0x3EAAAAAB

functions

15func p(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
16func pn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d: *u8=sys_mmap(24); var k: i64=0; while m>0 {d[k]=(48+(m%10)) as u8; m=m/10; k=k+1} var i: i64=k-1; while i>=0 {let o: *u8=sys_mmap(1); o[0]=d[i]; sys_write(1,o,1); i=i-1} return 0 }
called by 1: main calls 2: sys_writesys_mmap
17func phx(v: i64) -> i64 { let b: *u8=sys_mmap(8); var i: i64=0; while i<8 { let n: i64=(v>>((7-i)*4))&0xF; if n<10 {b[i]=(48+n) as u8} else {b[i]=(87+n) as u8} i=i+1 } sys_write(1,b,8); return 0 }
called by 1: main calls 2: sys_mmapsys_write
18func u16le(b: *u8, o: i64) -> i64 { return (b[o]&0xff) | ((b[o+1]&0xff)<<8) }
called by 1: main
19func u32le(b: *u8, o: i64) -> i64 { return (b[o]&0xff) | ((b[o+1]&0xff)<<8) | ((b[o+2]&0xff)<<16) | ((b[o+3]&0xff)<<24) }
called by 1: main
20func f32_sub(a: i64, b: i64) -> i64 { return nx_f32_add(a, (b & 0xFFFFFFFF) ^ 0x80000000) }
called by 1: main calls 1: nx_f32_add
21func f32_abs(a: i64) -> i64 { return a & 0x7FFFFFFF }
called by 1: main
22func vcopy(d: *i64, s: *i64, n: i64) -> i64 { var i: i64=0; while i<n { d[i]=s[i]; i=i+1 } return 0 }
called by 1: main
23func vaddto(d: *i64, s: *i64, n: i64) -> i64 { var i: i64=0; while i<n { d[i]=nx_f32_add(d[i],s[i]); i=i+1 } return 0 }
called by 1: main calls 1: nx_f32_add
24func vzero(d: *i64, n: i64) -> i64 { var i: i64=0; while i<n { d[i]=0; i=i+1 } return 0 }
called by 1: main
25func vscale(d: *i64, n: i64, s: i64) -> i64 { var i: i64=0; while i<n { d[i]=nx_f32_mul(d[i],s); i=i+1 } return 0 }
called by 1: main calls 1: nx_f32_mul
28func read_all(path: *u8, cap: i64, bufp: *i64) -> i64
35func main() -> i64