interplane.Get Omega
Read in your language

omega-dnn

aien-dev/omega-dnn

Brought by drakestapleton

branch main Branches Tags History

omega-dnn / docs / DESCRIPTOR.md

44 lines · 3123 bytes Raw Blame History Source

Node descriptor (layout dsc 4096)

dnn_run(ws, d) runs a node list over one arena ws (uint32 words: f32 bit patterns, and uint32 integers for position ids, block tables and sequence lengths). Every offset is an element index into ws. The descriptor is 512 little-endian u64 words:

wordmeaning
0magic 0x4f444e (OMEGA_DNN_MAGIC, also returned by dnn_abi)
1node count, at most 31
2bit 0: fuse elementwise followers
4 + 16·i + knode i, argument k (k = 0 the op, 1..14 operands, 15 flags; flag bit 1 = keep, a graph output)

Argument 3 is always the output offset. NONE = 2^64 − 1 marks an absent optional input. f64 scalars (eps, attention scale) are stored as their IEEE-754 bits.

opname (ONNX)arguments
1RMSNormalization (axis −1)1 x, 2 scale, 3 y, 4 rows, 5 cols, 6 eps
2LayerNormalization (axis −1)as 1, 7 bias or NONE
3Softmax (axis −1, max-subtracted)1 x, 3 y, 4 rows, 5 cols
4RotaryEmbedding1 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
5SiLU (Sigmoid·x)1 a, 3 y, 4 n
6Geluas 5, 6 approximate (0 none/erf, 1 tanh)
7SwiGLU silu(a)·b1 a, 2 b, 3 y, 4 n
8 / 9Add / Mul1 a, 2 b, 3 y, 4 n
10Add of a row bias b[x mod cols]1 a, 2 b, 3 y, 4 n, 5 cols
11Relu1 a, 3 y, 4 n
12MatMul (+ 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
13Attention prefill1 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)
14Paged-KV decode attention1 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
15Conv (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)
16 / 17MaxPool / 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
18GlobalAveragePool1 x, 3 y, 4 N·C, 5 H·W

Fusion. With word 2 bit 0 set, a producer at node i absorbs the following elementwise nodes i+1..e while each one reads the previous output as its a (argument 1) and that output is virtual: not marked keep, not named by any later node's argument, and not the next node's b. The fused chain is applied in f64 to each produced value and stored once, so a fused result is rounded once where the unfused list rounds after every node. dnn_run returns the number of passes.

Traps: 1 bad magic, node count or op; 2 a parameter above its bound (D > 512, block > 64, bs > 64, unknown elementwise op); 4 a loop over 1,000,000 passes (the seeded compiler's bound; elementwise nodes run in 65,536-element chunks).