code wiki / _hdl_build / nx_embed_train.nx

nx_embed_train.nx

buildroot/runtime/_hdl_build/nx_embed_train.nx

15345 B280 linesdepth 4pulls 9 transitivereach 0 importersview sourcekind tooltopic embed
docsdependenciesstructsconstsfunctions

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

nx_gate_gn.nx nx_gate_base.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx nx_syscalls.nx nx_estate_path.nx nx_embed_train.nx

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

main ep_anchor sys_openat_rd sys_close sys_chdir sys_mmap gw sys_write sys_mmap ↻ sys_openat_rd ↻ sys_read sys_close ↻ gn 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_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_sub nx_f32_add ↻ nx_f32_neg f32_milli f32_trunc nx_f32_mul ↻ nx_i32_to_f32 ↻ eprobe ewid

structs

none

consts

18const K_MAGIC_2147483648: i64 = 2147483648
19const K_MAGIC_8388608: i64 = 8388608
20const K_MAGIC_5381: i64 = 5381
21const K_MAGIC_77245: i64 = 77245
22const K_MAGIC_1073741789: i64 = 1073741789
23const K_MAGIC_1073741783: i64 = 1073741783
24const K_MAGIC_134217728: i64 = 134217728
25const K_MAGIC_2654435761: i64 = 2654435761
26const K_MAGIC_40503: i64 = 40503
27const K_MAGIC_262144: i64 = 262144
28const K_MAGIC_1024: i64 = 1024
30const AG0: i64 = 0 // f32 +0.0
31const AG1: i64 = 1065353216 // f32 1.0
32const DIM: i64 = 24
33const NEG: i64 = 3 // negative samples per positive triple (SGNS lever = spread)

functions

35func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
calls 1: gw
37func f32_trunc(raw: i64) -> i64
50func f32_milli(v: i64) -> i64 { return f32_trunc(nx_f32_mul(v, nx_i32_to_f32(1000))) }
51func f32_isqrt_approx(v: i64) -> i64 { // sqrt via f32: v^0.5 through 20 newton iters on f32 (small vals)
61func ehash(buf: *u8, off: i64, len: i64) -> i64
68func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: ewid
69func ebsearch(a: *i64, n: i64, v: i64) -> i64
74func ewid(vh: *i64, nv: i64, w: *u8) -> i64 { return ebsearch(vh, nv, ehash(w, 0, slen(w))) }
77func edcos(E: *i64, a: i64, b: i64) -> i64
92func eprobe(E: *i64, vh: *i64, nv: i64, a: *u8, b: *u8) -> i64
98func main() -> i64