code wiki / (root) / nx_fft_f32.nx

nx_fft_f32.nx

buildroot/runtime/nx_fft_f32.nx

4774 B117 linesdepth 4pulls 10 transitivereach 15 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_fft_f32.nx -- f32 radix-2 FFT + f32 FNet 2D-DFT token mixer. The bridge that lets the sub-quadratic FNet mixer (FNET-001/002, which ran in i64 Q14 fixed-point) plug into the f32 autograd tape so the block becomes TRAINABLE. Twiddles are synthesized by the sovereign CORDIC (fx_cos/fx_sin, Q16.16) then converted to f32; because f32 twiddles are unit-magnitude actual values, the butterfly needs NO per-stage descaling -- cleaner (and more accurate) than the fixed-point version. DRY: reuses nx_fft_log2 + nx_fft_bit_reverse. license_tier: ORIGINAL

dependencies 6 imports · 1 importers

nx_fft.nx fx.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx nx_syscalls.nx nx_fft_f32.nx nx_autograd_tensor.nx

imports: nx_fft.nxfx.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.nxnx_syscalls.nx

imported by: nx_autograd_tensor.nx

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

main sys_mmap nx_i32_to_f32 fftf_twiddles fftf_q16_to_f32 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 ↻ fx_cos fx_sin_cos fx_normalize_angle fx_cordic_atan fx_sin fx_sin_cos ↻ fftf_fwd nx_fft_log2 nx_fft_bit_reverse nx_f32_sub nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_neg nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_add ↻

structs

none

consts

13const FFTF_MAGIC_65536: i64 = 65536
15const FFTF_F32_ZERO: i64 = 0

functions

18func fftf_q16_to_f32(q: i64) -> i64 { return nx_f32_div(nx_i32_to_f32(q), nx_i32_to_f32(FFTF_MAGIC_65536)) }
21func fftf_twiddles(n: i64, tw_re: *i64, tw_im: *i64) -> i64
34func fftf_fwd(re: *i64, im: *i64, n: i64, tw_re: *i64, tw_im: *i64) -> i64
74func fnet_mix_f32(x_re: *i64, x_im: *i64, n: i64, d: i64) -> i64
107func main() -> i64