code wiki / _hdl_build / _tensor_grad_authored.nx

_tensor_grad_authored.nx

buildroot/runtime/_hdl_build/_tensor_grad_authored.nx

22367 B553 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind tooltopic tensor
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx _tensor_grad_authored.nx

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

main _tg_puts sys_write sys_mmap gate_a sys_mmap ↻ tg_q 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 ↻ nx_i32_to_f32 nx_f32_neg tg_leaf tg_node _tg_puts ↻ sys_exit tg_alloc _tg_puts ↻ sys_exit ↻ tg_reluvec tg_valp tg_alloc ↻ nx_f32_lt nx_f32_is_nan nx_f32_classify ↻ nx_f32_is_zero nx_f32_classify ↻ tg_node ↻ tg_addvec tg_valp ↻ tg_alloc ↻ nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻

structs

none

consts

24const TG_NCAP: i64 = 256
25const TG_ACAP: i64 = 16384

functions

7func _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 }
8func _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 }
9func tg_q(n: i64, d: i64) -> i64 { return nx_f32_div(nx_i32_to_f32(n), nx_i32_to_f32(d)) }
10func tg_milli(v: i64) -> i64
26func tg_alloc(arena: *i64, ab: *i64, n: i64) -> *i64
35func tg_node(tape: *i64, nb: *i64, op: i64, ai: i64, bi: i64, rows: i64, cols: i64, valp: *i64, gradp: *i64) -> i64
49func tg_valp(tape: *i64, x: i64) -> *i64 { return tape[x*8+5] as *i64 }
50func tg_gradp(tape: *i64, x: i64) -> *i64 { return tape[x*8+6] as *i64 }
51func tg_leaf(tape: *i64, nb: *i64, arena: *i64, ab: *i64, p: *i64, rows: i64, cols: i64) -> i64
54func tg_matvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, a: i64, x: i64) -> i64
70func tg_addvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64, y: i64) -> i64
79func tg_reluvec(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64) -> i64
92func tg_mse(tape: *i64, nb: *i64, arena: *i64, ab: *i64, p: i64, t: i64) -> i64
107func tg_smul(tape: *i64, nb: *i64, arena: *i64, ab: *i64, x: i64, y: i64) -> i64
114func tg_backward(tape: *i64, nt: i64, root: i64) -> i64
190func tg_fwd_mlp(w1: *i64, b1: *i64, w2: *i64, b2: *i64, x: *i64, t: i64) -> i64
207func tg_pget(w1: *i64, b1: *i64, w2: *i64, b2: *i64, k: i64) -> i64
called by 1: gate_a
213func tg_pset(w1: *i64, b1: *i64, w2: *i64, b2: *i64, k: i64, v: i64) -> i64
called by 1: gate_a
220func gate_a(tape: *i64, nb: *i64, arena: *i64, ab: *i64) -> i64
279func tg_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, out: *i64) -> i64
349func 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
370func ad_train(tape: *i64, nb: *i64, arena: *i64, ab: *i64, out: *i64) -> i64
443func main() -> i64