code wiki / _hdl_build / nx_ng_gsplat.nx
nx_ng_gsplat.nx
buildroot/runtime/_hdl_build/nx_ng_gsplat.nx
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
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
structs
| none |
consts
| 22 | const K_MAGIC_1024: i64 = 1024 |
| 23 | const K_MAGIC_16384: i64 = 16384 |
| 24 | const K_MAGIC_32768: i64 = 32768 |
| 25 | const K_MAGIC_49152: i64 = 49152 |
| 26 | const K_MAGIC_13107: i64 = 13107 |
| 27 | const K_MAGIC_45875: i64 = 45875 |
| 28 | const K_MAGIC_58982: i64 = 58982 |
| 29 | const K_MAGIC_40000: i64 = 40000 |
| 30 | const K_MAGIC_20000: i64 = 20000 |
| 31 | const K_MAGIC_4096: i64 = 4096 |
| 33 | const GLOG: *u8 = "knowledge/status/ng_gsplat.log" |
| 34 | const Q16: i64 = 65536 |
| 35 | const NP: i64 = 12 // image pixels (1D) |
| 36 | const NGA: i64 = 3 // gaussian primitives |
| 37 | const INV2S2: i64 = 2275555 // 1/(2*sigma^2) in Q16 for sigma=0.12 (footprint width) |
| 38 | const EPOCHS: i64 = 5000 |
| 39 | const LRQ: i64 = 4096 |
functions
| 41 | func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 42 | func gpn(v: i64) -> i64 |
| 50 | func g_abs(v: i64) -> i64 { if v<0 { return 0-v } return v } called by 1: main |
| 51 | func gqm(a: i64, b: i64) -> i64 { return (a * b) >> 16 } |
| 52 | func 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 } |
| 53 | func 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 } |
| 56 | func gs_build(tape: *i64, vals: *i64, st: *i64, cp: *i64, w: *i64, targ: *i64, cn: *i64) -> i64 |
| 75 | func gs_train(tape: *i64, vals: *i64, grads: *i64, st: *i64, w: *i64, targ: *i64, cout: *i64, lf: *i64, ll: *i64, sgn: i64) -> i64 |
| 93 | func main() -> i64 |