code wiki / _hdl_build / _tensor_grad_authored.nx
_tensor_grad_authored.nx
buildroot/runtime/_hdl_build/_tensor_grad_authored.nx
about
AUTHORED BY THE NISHI BUILDER (nx_module_author tensor-grad template) -- T6 tensor autograd.
Tutoring: specs/2026-06-09-tutoring-training-substrate-rung2-tensor.md
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.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
| 24 | const TG_NCAP: i64 = 256 |
| 25 | const TG_ACAP: i64 = 16384 |
functions
| 7 | func _tg_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 8 | func _tg_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;k=1}; while m>0{t[k]=48+(m%10);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 } |
| 9 | func tg_q(n: i64, d: i64) -> i64 { return nx_f32_div(nx_i32_to_f32(n), nx_i32_to_f32(d)) } |
| 10 | func tg_milli(v: i64) -> i64 |
| 26 | func tg_alloc(arena: *i64, ab: *i64, n: i64) -> *i64 |
| 35 | func tg_node(tape: *i64, nb: *i64, op: i64, ai: i64, bi: i64, rows: i64, cols: i64, valp: *i64, gradp: *i64) -> i64 |
| 49 | func tg_valp(tape: *i64, x: i64) -> *i64 { return tape[x*8+5] as *i64 } |
| 50 | func tg_gradp(tape: *i64, x: i64) -> *i64 { return tape[x*8+6] as *i64 } |
| 51 | func tg_leaf(tape: *i64, nb: *i64, arena: *i64, ab: *i64, p: *i64, rows: i64, cols: i64) -> i64 |
| 54 | func tg_matvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, a: i64, x: i64) -> i64 |
| 70 | func tg_addvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64, y: i64) -> i64 |
| 79 | func tg_reluvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64) -> i64 |
| 92 | func tg_mse(tape: *i64, nb: *i64, arena: *i64, ab: *i64, p: i64, t: i64) -> i64 |
| 107 | func tg_smul(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64, y: i64) -> i64 |
| 114 | func tg_backward(tape: *i64, nt: i64, root: i64) -> i64 called by 3: gate_atg_trainad_train calls 8: tg_gradpnx_i32_to_f32tg_valpnx_f32_addnx_f32_mulnx_f32_gt+2 |
| 190 | func tg_fwd_mlp(w1: *i64, b1: *i64, w2: *i64, b2: *i64, x: *i64, t: i64) -> i64 |
| 207 | func tg_pget(w1: *i64, b1: *i64, w2: *i64, b2: *i64, k: i64) -> i64 called by 1: gate_a |
| 213 | func tg_pset(w1: *i64, b1: *i64, w2: *i64, b2: *i64, k: i64, v: i64) -> i64 called by 1: gate_a |
| 220 | func gate_a(tape: *i64, nb: *i64, arena: *i64, ab: *i64) -> i64 |
| 279 | func tg_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, out: *i64) -> i64 |
| 349 | func ad_step(w: *i64, g: *i64, m: *i64, v: *i64, n: i64, lr: i64, b1: i64, b2: i64, eps: i64, wd: i64, t: i64) -> i64 |
| 370 | func ad_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, out: *i64) -> i64 |
| 443 | func main() -> i64 |