code wiki / (root) / nx_vitpose_patchembed.nx

nx_vitpose_patchembed.nx

buildroot/runtime/nx_vitpose_patchembed.nx

5836 B101 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic vitpose
docsdependenciesstructsconstsfunctions

about

nx_vitpose_patchembed.nx -- FIRST assembly rung of the faithful f32 ViTPose forward: load the REAL patch-embed weights (projection.weight [768,3,16,16] + bias [768]) and position_embeddings [1,193,768] from the downloaded safetensors (targeted seek+read), run the patch-embed Conv2d(3->768,k16,s16) on a 256x192x3 input, transpose the [768,16,12] feature map into 192 tokens x 768, and add the position embeddings (index 1.. -> skip the cls slot). Structural gate: token block is 192x768, finite (no NaN/Inf), non-trivial. (No PyTorch reference in-env -> the assembly is built rung-by-rung with structural/property gates; final validation = keypoints on a real image.) expect_exit: 0

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_f32.nx nx_f32_cvt.nx nx_f32_conv2d.nx nx_safetensors_load.nx nx_vitpose_patchembed.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_cvt.nxnx_f32_conv2d.nxnx_safetensors_load.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap rdfile sys_openat_rd sys_read sys_close w sys_write sys_exit sys_openat_rd ↻ sys_read ↻ u64le load_named sys_mmap ↻ stl_tensor stl_find sys_mmap ↻ stl_parse_int sys_lseek sys_read ↻ stl_read_f32 stl_streq stl_u32le nx_f16_to_f32 stl_u16le sys_close ↻ wn w ↻ sys_mmap ↻ sys_write ↻ nx_i32_to_f32 nx_f32_conv2d_forward 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

structs

none

consts

13const K_MAGIC_4096: i64 = 4096
14const K_MAGIC_589824: i64 = 589824
15const K_MAGIC_148224: i64 = 148224
16const K_MAGIC_100000: i64 = 100000

functions

18func w(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 2: wnmain calls 1: sys_write
19func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); 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; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
called by 1: main calls 3: wsys_mmapsys_write
20func rdfile(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0-1} var n: i64=sys_read(fd,buf,cap-1); sys_close(fd); if n<0{return 0-1} var go: i64=1; while go==1{go=0; if n>0{ let c: i64=buf[n-1] as i64; if c==10{n=n-1;go=1} if c==13{n=n-1;go=1} if c==32{n=n-1;go=1} }} buf[n]=0 as u8; return n }
called by 1: main calls 3: sys_openat_rdsys_readsys_close
21func u64le(buf: *u8, off: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v=v|((buf[off+i]&0xff)<<(i*8)); i=i+1 } return v }
called by 1: main
24func load_named(fd: i64, hbuf: *u8, hlen: i64, data_start: i64, name: *u8, out: *i64) -> i64
36func main() -> i64