code wiki / _hdl_build / nx_ng_gsplat.nx

nx_ng_gsplat.nx

buildroot/runtime/_hdl_build/nx_ng_gsplat.nx

9802 B179 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ng
docsdependenciesstructsconstsfunctions

about

nx_ng_gsplat.nx -- CAP-GAUSSIAN-SPLAT, generation 10: 3D Gaussian Splatting (Kerbl et al. 2023, arxiv 2308.04079, Inria/EU). The other pillar of the radiance-field frontier: instead of an MLP queried along rays (NeRF), the scene is EXPLICIT Gaussian primitives that are SPLATTED (each projects to a footprint) and ALPHA-OVER composited front-to-back -- real-time, and differentiable so the primitives can be optimized. This rung REUSES the alpha-over compositor proven in CAP-VOLUME-RENDER (T_g = prod(1-a_h); C = sum T_g*a_g*c_g) and adds the 3DGS-specific pieces: the explicit Gaussian PRIMITIVE + its SPLAT FOOTPRINT (a Gaussian falloff exp(-(x-mu)^2/2sigma^2) via the autograd module's fixed-point nfa_fxexp). 1D image, Q16, no float. Honest gated proof (HARD evidence): N Gaussians (centers mu_g, width sigma) splat onto a P-pixel image; their per-pixel opacities a_g(p)=footprint are alpha-composited (the reused compositor) -> a rendered image. Gate: T1 FORWARD SPLAT -- each Gaussian's footprint PEAKS at its center and falls off (a real splat), T2 DIFFERENTIABLE FIT -- GD on the Gaussian COLORS reconstructs a target render (loss->~0, colors recovered): the explicit-primitive scene is differentiably optimizable (the 3DGS training loop), T3 NEG-CONTROL -- ascending that gradient diverges (the gradient has teeth), T4 BIT-EXACT -- train twice -> identical integer colors. HONEST: 1D, fixed mu/sigma/opacity (only colors optimized); full 3DGS = 3D gaussians with optimized position/covariance/opacity + tile sort + adaptive densification = the follow-on. Sovereign: nx_nofloat_autograd (tape + nfa_fxexp) + syscalls, no float. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_ng_gsplat.nx

imports: nx_nofloat_autograd.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gp sys_write sys_mmap gqm nfa_fxexp gpn sys_mmap ↻ sys_write ↻ gs_train sys_mmap ↻ gs_build nfa_leaf nfa_new nfa_cmul nfa_new ↻ nfa_qmul nfa_vadd nfa_new ↻ nfa_mse nfa_new ↻ nfa_backward nfa_qmul ↻ nfa_silud nfa_sigmoid nfa_fxexp ↻ nfa_qmul ↻ nfa_isqrt nfa_fxexp ↻ nfa_cosf nfa_reduce2pi nfa_cosq nfa_qmul ↻ nfa_sinf nfa_reduce2pi ↻ nfa_sinq nfa_qmul ↻ nfa_val nfa_grad nfa_sgd

structs

none

consts

22const K_MAGIC_1024: i64 = 1024
23const K_MAGIC_16384: i64 = 16384
24const K_MAGIC_32768: i64 = 32768
25const K_MAGIC_49152: i64 = 49152
26const K_MAGIC_13107: i64 = 13107
27const K_MAGIC_45875: i64 = 45875
28const K_MAGIC_58982: i64 = 58982
29const K_MAGIC_40000: i64 = 40000
30const K_MAGIC_20000: i64 = 20000
31const K_MAGIC_4096: i64 = 4096
33const GLOG: *u8 = "knowledge/status/ng_gsplat.log"
34const Q16: i64 = 65536
35const NP: i64 = 12 // image pixels (1D)
36const NGA: i64 = 3 // gaussian primitives
37const INV2S2: i64 = 2275555 // 1/(2*sigma^2) in Q16 for sigma=0.12 (footprint width)
38const EPOCHS: i64 = 5000
39const LRQ: i64 = 4096

functions

41func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
42func gpn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
50func g_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
51func gqm(a: i64, b: i64) -> i64 { return (a * b) >> 16 }
called by 2: gs_trainmain
52func gl_ws(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
53func gl_wn(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0 {sys_write(fd,"-" as *u8,1); m=0-m} 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)) as u8; m=m/10; k=k+1} var i: i64=0; while i<k {b[i]=t[k-1-i]; i=i+1} sys_write(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
56func gs_build(tape: *i64, vals: *i64, st: *i64, cp: *i64, w: *i64, targ: *i64, cn: *i64) -> i64
75func gs_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, w: *i64, targ: *i64, cout: *i64, lf: *i64, ll: *i64, sgn: i64) -> i64
93func main() -> i64