omega-dnn
aien-dev/omega-dnn
Brought by drakestapleton
omega-dnn / docs / DESCRIPTOR.md
| 1 | # Node descriptor (`layout dsc 4096`) |
| 2 | |
| 3 | `dnn_run(ws, d)` runs a node list over one arena `ws` (uint32 words: f32 bit patterns, and uint32 |
| 4 | integers for position ids, block tables and sequence lengths). Every offset is an element index |
| 5 | into `ws`. The descriptor is 512 little-endian u64 words: |
| 6 | |
| 7 | | word | meaning | |
| 8 | |---|---| |
| 9 | | 0 | magic `0x4f444e` (`OMEGA_DNN_MAGIC`, also returned by `dnn_abi`) | |
| 10 | | 1 | node count, at most 31 | |
| 11 | | 2 | bit 0: fuse elementwise followers | |
| 12 | | 4 + 16·i + k | node i, argument k (k = 0 the op, 1..14 operands, 15 flags; flag bit 1 = keep, a graph output) | |
| 13 | |
| 14 | Argument 3 is always the output offset. `NONE` = 2^64 − 1 marks an absent optional input. f64 |
| 15 | scalars (eps, attention scale) are stored as their IEEE-754 bits. |
| 16 | |
| 17 | | op | name (ONNX) | arguments | |
| 18 | |---|---|---| |
| 19 | | 1 | RMSNormalization (axis −1) | 1 x, 2 scale, 3 y, 4 rows, 5 cols, 6 eps | |
| 20 | | 2 | LayerNormalization (axis −1) | as 1, 7 bias or NONE | |
| 21 | | 3 | Softmax (axis −1, max-subtracted) | 1 x, 3 y, 4 rows, 5 cols | |
| 22 | | 4 | RotaryEmbedding | 1 x [B,H,S,D], 2 cos [maxpos, rot/2], 3 y, 4 sin, 5 position ids [B,S] (uint32), 6 B, 7 H, 8 S, 9 D, 10 rotary dim (0 = D), 11 interleaved | |
| 23 | | 5 | SiLU (Sigmoid·x) | 1 a, 3 y, 4 n | |
| 24 | | 6 | Gelu | as 5, 6 approximate (0 none/erf, 1 tanh) | |
| 25 | | 7 | SwiGLU silu(a)·b | 1 a, 2 b, 3 y, 4 n | |
| 26 | | 8 / 9 | Add / Mul | 1 a, 2 b, 3 y, 4 n | |
| 27 | | 10 | Add of a row bias b[x mod cols] | 1 a, 2 b, 3 y, 4 n, 5 cols | |
| 28 | | 11 | Relu | 1 a, 3 y, 4 n | |
| 29 | | 12 | MatMul (+ bias) | 1 A [M,K], 2 B [K,N] (or [N,K] with 8 = 1), 3 C [M,N], 4 M, 5 N, 6 K, 7 bias [N] or NONE | |
| 30 | | 13 | Attention prefill | 1 q [B,Hq,Sq,D], 2 k [B,Hkv,Skv,D], 3 o, 4 v, 5 B, 6 Hq, 7 Hkv, 8 Sq, 9 Skv, 10 D ≤ 512, 11 causal (top-left), 12 scale bits, 13 key block 1..64 (0 = 64) | |
| 31 | | 14 | Paged-KV decode attention | 1 q [B,Hq,D], 2 k cache [nblk, bs, Hkv, D], 3 o, 4 v cache, 5 block table [B,maxb], 6 lengths [B], 7 B, 8 Hq, 9 Hkv, 10 D ≤ 512, 11 bs ≤ 64, 12 maxb, 13 scale bits | |
| 32 | | 15 | Conv (2-D, NCHW) | 1 x, 2 w [O,C/g,kh,kw], 3 y, 4 bias or NONE, 5 scratch (im2col: C/g·kh·kw·OH·OW), 6 N, 7 C, 8 H, 9 W, 10 O, 11 packed kh kw sh sw ph pw dh dw (one byte each, low first, symmetric pads), 12 groups, 13 algorithm (0 direct, 1 im2col + GEMM) | |
| 33 | | 16 / 17 | MaxPool / AveragePool (2-D) | 1 x, 3 y, 4 N·C, 5 H, 6 W, 7 packed kh kw sh sw ph pw, 8 count_include_pad | |
| 34 | | 18 | GlobalAveragePool | 1 x, 3 y, 4 N·C, 5 H·W | |
| 35 | |
| 36 | **Fusion.** With word 2 bit 0 set, a producer at node i absorbs the following elementwise nodes |
| 37 | i+1..e while each one reads the previous output as its `a` (argument 1) and that output is |
| 38 | virtual: not marked keep, not named by any later node's argument, and not the next node's `b`. |
| 39 | The fused chain is applied in f64 to each produced value and stored once, so a fused result is |
| 40 | rounded once where the unfused list rounds after every node. `dnn_run` returns the number of passes. |
| 41 | |
| 42 | Traps: 1 bad magic, node count or op; 2 a parameter above its bound (D > 512, block > 64, bs > 64, |
| 43 | unknown elementwise op); 4 a loop over 1,000,000 passes (the seeded compiler's bound; elementwise |
| 44 | nodes run in 65,536-element chunks). |