code wiki / _hdl_build / nx_embed_train.nx
nx_embed_train.nx
buildroot/runtime/_hdl_build/nx_embed_train.nx
about
nx_embed_train.nx -- Trains dense word embeddings by factorizing the PPMI matrix using sovereign f32 SGD and quantized storage.
dependencies 7 imports · 0 importers
imports: nx_gate_gn.nxnx_gate_base.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.nxnx_syscalls.nxnx_estate_path.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
| 18 | const K_MAGIC_2147483648: i64 = 2147483648 |
| 19 | const K_MAGIC_8388608: i64 = 8388608 |
| 20 | const K_MAGIC_5381: i64 = 5381 |
| 21 | const K_MAGIC_77245: i64 = 77245 |
| 22 | const K_MAGIC_1073741789: i64 = 1073741789 |
| 23 | const K_MAGIC_1073741783: i64 = 1073741783 |
| 24 | const K_MAGIC_134217728: i64 = 134217728 |
| 25 | const K_MAGIC_2654435761: i64 = 2654435761 |
| 26 | const K_MAGIC_40503: i64 = 40503 |
| 27 | const K_MAGIC_262144: i64 = 262144 |
| 28 | const K_MAGIC_1024: i64 = 1024 |
| 30 | const AG0: i64 = 0 // f32 +0.0 |
| 31 | const AG1: i64 = 1065353216 // f32 1.0 |
| 32 | const DIM: i64 = 24 |
| 33 | const NEG: i64 = 3 // negative samples per positive triple (SGNS lever = spread) |
functions
| 35 | 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 |
| 37 | func f32_trunc(raw: i64) -> i64 |
| 50 | func f32_milli(v: i64) -> i64 { return f32_trunc(nx_f32_mul(v, nx_i32_to_f32(1000))) } |
| 51 | func f32_isqrt_approx(v: i64) -> i64 { // sqrt via f32: v^0.5 through 20 newton iters on f32 (small vals) |
| 61 | func ehash(buf: *u8, off: i64, len: i64) -> i64 |
| 68 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: ewid |
| 69 | func ebsearch(a: *i64, n: i64, v: i64) -> i64 |
| 74 | func ewid(vh: *i64, nv: i64, w: *u8) -> i64 { return ebsearch(vh, nv, ehash(w, 0, slen(w))) } |
| 77 | func edcos(E: *i64, a: i64, b: i64) -> i64 |
| 92 | func eprobe(E: *i64, vh: *i64, nv: i64, a: *u8, b: *u8) -> i64 |
| 98 | func main() -> i64 |