code wiki / _hdl_build / nx_f32_attn_charlm_gate.nx
nx_f32_attn_charlm_gate.nx
buildroot/runtime/_hdl_build/nx_f32_attn_charlm_gate.nx
dependencies 4 imports · 0 importers
imports: nx_gate_gn.nxnx_gate_base.nxnx_autograd_tensor.nxnx_syscalls.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
| 22 | const VMAX: i64 = 40 |
| 23 | const DM: i64 = 16 // model dim |
| 24 | const HF: i64 = 32 // FFN hidden |
| 25 | const TMAX: i64 = 64 // max sequence (tape sizing) |
| 26 | const EPOCHS: i64 = 1600 |
| 27 | const NODES: i64 = 64 // tape node cap |
| 28 | const CELLS: i64 = 40000 // tape value-arena cap (cells) |
functions
| 30 | func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" calls 1: gw |
| 32 | func gm(x: i64) -> i64 { return gn(ta_f32_to_milli(x)) } |
| 33 | func f32c(num: i64, den: i64) -> i64 { return nx_f32_div(nx_i32_to_f32(num), nx_i32_to_f32(den)) } called by 1: main |
| 34 | func f32_absx(x: i64) -> i64 { return x & 0x7FFFFFFF } |
| 35 | func f32_lex(x: i64, y: i64) -> i64 { if nx_f32_gt(x,y)==1 { return 0 } return 1 } |
| 36 | func f32_sqrtx(x: i64) -> i64 { if (x & 0x7FFFFFFF)==0 { return nx_i32_to_f32(0) } var y: i64=x; var i: i64=0; while i<16 { y=nx_f32_div(nx_f32_add(y, nx_f32_div(x,y)), nx_i32_to_f32(2)); i=i+1 } return y } |
| 40 | func build_fwd(tape: *i64, vals: *i64, st: *i64, M: *i64, toks: *i64, T: i64, vv: i64, scale: i64, Xsrc: *i64) -> i64 |
| 72 | func loss_of(tape: *i64, vals: *i64, M: *i64, toks: *i64, tgt: *i64, T: i64, vv: i64, scale: i64, Xsrc: *i64) -> i64 |
| 79 | func det_fill(dst: *i64, n: i64, seed: i64) -> i64 { var i: i64=0; while i<n { let s: i64=(((i*2654435761)+seed) % 15) - 7; dst[i]=f32c(s, 90); i=i+1 } return 0 } |
| 80 | func argmax_row(vals: *i64, tape: *i64, lg: i64, row: i64, vv: i64) -> i64 { let off: i64=tape[7*lg+5]+row*vv; var bi: i64=0; var o: i64=1; while o<vv { if nx_f32_gt(vals[off+o], vals[off+bi])==1 { bi=o } o=o+1 } return bi } |
| 83 | func adam_step(P: *i64, Gd: *i64, Mo: *i64, Vo: *i64, cnt: i64, lr: i64, b1: i64, b2: i64, bc1: i64, bc2: i64, aeps: i64) -> i64 |
| 98 | func wr_f32(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(8); b[0]=(v & 0xff) as u8; b[1]=((v>>8)&0xff) as u8; b[2]=((v>>16)&0xff) as u8; b[3]=((v>>24)&0xff) as u8; sys_write(fd, b, 4); return 0 } |
| 99 | func save_buf(fd: i64, P: *i64, n: i64) -> i64 { var i: i64=0; while i<n { wr_f32(fd, P[i]); i=i+1 } return 0 } called by 1: main |
| 100 | func load_buf(buf: *u8, off: i64, P: *i64, n: i64) -> i64 { var i: i64=0; var o: i64=off; while i<n { P[i]=(buf[o]&0xff)|((buf[o+1]&0xff)<<8)|((buf[o+2]&0xff)<<16)|((buf[o+3]&0xff)<<24); o=o+4; i=i+1 } return 0 } |
| 102 | func main() -> i64 |