code wiki / _hdl_build / nx_inr_patch_gate.nx
nx_inr_patch_gate.nx
buildroot/runtime/_hdl_build/nx_inr_patch_gate.nx
about
nx_inr_patch_gate.nx -- FIRST sovereign neural-codec rung: our clean-room autograd OVERFITS a REAL image
patch (an Implicit Neural Representation: a small coordinate MLP f(x,y)->luma learned to reconstruct an
8x8 luma patch of ref_frame0.yuv). Proves "our autograd represents a real image" -- the foundation the
COOL-CHIC-style codec stands on. ALL tools provably clean (autodiff=UNPAT, MLP/ReLU/SGD=UNPAT) -> passes
nx_codec_provenance_gate. HONEST: this is the REPRESENTATION proof (net learns the patch); compression
(latents, larger frames where weights amortize, rANS) is the next rung. license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_emit_lib.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
| 10 | const Q: i64 = 65536 |
functions
| 11 | func g_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; 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 } |
| 12 | func g_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 13 | func g_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; 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(fd,bb,k); return 0 } |
| 14 | func iabs(v: i64) -> i64 { if v<0 { return 0-v } return v } called by 1: main |
| 15 | func clampb(v: i64) -> i64 { if v<0 { return 0 } if v>255 { return 255 } return v } called by 1: main |
| 17 | func ag_leaf(tp: *i64, np: *i64, v: i64) -> i64 { let k: i64=np[0]; tp[k*5]=v; tp[k*5+2]=0; tp[k*5+3]=0-1; tp[k*5+4]=0-1; np[0]=k+1; return k } |
| 18 | func ag_add(tp: *i64, np: *i64, i: i64, j: i64) -> i64 { let k: i64=np[0]; tp[k*5]=tp[i*5]+tp[j*5]; tp[k*5+2]=1; tp[k*5+3]=i; tp[k*5+4]=j; np[0]=k+1; return k } called by 1: build_inr |
| 19 | func ag_sub(tp: *i64, np: *i64, i: i64, j: i64) -> i64 { let k: i64=np[0]; tp[k*5]=tp[i*5]-tp[j*5]; tp[k*5+2]=4; tp[k*5+3]=i; tp[k*5+4]=j; np[0]=k+1; return k } called by 1: main |
| 20 | func ag_mul(tp: *i64, np: *i64, i: i64, j: i64) -> i64 { let k: i64=np[0]; tp[k*5]=(tp[i*5]*tp[j*5])>>16; tp[k*5+2]=2; tp[k*5+3]=i; tp[k*5+4]=j; np[0]=k+1; return k } |
| 21 | func ag_relu(tp: *i64, np: *i64, i: i64) -> i64 { let k: i64=np[0]; var v: i64=tp[i*5]; if v<0 { v=0 } tp[k*5]=v; tp[k*5+2]=3; tp[k*5+3]=i; tp[k*5+4]=0-1; np[0]=k+1; return k } called by 1: build_inr |
| 22 | func ag_backward(tp: *i64, np: *i64, out: i64) -> i64 called by 1: main |
| 37 | func build_inr(tp: *i64, np: *i64, W1: *i64, b1: *i64, w2: *i64, b2v: i64, H: i64, xn: i64, yn: i64) -> i64 |
| 60 | func main() -> i64 |