VanishD shuaiwei huang allen wu weihua du commited on
Commit
bbe836b
·
0 Parent(s):

KernelShift dataset

Browse files

144 kernel definitions with workloads, reference-scalar starting points and expert baselines from ncnn, llama.cpp, Arm SIMD Loops and KleidiAI, plus end-to-end GEMMs of Qwen3.5-4B and Llama-3.1-8B-Instruct.

Co-authored-by: Shuaiwei Huang <112870732+ArtificialRay@users.noreply.github.com>
Co-authored-by: Allen Wu <110312634+wuallenwu@users.noreply.github.com>
Co-authored-by: Weihua Du <73473861+StigLidu@users.noreply.github.com>


Co-authored-by: shuaiwei huang <shuaiwei huang@users.noreply.huggingface.co>
Co-authored-by: allen wu <allen wu@users.noreply.huggingface.co>
Co-authored-by: weihua du <weihua du@users.noreply.huggingface.co>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +60 -0
  2. README.md +129 -0
  3. TASKS.md +229 -0
  4. definitions/conv2d/conv2d_f16_nhwc_kh3_kw3_valid_c32_c64.json +33 -0
  5. definitions/conv2d/conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0.json +111 -0
  6. definitions/conv2d/conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0.json +111 -0
  7. definitions/conv2d/conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +111 -0
  8. definitions/conv2d/conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +111 -0
  9. definitions/conv2d/conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3.json +111 -0
  10. definitions/conv2d/conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64.json +29 -0
  11. definitions/conv2d/conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2.json +77 -0
  12. definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json +121 -0
  13. definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json +121 -0
  14. definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +121 -0
  15. definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +121 -0
  16. definitions/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json +121 -0
  17. definitions/conv2d_depthwise/conv2d_depthwise_f16_nhwc_kh3_kw3_s1_p1.json +36 -0
  18. definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +112 -0
  19. definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +112 -0
  20. definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +112 -0
  21. definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2.json +112 -0
  22. definitions/conv2d_depthwise/conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1.json +36 -0
  23. definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +124 -0
  24. definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +124 -0
  25. definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +124 -0
  26. definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json +124 -0
  27. definitions/gemm/gemm_bf16_n1024_k2048.json +50 -0
  28. definitions/gemm/gemm_bf16_n1408_k2048.json +50 -0
  29. definitions/gemm/gemm_bf16_n2048_k1024.json +50 -0
  30. definitions/gemm/gemm_bf16_n2048_k1408.json +50 -0
  31. definitions/gemm/gemm_bf16_n2048_k2048.json +50 -0
  32. definitions/gemm/gemm_bf16_n512_k512.json +55 -0
  33. definitions/gemm/gemm_f16_n512_k512.json +24 -0
  34. definitions/gemm/gemm_f16_qai4c32_sme2_n256_k512.json +77 -0
  35. definitions/gemm/gemm_f16_qs4cx_sme2_n256_k512.json +65 -0
  36. definitions/gemm/gemm_f16_qs8cx_sme2_n256_k512.json +61 -0
  37. definitions/gemm/gemm_f16act_qs4c32_sme2_n256_k512.json +64 -0
  38. definitions/gemm/gemm_f32_bf16_n512_k512.json +54 -0
  39. definitions/gemm/gemm_fp32_n512_k512.json +49 -0
  40. definitions/gemm/gemm_fp32_sme2_n512_k512.json +24 -0
  41. definitions/gemm/gemm_ggml_q4_K_n1024_k2560.json +61 -0
  42. definitions/gemm/gemm_ggml_q4_K_n1024_k4096.json +61 -0
  43. definitions/gemm/gemm_ggml_q4_K_n14336_k4096.json +61 -0
  44. definitions/gemm/gemm_ggml_q4_K_n2560_k4096.json +61 -0
  45. definitions/gemm/gemm_ggml_q4_K_n2560_k9216.json +61 -0
  46. definitions/gemm/gemm_ggml_q4_K_n4096_k14336.json +61 -0
  47. definitions/gemm/gemm_ggml_q4_K_n4096_k2560.json +61 -0
  48. definitions/gemm/gemm_ggml_q4_K_n4096_k4096.json +61 -0
  49. definitions/gemm/gemm_ggml_q4_K_n8192_k2560.json +61 -0
  50. definitions/gemm/gemm_ggml_q4_K_n9216_k2560.json +61 -0
.gitattributes ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp filter=lfs diff=lfs merge=lfs -text
58
+ # Video files - compressed
59
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
60
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - code
7
+ - kernels
8
+ - benchmark
9
+ - arm
10
+ - aarch64
11
+ - sve
12
+ - sve2
13
+ - sme2
14
+ - ncnn
15
+ - llama.cpp
16
+ - kleidiai
17
+ - simd-loops
18
+ pretty_name: KernelShift
19
+ size_categories:
20
+ - n<1K
21
+ ---
22
+
23
+ # KernelShift
24
+
25
+ Benchmark data for optimizing **Arm (AArch64) CPU kernels** across three
26
+ generations of vector and matrix extensions: SVE (AWS Graviton3, 256-bit),
27
+ SVE2 (AWS Graviton4, 128-bit) and SME2 (Apple M4). Each kernel *definition*
28
+ comes with *workloads*, a scalar *reference* that serves as the correctness
29
+ check and the agent's starting point, and an *expert baseline*: a candidate
30
+ kernel is checked against the reference and timed against the baseline.
31
+
32
+ Code, the agent environments and the evaluation scripts:
33
+ <https://github.com/cmu-l3/kernel-shift>.
34
+
35
+ ## Contents
36
+
37
+ 144 kernel definitions from four open-source projects, plus the matrix
38
+ multiplications of two LLMs; 99 of them form the evaluation set.
39
+
40
+ | Source | Definitions | Evaluation set | Op types | Expert baseline |
41
+ |------------|------------:|----------------:|-------------------------------------------------------------------|--------------------------------------|
42
+ | ncnn | 23 | 23 | conv2d, conv2d_depthwise, pooling | `baseline-ncnn` |
43
+ | llama.cpp | 26 | 26 | gemm, moe, mha, gqa, mla_decode, mla_prefill, rms_norm | `baseline-llamacpp` |
44
+ | SIMD Loops | 47 | 24 | one loop per definition | `baseline-simd-loop-{sve,sve2,sme2}` |
45
+ | KleidiAI | 30 | 6 SVE + 20 SME2 | gemm, conv2d, conv2d_depthwise, softmax | `baseline-kleidiai` |
46
+ | e2e | 18 | – | gemm on q4_K / q5_K / q6_K weights of Qwen3.5-4B and Llama-3.1-8B | `baseline-llamacpp` |
47
+ | **Total** | **144** | **99** | | |
48
+
49
+ - `expected_sets.json` lists the evaluation set: 79 kernels evaluated on
50
+ Graviton3 (`ncnn`, `llama.cpp`, `simd-loop`, and `kleidiai` for the six
51
+ KleidiAI kernels with an SVE expert) and, under `kleidiai-sme2`, the 20
52
+ KleidiAI kernels with an SME2 expert, evaluated on Apple M4. The other 23 SIMD
53
+ Loops definitions are not in it (see `TASKS.md`); for example, `loop_120`
54
+ and `loop_124` sort their input in place, so their timings are not valid.
55
+ - `subset_sve.json` and `subset_sme2.json`: a 32-kernel subset for the SVE and
56
+ SME2 tiers; they differ only in the KleidiAI GEMM.
57
+ - The 18 e2e definitions are the quantized matrix multiplications of
58
+ Qwen3.5-4B (11) and Llama-3.1-8B-Instruct (7) in llama.cpp, for the
59
+ end-to-end inference experiments. They carry an `e2e:<model>` tag.
60
+ - [`TASKS.md`](TASKS.md) lists every definition with its expert baseline on
61
+ each tier: whether it runs there and whether it is specialized for that
62
+ tier.
63
+
64
+ ## Layout
65
+
66
+ ```
67
+ definitions/<op_type>/<name>.json kernel spec: axes, inputs/outputs, PyTorch reference
68
+ workloads/<op_type>/<name>.jsonl one workload per line: axis values and how to build each input
69
+ solutions/<source>/<author>/... kernels, with their sources inlined in the JSON
70
+ tensors/gemm/<name>/*.npy recorded activations used by the e2e workloads
71
+ results/e2e-qwen3.5-4b.json end-to-end results for Qwen3.5-4B
72
+ ```
73
+
74
+ Solution authors:
75
+
76
+ - `reference-scalar`: scalar code, the correctness reference and the
77
+ starting point.
78
+ - `baseline-<source>`: the expert baselines. SIMD Loops has a separate one per
79
+ tier, `baseline-simd-loop-<isa>`.
80
+ - `autovec` (SIMD Loops): the loop compiled with the compiler's
81
+ auto-vectorizer.
82
+ - `claude-code-claude-fable-5-1` (llama.cpp): the agent-written kernels for
83
+ the 18 e2e definitions (next section); they are not baselines.
84
+
85
+ Definitions tagged `correctness:sqnr` (quantized and BF16 kernels) are
86
+ checked by signal-to-quantization-noise ratio instead of element-wise
87
+ tolerances.
88
+
89
+ ## End-to-end results
90
+
91
+ For the end-to-end inference experiments, Claude Code with Claude Fable 5.1
92
+ wrote a kernel for each of the 18 e2e definitions (11 for Qwen3.5-4B, 7 for
93
+ Llama-3.1-8B-Instruct), in `solutions/llama.cpp/claude-code-claude-fable-5-1/`.
94
+ The kernels are substituted into llama.cpp and compared with stock llama.cpp,
95
+ which uses its repacked i8mm kernels, on AWS Graviton4.
96
+
97
+ `results/e2e-qwen3.5-4b.json` holds the Qwen3.5-4B results reported in the
98
+ paper: prefill and decode speedups at 1, 4 and 16 threads, the prompt-length
99
+ and micro-batch sweeps, perplexity on wikitext-2, and the speedup of the
100
+ kernels alone over the repacked kernels.
101
+
102
+ ## Usage
103
+
104
+ ```bash
105
+ git clone https://github.com/cmu-l3/kernel-shift
106
+ cd kernel-shift
107
+ pip install -r requirements.txt
108
+ hf download l3lab/KernelShift --repo-type dataset --local-dir bench-trace
109
+
110
+ python -m bench.cli bench --dataset simd-loop --isa sve \
111
+ --definition loop_001 --solution reference-scalar_loop_001
112
+ ```
113
+
114
+ ## Authors
115
+
116
+ Shuaiwei Huang\*, Weihua Du\*, Allen Wu\* (Carnegie Mellon University),
117
+ Ivan Fox, Manupa Karunaratne (Arm Ltd.),
118
+ Yiming Yang, Sean Welleck (Carnegie Mellon University).
119
+
120
+ \* Equal contribution.
121
+
122
+ ## License
123
+
124
+ Released under the Apache-2.0 license. The baselines derive from or wrap
125
+ [ncnn](https://github.com/Tencent/ncnn) (BSD-3-Clause),
126
+ [llama.cpp / ggml](https://github.com/ggml-org/llama.cpp) (MIT),
127
+ [KleidiAI](https://gitlab.arm.com/kleidi/kleidiai) (Apache-2.0) and
128
+ [SIMD Loops](https://gitlab.arm.com/architecture/simd-loops) (BSD-3-Clause);
129
+ see each project for its license terms.
TASKS.md ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tasks and baselines
2
+
3
+ Every definition in this dataset, with the expert baseline it is scored against on each hardware tier: whether it runs there, and whether it is specialized for that tier. The marks come from the dataset, the recorded runs and a check of each baseline's code. `loop_120` and `loop_124` are not in the Eval set (see the notes on ✗). 7 KleidiAI definitions have an SVE expert, among them `gemm_qai8dxp_qs4c32_n256_k512` (the Graviton3 twin of `gemm_qai8dxp_qs4c32_sme2_n256_k512`) and `softmax_fp32`.
4
+
5
+ | Mark | Meaning |
6
+ |---|---|
7
+ | ★ | Runs on that machine, and its code is specialized for the tier: it uses SVE on Graviton3, SVE2-only instructions on Graviton4, SME (ZA) on M4 |
8
+ | ✓ | Runs on that machine as optimized code (hand-written or vendor), but not specialized for the tier, e.g. NEON code, or SVE code on Graviton4 or in streaming mode on M4 (streaming SVE counts as ✓, not ★). It does not fall back to compiler-vectorized scalar code |
9
+ | ? | A baseline exists for this tier but has not been confirmed on the machine yet |
10
+ | ✗ | Tried and fails on the machine (see the notes at the end) |
11
+ | — | No baseline for this tier |
12
+
13
+ Tiers: **SVE** = Graviton3 (c7g), **SVE2** = Graviton4 (c8g), **SME2** = Apple M4 (mac-m4.metal). "Runs" means a recorded run on that machine computed speedups against the baseline; for SIMD Loops on M4, the baseline was also run on every workload.
14
+
15
+ How each source's baseline is chosen and marked is explained under *Notes on the baselines* at the end.
16
+
17
+ **Eval set** = the 99 evaluated kernels listed in `expected_sets.json`: 79 on Graviton3 (23 ncnn, 26 llama.cpp, 24 SIMD Loops, 6 KleidiAI with an SVE expert; `softmax_fp32` is not in it) and, under `kleidiai-sme2`, the 20 KleidiAI kernels with an SME2 expert, evaluated on M4. **Subset** = the 32-kernel subset; `subset_sve.json` and `subset_sme2.json` differ only in the KleidiAI GEMM (`gemm_fp32_n512_k512` vs `gemm_fp32_sme2_n512_k512`), so 33 rows carry the mark.
18
+
19
+ ## Summary
20
+
21
+ | Source | Definitions | SVE ★ / ✓ / ? / ✗ / — | SVE2 ★ / ✓ / ? / ✗ / — | SME2 ★ / ✓ / ? / ✗ / — |
22
+ |---|---|---|---|---|
23
+ | ncnn | 23 | 0 / 23 / 0 / 0 / 0 | 0 / 23 / 0 / 0 / 0 | 0 / 23 / 0 / 0 / 0 |
24
+ | llama.cpp | 26 | 0 / 26 / 0 / 0 / 0 | 0 / 26 / 0 / 0 / 0 | 0 / 26 / 0 / 0 / 0 |
25
+ | SIMD Loops | 47 | 25 / 0 / 0 / 5 / 17 | 10 / 17 / 0 / 9 / 11 | 7 / 16 / 0 / 8 / 16 |
26
+ | KleidiAI | 30 | 7 / 3 / 0 / 0 / 20 | 0 / 7 / 1 / 0 / 22 | 20 / 0 / 0 / 0 / 10 |
27
+ | e2e (llama.cpp GEMMs) | 18 | 0 / 18 / 0 / 0 / 0 | 0 / 18 / 0 / 0 / 0 | 0 / 18 / 0 / 0 / 0 |
28
+ | **All** | **144** | 32 / 70 / 0 / 5 / 37 | 10 / 91 / 1 / 9 / 33 | 27 / 83 / 0 / 8 / 26 |
29
+
30
+ ## ncnn (23)
31
+
32
+ | Definition | Op | Workloads | Eval set | Subset | SVE | SVE2 | SME2 |
33
+ |---|---|---|---|---|---|---|---|
34
+ | `conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1` | conv2d_depthwise | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
35
+ | `conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1` | conv2d_depthwise | 20 | ✓ | | ✓ | ✓ | ✓ |
36
+ | `conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2` | conv2d_depthwise | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
37
+ | `conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2` | conv2d_depthwise | 20 | ✓ | | ✓ | ✓ | ✓ |
38
+ | `conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1` | conv2d_depthwise | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
39
+ | `conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1` | conv2d_depthwise | 20 | ✓ | | ✓ | ✓ | ✓ |
40
+ | `conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2` | conv2d_depthwise | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
41
+ | `conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2` | conv2d_depthwise | 20 | ✓ | | ✓ | ✓ | ✓ |
42
+ | `conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
43
+ | `conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
44
+ | `conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1` | conv2d | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
45
+ | `conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
46
+ | `conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3` | conv2d | 11 | ✓ | ✓ | ✓ | ✓ | ✓ |
47
+ | `conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
48
+ | `conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
49
+ | `conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1` | conv2d | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
50
+ | `conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1` | conv2d | 20 | ✓ | | ✓ | ✓ | ✓ |
51
+ | `conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3` | conv2d | 11 | ✓ | ✓ | ✓ | ✓ | ✓ |
52
+ | `pooling_fp32_global_avg` | pooling | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
53
+ | `pooling_fp32_max_kh2_kw2_sh2_sw2_p0` | pooling | 6 | ✓ | | ✓ | ✓ | ✓ |
54
+ | `pooling_fp32_max_kh3_kw3_sh1_sw1_p1` | pooling | 6 | ✓ | | ✓ | ✓ | ✓ |
55
+ | `pooling_fp32_max_kh3_kw3_sh2_sw2_p0` | pooling | 6 | ✓ | | ✓ | ✓ | ✓ |
56
+ | `pooling_fp32_max_kh3_kw3_sh2_sw2_p1` | pooling | 11 | ✓ | ✓ | ✓ | ✓ | ✓ |
57
+
58
+ ## llama.cpp (26)
59
+
60
+ | Definition | Op | Workloads | Eval set | Subset | SVE | SVE2 | SME2 |
61
+ |---|---|---|---|---|---|---|---|
62
+ | `gemm_bf16_n1024_k2048` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
63
+ | `gemm_bf16_n1408_k2048` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
64
+ | `gemm_bf16_n2048_k1024` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
65
+ | `gemm_bf16_n2048_k1408` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
66
+ | `gemm_bf16_n2048_k2048` | gemm | 24 | ✓ | ✓ | ✓ | ✓ | ✓ |
67
+ | `gemm_q4_k_m_n1024_k2048` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
68
+ | `gemm_q4_k_m_n1408_k2048` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
69
+ | `gemm_q4_k_m_n2048_k1024` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
70
+ | `gemm_q4_k_m_n2048_k1536` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
71
+ | `gemm_q4_k_m_n2048_k2048` | gemm | 24 | ✓ | ✓ | ✓ | ✓ | ✓ |
72
+ | `gemm_q8_0_n1024_k2048` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
73
+ | `gemm_q8_0_n1408_k2048` | gemm | 24 | ✓ | ✓ | ✓ | ✓ | ✓ |
74
+ | `gemm_q8_0_n2048_k1024` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
75
+ | `gemm_q8_0_n2048_k1408` | gemm | 24 | ✓ | | ✓ | ✓ | ✓ |
76
+ | `gemm_q8_0_n2048_k2048` | gemm | 24 | ✓ | ✓ | ✓ | ✓ | ✓ |
77
+ | `gqa_bf16_h32_d128_kvh8` | gqa | 20 | ✓ | | ✓ | ✓ | ✓ |
78
+ | `mha_bf16_h16_d128_kvh16` | mha | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
79
+ | `mla_decode_bf16_h16_lora512_rope64_v128` | mla_decode | 20 | ✓ | | ✓ | ✓ | ✓ |
80
+ | `mla_prefill_bf16_h16_qk192_vo128` | mla_prefill | 20 | ✓ | | ✓ | ✓ | ✓ |
81
+ | `moe_bf16_e60_k4_d2048_ff1408` | moe | 20 | ✓ | | ✓ | ✓ | ✓ |
82
+ | `moe_bf16_e64_k8_d2048_ff1024` | moe | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
83
+ | `moe_q4_k_m_e60_k4_d2048_ff1536` | moe | 20 | ✓ | | ✓ | ✓ | ✓ |
84
+ | `moe_q4_k_m_e64_k8_d2048_ff1024` | moe | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
85
+ | `moe_q8_0_e60_k4_d2048_ff1408` | moe | 20 | ✓ | | ✓ | ✓ | ✓ |
86
+ | `moe_q8_0_e64_k8_d2048_ff1024` | moe | 20 | ✓ | ✓ | ✓ | ✓ | ✓ |
87
+ | `rms_norm_fp32_d2048` | rms_norm | 24 | ✓ | ✓ | ✓ | ✓ | ✓ |
88
+
89
+ ## SIMD Loops (47)
90
+
91
+ Loops without the Eval set mark are in the dataset but not in the main results. `loop_005`, `006`, `034`, `128` and the matrix loops `216`–`223` (except `219`) have no expert baseline yet.
92
+
93
+ | Definition | Op | Workloads | Eval set | Subset | SVE | SVE2 | SME2 |
94
+ |---|---|---|---|---|---|---|---|
95
+ | `loop_001` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
96
+ | `loop_002` | | 10 | ✓ | ✓ | ★ | ✓ | ✗ |
97
+ | `loop_003` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
98
+ | `loop_004` | | 10 | ✓ | | ★ | ✓ | ✓ |
99
+ | `loop_008` | | 10 | ✓ | | ★ | ✓ | — |
100
+ | `loop_024` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
101
+ | `loop_027` | | 10 | ✓ | ✓ | ★ | ✓ | ✗ |
102
+ | `loop_028` | | 10 | ✓ | | ★ | ✓ | ✗ |
103
+ | `loop_029` | | 10 | ✓ | | ★ | ✓ | ✓ |
104
+ | `loop_033` | | 10 | ✓ | | ★ | ✓ | ✓ |
105
+ | `loop_035` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
106
+ | `loop_037` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
107
+ | `loop_038` | | 10 | ✓ | | ★ | ✓ | ✗ |
108
+ | `loop_103` | | 10 | ✓ | | ★ | ★ | — |
109
+ | `loop_105` | | 10 | ✓ | ✓ | ★ | ★ | ✓ |
110
+ | `loop_108` | | 10 | ✓ | ✓ | ★ | ★ | ✓ |
111
+ | `loop_109` | | 10 | ✓ | | ★ | ★ | ✓ |
112
+ | `loop_110` | | 10 | ✓ | | ★ | ★ | ✓ |
113
+ | `loop_112` | | 10 | ✓ | | ★ | ★ | ✓ |
114
+ | `loop_113` | | 10 | ✓ | ✓ | ★ | ★ | ✓ |
115
+ | `loop_114` | | 10 | ✓ | | ★ | ★ | ✗ |
116
+ | `loop_120` | | 10 | | | ✗ | ✗ | — |
117
+ | `loop_124` | | 10 | | | ✗ | ✗ | — |
118
+ | `loop_126` | | 10 | ✓ | ✓ | ★ | ✓ | ✓ |
119
+ | `loop_127` | | 10 | ✓ | ✓ | ★ | ✓ | ✗ |
120
+ | `loop_219` | | 10 | ✓ | | ★ | ✓ | ★ |
121
+ | `loop_005` | | 10 | | | — | — | — |
122
+ | `loop_006` | | 10 | | | — | — | — |
123
+ | `loop_010` | | 10 | | | ★ | ✓ | ✗ |
124
+ | `loop_032` | | 10 | | | ✗ | ✗ | — |
125
+ | `loop_034` | | 10 | | | — | — | — |
126
+ | `loop_101` | | 10 | | | — | ★ | ✓ |
127
+ | `loop_102` | | 10 | | | — | ★ | — |
128
+ | `loop_104` | | 10 | | | — | ✗ | — |
129
+ | `loop_106` | | 10 | | | — | ✗ | — |
130
+ | `loop_121` | | 10 | | | ✗ | ✗ | — |
131
+ | `loop_122` | | 10 | | | ✗ | — | — |
132
+ | `loop_123` | | 10 | | | — | ✗ | — |
133
+ | `loop_128` | | 10 | | | — | — | ✗ |
134
+ | `loop_130` | | 10 | | | — | ✗ | — |
135
+ | `loop_135` | | 10 | | | — | ✗ | — |
136
+ | `loop_216` | | 10 | | | — | — | ★ |
137
+ | `loop_217` | | 10 | | | — | — | ★ |
138
+ | `loop_218` | | 10 | | | — | — | ★ |
139
+ | `loop_220` | | 10 | | | — | — | ★ |
140
+ | `loop_221` | | 10 | | | — | — | ★ |
141
+ | `loop_223` | | 10 | | | — | — | ★ |
142
+
143
+ ## KleidiAI (30)
144
+
145
+ | Definition | Op | Workloads | Eval set | Subset | SVE | SVE2 | SME2 |
146
+ |---|---|---|---|---|---|---|---|
147
+ | `conv2d_depthwise_f16_nhwc_kh3_kw3_s1_p1` | conv2d_depthwise | 20 | ✓ | | — | — | ★ |
148
+ | `conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1` | conv2d_depthwise | 20 | ✓ | | — | — | ★ |
149
+ | `conv2d_f16_nhwc_kh3_kw3_valid_c32_c64` | conv2d | 20 | ✓ | | — | — | ★ |
150
+ | `conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64` | conv2d | 16 | ✓ | | ★ | ✓ | — |
151
+ | `conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2` | conv2d | 16 | ✓ | | — | — | ★ |
152
+ | `gemm_bf16_n512_k512` | gemm | 15 | ✓ | | — | — | ★ |
153
+ | `gemm_f16_n512_k512` | gemm | 13 | ✓ | | — | — | ★ |
154
+ | `gemm_f16_qai4c32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
155
+ | `gemm_f16_qs4cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
156
+ | `gemm_f16_qs8cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
157
+ | `gemm_f16act_qs4c32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
158
+ | `gemm_f32_bf16_n512_k512` | gemm | 13 | | | ✓ | ✓ | — |
159
+ | `gemm_fp32_n512_k512` | gemm | 13 | ✓ | ✓ | ★ | ✓ | — |
160
+ | `gemm_fp32_sme2_n512_k512` | gemm | 13 | ✓ | ✓ | — | — | ★ |
161
+ | `gemm_i32_u8_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
162
+ | `gemm_qai4c32_n256_k512` | gemm | 13 | | | ✓ | ✓ | — |
163
+ | `gemm_qai4c32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
164
+ | `gemm_qai8_qsi8cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
165
+ | `gemm_qai8dxp_qs4c32_n256_k512` | gemm | 13 | ✓ | | ★ | — | — |
166
+ | `gemm_qai8dxp_qs4c32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
167
+ | `gemm_qs4c32_n256_k512` | gemm | 13 | ✓ | | ★ | — | — |
168
+ | `gemm_qs4c32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
169
+ | `gemm_qs4cx_n512_k512` | gemm | 13 | ✓ | | ★ | ✓ | — |
170
+ | `gemm_qs4cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
171
+ | `gemm_qs8cx_n512_k512` | gemm | 13 | ✓ | | ★ | ✓ | — |
172
+ | `gemm_qs8cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
173
+ | `gemm_qsu2cx_n256_k512` | gemm | 13 | | | ✓ | ✓ | — |
174
+ | `gemm_qsu2cx_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
175
+ | `gemm_u8_f32_sme2_n256_k512` | gemm | 13 | ✓ | | — | — | ★ |
176
+ | `softmax_fp32` | softmax | 13 | | | ★ | ? | — |
177
+
178
+ ## e2e (llama.cpp GEMMs) (18)
179
+
180
+ | Definition | Op | Workloads | Eval set | Subset | SVE | SVE2 | SME2 |
181
+ |---|---|---|---|---|---|---|---|
182
+ | `gemm_ggml_q4_K_n1024_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
183
+ | `gemm_ggml_q4_K_n1024_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
184
+ | `gemm_ggml_q4_K_n14336_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
185
+ | `gemm_ggml_q4_K_n2560_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
186
+ | `gemm_ggml_q4_K_n2560_k9216` | gemm | 6 | | | ✓ | ✓ | ✓ |
187
+ | `gemm_ggml_q4_K_n4096_k14336` | gemm | 6 | | | ✓ | ✓ | ✓ |
188
+ | `gemm_ggml_q4_K_n4096_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
189
+ | `gemm_ggml_q4_K_n4096_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
190
+ | `gemm_ggml_q4_K_n8192_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
191
+ | `gemm_ggml_q4_K_n9216_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
192
+ | `gemm_ggml_q5_K_n2560_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
193
+ | `gemm_ggml_q5_K_n8192_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
194
+ | `gemm_ggml_q6_K_n1024_k2560` | gemm | 6 | | | ✓ | ✓ | ✓ |
195
+ | `gemm_ggml_q6_K_n1024_k4096` | gemm | 6 | | | ✓ | ✓ | ✓ |
196
+ | `gemm_ggml_q6_K_n128256_k4096` | gemm | 4 | | | ✓ | ✓ | ✓ |
197
+ | `gemm_ggml_q6_K_n248320_k2560` | gemm | 4 | | | ✓ | ✓ | ✓ |
198
+ | `gemm_ggml_q6_K_n2560_k9216` | gemm | 6 | | | ✓ | ✓ | ✓ |
199
+ | `gemm_ggml_q6_K_n4096_k14336` | gemm | 6 | | | ✓ | ✓ | ✓ |
200
+
201
+ ## Notes on ✗
202
+
203
+ - `loop_120` and `loop_124` (Graviton3 and Graviton4): both sort their first input in place. The harness calls the kernel on the same buffers for the correctness, warmup and timed calls and does not restore the input in between, so every timed call, the baseline's included, sorts data that is already sorted, and a kernel that returns early on sorted input or caches its result looks 20–100x faster. The baselines themselves run correctly; the timings are not valid, so both loops are left out of the Eval set.
204
+ - `loop_032` (`baseline-simd-loop-sve` on Graviton3): wrong results on 7 of 10 workloads.
205
+ - `loop_121` (`baseline-simd-loop-sve` on Graviton3): hangs (no result after 20 min).
206
+ - `loop_122` (`baseline-simd-loop-sve` on Graviton3): about 960x slower than the auto-vectorized scalar starting point.
207
+ - `loop_032` (`baseline-simd-loop-sve2` on Graviton4): wrong results on 7 of 10 workloads.
208
+ - `loop_104` (`baseline-simd-loop-sve2` on Graviton4): wrong results on 1 of 10 workloads.
209
+ - `loop_106` (`baseline-simd-loop-sve2` on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
210
+ - `loop_121` (`baseline-simd-loop-sve2` on Graviton4): hangs (no result after 15 min).
211
+ - `loop_123` (`baseline-simd-loop-sve2` on Graviton4): about 3.9x slower than the auto-vectorized scalar starting point.
212
+ - `loop_130` (`baseline-simd-loop-sve2` on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
213
+ - `loop_135` (`baseline-simd-loop-sve2` on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
214
+ - `loop_002` (`baseline-simd-loop-sme2` on M4): about 2.2x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
215
+ - `loop_010` (`baseline-simd-loop-sme2` on M4): about 44x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that (the scalar loop exits early, while the baseline scans the whole array).
216
+ - `loop_027` (`baseline-simd-loop-sme2` on M4): about 2.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
217
+ - `loop_028` (`baseline-simd-loop-sme2` on M4): about 6.1x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
218
+ - `loop_038` (`baseline-simd-loop-sme2` on M4): about 5.0x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
219
+ - `loop_114` (`baseline-simd-loop-sme2` on M4): about 3.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
220
+ - `loop_127` (`baseline-simd-loop-sme2` on M4): about 5.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
221
+ - `loop_128` (`baseline-simd-loop-sme2` on M4): 2.01x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that, just over the limit.
222
+
223
+ ## Notes on the baselines
224
+
225
+ - **ncnn** → `baseline-ncnn`, the upstream ncnn kernel, the same on every tier. ncnn is built with its SVE options off, so this is NEON code everywhere: ✓, never ★.
226
+ - **llama.cpp and e2e** → `baseline-llamacpp`, the ggml CPU kernel built natively on each machine. The exception is the five `gemm_bf16_*` GEMMs: ggml's bf16 mul_mat is scalar on Arm, so their baseline is a NEON BFMMLA kernel written for this benchmark. Which kernels reach ggml's SVE code has not been checked, so these are ✓; ggml's KleidiAI path is off. ggml picks its kernel by op, data type and CPU features, not by shape, so a cell with no recorded run is ✓ when the same op and data type ran on that machine (8 llama.cpp definitions on Graviton4). e2e has recorded runs only on Graviton4 and is ✓ on Graviton3 and M4 for the same reason (q4_K ran on both in the llama.cpp set; q5_K and q6_K have not).
227
+ - **SIMD Loops** → one hand-written Arm baseline per tier. `baseline-simd-loop-sve2` uses SVE2-only instructions in some loops (★) and is SVE code in the rest (✓). Of the 31 `baseline-simd-loop-sme2`, 24 are SVE code run in streaming mode (`__arm_locally_streaming`, tag `sme2-kernel:streaming-sve`) and 7 use ZA (tag `sme2-kernel:za`: the matrix loops 216–221 and 223). Streaming SVE counts as ✓, not ★, because it uses nothing SME adds (ZA, outer products, SME2 multi-vector instructions); the ZA ones are ★. All 31 were run on M4 and pass every workload; the 2x check against the auto-vectorized starting point flags 8 of them, which are ✗ (see the notes on ✗). `loop_032` has no SME2 code upstream, and under `-mcpu=apple-m4` its source falls back to NEON, which streaming mode rejects on M4, so it has no `baseline-simd-loop-sme2` (—).
228
+ - **KleidiAI** → `baseline-kleidiai`: each kernel uses an SVE micro-kernel (`gemm_fp32`, `gemm_qs4c32`, `conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64`), a NEON dot-product / i8mm / bf16 one (`gemm_f32_bf16`, `gemm_qai4c32`, `gemm_qsu2cx`; KleidiAI has no SVE kernel for them: ✓ on Graviton3 and Graviton4, not specialized for either), or an SME2 one (M4). `gemm_qs8cx` and `gemm_qs4cx` choose at run time: on 256-bit SVE with SVE I8MM (Graviton3) they run KleidiAI's SVE micro-kernels (★; these need exactly 256-bit vectors), elsewhere (Graviton4) a NEON pair (✓). `gemm_qs4cx` keeps the NEON GEMV at M = 1, as KleidiAI has no SVE GEMV for that format. All their KleidiAI sources are from commit 9e404c3. Of the SME2 definitions, `conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2` and the quantized and integer GEMMs run SME2 `mopa` micro-kernels (★); `gemm_i32_u8` and `gemm_u8_f32` use KleidiAI's newer `kai_matmul_uker` API. `gemm_qai8dxp_qs4c32_n256_k512` runs `kai_matmul_clamp_f32_qai8dxp2vsx8sf32_qsi4c32p8x8s16s0sbf16bf32_8vsx8_sve_i8mm` for M > 1 (exactly 256-bit SVE, so — on Graviton4) and KleidiAI's NEON GEMV `kai_matmul_clamp_f32_qai8dxp1x4_qsi4c32p8x4_1x8_neon_dotprod` (the fastest GEMV of the family there) at M = 1, as there is no SVE GEMV for that format. `softmax_fp32` runs `kai_softmax_f32_f32_1d_sve_fexpa` (any vector length; ? on Graviton4, not yet run there) and is judged by SQNR against it: its outputs (about 1/N) are below the default absolute tolerance.
229
+
definitions/conv2d/conv2d_f16_nhwc_kh3_kw3_valid_c32_c64.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_f16_nhwc_kh3_kw3_valid_c32_c64",
3
+ "op_type": "conv2d",
4
+ "description": "'Valid' (no padding) 2D conv, Kh=Kw=3 stride=1, NHWC/HWIO, C_in=32/C_out=64 baked, N=1. A/weight/bias are f16 (raw uint16 bit-pattern per this repo's raw ABI convention -- bench/datasets/raw.py's _DTYPE_TO_NP_AND_PTR); output stays float32 (RawDataset always allocates a float32 output buffer). This definition exists to host a KleidiAI SME2 baseline (kai_imatmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa via indirect-GEMM), whose native compute dtype is f16 throughout -- distinct from conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64 (fp32, 'same' padding, SVE). H/W vary per workload (must be >= 3).",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "H": { "type": "var" },
11
+ "W": { "type": "var" },
12
+ "H_out": { "type": "var" },
13
+ "W_out": { "type": "var" },
14
+ "N": { "type": "const", "value": 1 },
15
+ "C_in": { "type": "const", "value": 32 },
16
+ "C_out": { "type": "const", "value": 64 },
17
+ "Kh": { "type": "const", "value": 3 },
18
+ "Kw": { "type": "const", "value": 3 }
19
+ },
20
+ "inputs": {
21
+ "input": { "shape": ["N", "H", "W", "C_in"], "dtype": "float16" },
22
+ "weight": { "shape": ["Kh", "Kw", "C_in", "C_out"], "dtype": "float16" },
23
+ "bias": { "shape": ["C_out"], "dtype": "float16" }
24
+ },
25
+ "outputs": {
26
+ "output": { "shape": ["N", "H_out", "W_out", "C_out"], "dtype": "float32" }
27
+ },
28
+ "constraints": [
29
+ "H_out == H - Kh + 1",
30
+ "W_out == W - Kw + 1"
31
+ ],
32
+ "reference": "import numpy as np\nimport torch\nimport torch.nn.functional as F\n\n\ndef run(input, weight, bias):\n # input: [N,H,W,C_in] f16 -> NCHW f32 for torch\n x = torch.from_numpy(input.astype(np.float32)).permute(0, 3, 1, 2)\n # weight: [Kh,Kw,C_in,C_out] -> torch [C_out,C_in,Kh,Kw]\n w = torch.from_numpy(weight.astype(np.float32)).permute(3, 2, 0, 1)\n b = torch.from_numpy(bias.astype(np.float32))\n y = F.conv2d(x, w, b, stride=(1, 1), padding=(0, 0), dilation=(1, 1))\n return y.permute(0, 2, 3, 1).contiguous().numpy().astype(np.float32)\n"
33
+ }
definitions/conv2d/conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 1x1 stride=(1,1) dilation=(1,1) pad=(0,0). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 1
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 1
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 1
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 1
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 0
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 0
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "float32"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "float32"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ }
94
+ },
95
+ "outputs": {
96
+ "output": {
97
+ "shape": [
98
+ "N",
99
+ "C_out",
100
+ "H_out",
101
+ "W_out"
102
+ ],
103
+ "dtype": "float32"
104
+ }
105
+ },
106
+ "constraints": [
107
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
108
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
109
+ ],
110
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(0, 0),\n dilation=(1, 1)).numpy()\n"
111
+ }
definitions/conv2d/conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 1x1 stride=(2,2) dilation=(1,1) pad=(0,0). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 1
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 1
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 0
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 0
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "float32"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "float32"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ }
94
+ },
95
+ "outputs": {
96
+ "output": {
97
+ "shape": [
98
+ "N",
99
+ "C_out",
100
+ "H_out",
101
+ "W_out"
102
+ ],
103
+ "dtype": "float32"
104
+ }
105
+ },
106
+ "constraints": [
107
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
108
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
109
+ ],
110
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(0, 0),\n dilation=(1, 1)).numpy()\n"
111
+ }
definitions/conv2d/conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 3x3 stride=(1,1) dilation=(1,1) pad=(1,1). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 3
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 3
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 1
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 1
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 1
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 1
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "float32"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "float32"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ }
94
+ },
95
+ "outputs": {
96
+ "output": {
97
+ "shape": [
98
+ "N",
99
+ "C_out",
100
+ "H_out",
101
+ "W_out"
102
+ ],
103
+ "dtype": "float32"
104
+ }
105
+ },
106
+ "constraints": [
107
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
108
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
109
+ ],
110
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(1, 1),\n dilation=(1, 1)).numpy()\n"
111
+ }
definitions/conv2d/conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 3x3 stride=(2,2) dilation=(1,1) pad=(1,1). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 3
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 3
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 1
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 1
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "float32"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "float32"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ }
94
+ },
95
+ "outputs": {
96
+ "output": {
97
+ "shape": [
98
+ "N",
99
+ "C_out",
100
+ "H_out",
101
+ "W_out"
102
+ ],
103
+ "dtype": "float32"
104
+ }
105
+ },
106
+ "constraints": [
107
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
108
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
109
+ ],
110
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(1, 1),\n dilation=(1, 1)).numpy()\n"
111
+ }
definitions/conv2d/conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 7x7 stride=(2,2) dilation=(1,1) pad=(3,3). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 7
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 7
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 3
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 3
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "float32"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "float32"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ }
94
+ },
95
+ "outputs": {
96
+ "output": {
97
+ "shape": [
98
+ "N",
99
+ "C_out",
100
+ "H_out",
101
+ "W_out"
102
+ ],
103
+ "dtype": "float32"
104
+ }
105
+ },
106
+ "constraints": [
107
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
108
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
109
+ ],
110
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(3, 3),\n dilation=(1, 1)).numpy()\n"
111
+ }
definitions/conv2d/conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64",
3
+ "op_type": "conv2d",
4
+ "description": "'Same' conv2d (Kh=Kw=3, stride=1, pad=1, so H_out=H/W_out=W) in NHWC input / HWIO weight layout (channels-last) — distinct from this repo's other conv2d definitions (NCHW-style, via ncnn's Mat convention). Chosen deliberately to match Arm KleidiAI's imatmul indirection-buffer convention directly (no transpose needed in the baseline binding, unlike gemm_fp32_n512_k512).",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "N": { "type": "var" },
11
+ "H": { "type": "var" },
12
+ "W": { "type": "var" },
13
+ "C_in": { "type": "const", "value": 32 },
14
+ "C_out": { "type": "const", "value": 64 },
15
+ "Kh": { "type": "const", "value": 3 },
16
+ "Kw": { "type": "const", "value": 3 },
17
+ "pad": { "type": "const", "value": 1 },
18
+ "stride": { "type": "const", "value": 1 }
19
+ },
20
+ "inputs": {
21
+ "input": { "shape": ["N", "H", "W", "C_in"], "dtype": "float32" },
22
+ "weight": { "shape": ["Kh", "Kw", "C_in", "C_out"], "dtype": "float32" }
23
+ },
24
+ "outputs": {
25
+ "output": { "shape": ["N", "H", "W", "C_out"], "dtype": "float32" }
26
+ },
27
+ "constraints": [],
28
+ "reference": "import numpy as np\ndef run(input, weight):\n N, H, W, C_in = input.shape\n Kh, Kw, _, C_out = weight.shape\n pad = 1\n padded = np.pad(input, ((0, 0), (pad, pad), (pad, pad), (0, 0)))\n out = np.zeros((N, H, W, C_out), dtype=np.float32)\n for n in range(N):\n for oh in range(H):\n for ow in range(W):\n patch = padded[n, oh:oh + Kh, ow:ow + Kw, :]\n out[n, oh, ow, :] = np.tensordot(patch, weight, axes=([0, 1, 2], [0, 1, 2]))\n return out\n"
29
+ }
definitions/conv2d/conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2",
3
+ "op_type": "conv2d",
4
+ "description": "'Same' conv2d (Kh=Kw=3, stride=1, pad=1, so H_out=H/W_out=W) in NHWC input / HWIO weight layout (channels-last) \u2014 distinct from this repo's other conv2d definitions (NCHW-style, via ncnn's Mat convention). Chosen deliberately to match Arm KleidiAI's imatmul indirection-buffer convention directly (no transpose needed in the baseline binding, unlike gemm_fp32_n512_k512). SME2-tier counterpart of conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64 (same operator and ABI; baseline is KleidiAI's SME2 imatmul kernel kai_imatmul_clamp_f32_f32p2vlx1_f32p2vlx1b_2vlx2vl_sme2_mopa instead of the SVE one).",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "N": {
11
+ "type": "var"
12
+ },
13
+ "H": {
14
+ "type": "var"
15
+ },
16
+ "W": {
17
+ "type": "var"
18
+ },
19
+ "C_in": {
20
+ "type": "const",
21
+ "value": 32
22
+ },
23
+ "C_out": {
24
+ "type": "const",
25
+ "value": 64
26
+ },
27
+ "Kh": {
28
+ "type": "const",
29
+ "value": 3
30
+ },
31
+ "Kw": {
32
+ "type": "const",
33
+ "value": 3
34
+ },
35
+ "pad": {
36
+ "type": "const",
37
+ "value": 1
38
+ },
39
+ "stride": {
40
+ "type": "const",
41
+ "value": 1
42
+ }
43
+ },
44
+ "inputs": {
45
+ "input": {
46
+ "shape": [
47
+ "N",
48
+ "H",
49
+ "W",
50
+ "C_in"
51
+ ],
52
+ "dtype": "float32"
53
+ },
54
+ "weight": {
55
+ "shape": [
56
+ "Kh",
57
+ "Kw",
58
+ "C_in",
59
+ "C_out"
60
+ ],
61
+ "dtype": "float32"
62
+ }
63
+ },
64
+ "outputs": {
65
+ "output": {
66
+ "shape": [
67
+ "N",
68
+ "H",
69
+ "W",
70
+ "C_out"
71
+ ],
72
+ "dtype": "float32"
73
+ }
74
+ },
75
+ "constraints": [],
76
+ "reference": "import numpy as np\ndef run(input, weight):\n N, H, W, C_in = input.shape\n Kh, Kw, _, C_out = weight.shape\n pad = 1\n padded = np.pad(input, ((0, 0), (pad, pad), (pad, pad), (0, 0)))\n out = np.zeros((N, H, W, C_out), dtype=np.float32)\n for n in range(N):\n for oh in range(H):\n for ow in range(W):\n patch = padded[n, oh:oh + Kh, ow:ow + Kw, :]\n out[n, oh, ow, :] = np.tensordot(patch, weight, axes=([0, 1, 2], [0, 1, 2]))\n return out\n"
77
+ }
definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 1x1 stride=(1,1) dilation=(1,1) pad=(0,0). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 1
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 1
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 1
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 1
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 0
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 0
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "int8"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "int8"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ },
94
+ "input_scale": {
95
+ "shape": null,
96
+ "dtype": "float32"
97
+ },
98
+ "weight_scales": {
99
+ "shape": [
100
+ "C_out"
101
+ ],
102
+ "dtype": "float32"
103
+ }
104
+ },
105
+ "outputs": {
106
+ "output": {
107
+ "shape": [
108
+ "N",
109
+ "C_out",
110
+ "H_out",
111
+ "W_out"
112
+ ],
113
+ "dtype": "float32"
114
+ }
115
+ },
116
+ "constraints": [
117
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
118
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
119
+ ],
120
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * np.float32(input_scale)\n weight_f = weight.astype(np.float32) * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, weight_f[:, :, kh, kw])\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
121
+ }
definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 1x1 stride=(2,2) dilation=(1,1) pad=(0,0). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 1
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 1
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 0
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 0
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "int8"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "int8"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ },
94
+ "input_scale": {
95
+ "shape": null,
96
+ "dtype": "float32"
97
+ },
98
+ "weight_scales": {
99
+ "shape": [
100
+ "C_out"
101
+ ],
102
+ "dtype": "float32"
103
+ }
104
+ },
105
+ "outputs": {
106
+ "output": {
107
+ "shape": [
108
+ "N",
109
+ "C_out",
110
+ "H_out",
111
+ "W_out"
112
+ ],
113
+ "dtype": "float32"
114
+ }
115
+ },
116
+ "constraints": [
117
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
118
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
119
+ ],
120
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * np.float32(input_scale)\n weight_f = weight.astype(np.float32) * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, weight_f[:, :, kh, kw])\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
121
+ }
definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 3x3 stride=(1,1) dilation=(1,1) pad=(1,1). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 3
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 3
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 1
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 1
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 1
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 1
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "int8"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "int8"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ },
94
+ "input_scale": {
95
+ "shape": null,
96
+ "dtype": "float32"
97
+ },
98
+ "weight_scales": {
99
+ "shape": [
100
+ "C_out"
101
+ ],
102
+ "dtype": "float32"
103
+ }
104
+ },
105
+ "outputs": {
106
+ "output": {
107
+ "shape": [
108
+ "N",
109
+ "C_out",
110
+ "H_out",
111
+ "W_out"
112
+ ],
113
+ "dtype": "float32"
114
+ }
115
+ },
116
+ "constraints": [
117
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
118
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
119
+ ],
120
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * np.float32(input_scale)\n weight_f = weight.astype(np.float32) * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, weight_f[:, :, kh, kw])\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
121
+ }
definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 3x3 stride=(2,2) dilation=(1,1) pad=(1,1). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 3
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 3
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 1
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 1
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "int8"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "int8"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ },
94
+ "input_scale": {
95
+ "shape": null,
96
+ "dtype": "float32"
97
+ },
98
+ "weight_scales": {
99
+ "shape": [
100
+ "C_out"
101
+ ],
102
+ "dtype": "float32"
103
+ }
104
+ },
105
+ "outputs": {
106
+ "output": {
107
+ "shape": [
108
+ "N",
109
+ "C_out",
110
+ "H_out",
111
+ "W_out"
112
+ ],
113
+ "dtype": "float32"
114
+ }
115
+ },
116
+ "constraints": [
117
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
118
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
119
+ ],
120
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * np.float32(input_scale)\n weight_f = weight.astype(np.float32) * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, weight_f[:, :, kh, kw])\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
121
+ }
definitions/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3",
3
+ "op_type": "conv2d",
4
+ "description": "2D conv 7x7 stride=(2,2) dilation=(1,1) pad=(3,3). C_in and C_out vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:resnet50",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C_in": {
31
+ "type": "var"
32
+ },
33
+ "C_out": {
34
+ "type": "var"
35
+ },
36
+ "Kh": {
37
+ "type": "const",
38
+ "value": 7
39
+ },
40
+ "Kw": {
41
+ "type": "const",
42
+ "value": 7
43
+ },
44
+ "Sh": {
45
+ "type": "const",
46
+ "value": 2
47
+ },
48
+ "Sw": {
49
+ "type": "const",
50
+ "value": 2
51
+ },
52
+ "Dh": {
53
+ "type": "const",
54
+ "value": 1
55
+ },
56
+ "Dw": {
57
+ "type": "const",
58
+ "value": 1
59
+ },
60
+ "pad_top": {
61
+ "type": "const",
62
+ "value": 3
63
+ },
64
+ "pad_left": {
65
+ "type": "const",
66
+ "value": 3
67
+ }
68
+ },
69
+ "inputs": {
70
+ "input": {
71
+ "shape": [
72
+ "N",
73
+ "C_in",
74
+ "H",
75
+ "W"
76
+ ],
77
+ "dtype": "int8"
78
+ },
79
+ "weight": {
80
+ "shape": [
81
+ "C_out",
82
+ "C_in",
83
+ "Kh",
84
+ "Kw"
85
+ ],
86
+ "dtype": "int8"
87
+ },
88
+ "bias": {
89
+ "shape": [
90
+ "C_out"
91
+ ],
92
+ "dtype": "float32"
93
+ },
94
+ "input_scale": {
95
+ "shape": null,
96
+ "dtype": "float32"
97
+ },
98
+ "weight_scales": {
99
+ "shape": [
100
+ "C_out"
101
+ ],
102
+ "dtype": "float32"
103
+ }
104
+ },
105
+ "outputs": {
106
+ "output": {
107
+ "shape": [
108
+ "N",
109
+ "C_out",
110
+ "H_out",
111
+ "W_out"
112
+ ],
113
+ "dtype": "float32"
114
+ }
115
+ },
116
+ "constraints": [
117
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
118
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
119
+ ],
120
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 7, 7\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 3, 3\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * np.float32(input_scale)\n weight_f = weight.astype(np.float32) * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, weight_f[:, :, kh, kw])\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
121
+ }
definitions/conv2d_depthwise/conv2d_depthwise_f16_nhwc_kh3_kw3_s1_p1.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_f16_nhwc_kh3_kw3_s1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(1,1) 'same' pad=(1,1), NHWC layout, depth_multiplier=1 (C_in=C_out=C=groups), N=1, f16 throughout inputs (raw uint16 bit patterns per this repo's raw ABI convention), f32 output (RawDataset always allocates float32 output). SME2 counterpart to conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1 (f32/planar) -- this baseline (kai_dwconv_clamp_f16_f16_f16p1vlx1b_3x3_s1_4x4_sme2_mla) is the 'indirect' variant: unlike the f32 planar kernel, it takes the WHOLE feature map + pad_left/pad_top in ONE call (no per-4-row loop, no manual indirection-table construction -- the kernel handles internal addressing itself). H/W/C vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "H": { "type": "var" },
11
+ "W": { "type": "var" },
12
+ "H_out": { "type": "var" },
13
+ "W_out": { "type": "var" },
14
+ "C": { "type": "var" },
15
+ "N": { "type": "const", "value": 1 },
16
+ "Kh": { "type": "const", "value": 3 },
17
+ "Kw": { "type": "const", "value": 3 },
18
+ "Sh": { "type": "const", "value": 1 },
19
+ "Sw": { "type": "const", "value": 1 },
20
+ "pad_top": { "type": "const", "value": 1 },
21
+ "pad_left": { "type": "const", "value": 1 }
22
+ },
23
+ "inputs": {
24
+ "input": { "shape": ["N", "H", "W", "C"], "dtype": "float16" },
25
+ "weight": { "shape": ["Kh", "Kw", "C"], "dtype": "float16" },
26
+ "bias": { "shape": ["C"], "dtype": "float16" }
27
+ },
28
+ "outputs": {
29
+ "output": { "shape": ["N", "H_out", "W_out", "C"], "dtype": "float32" }
30
+ },
31
+ "constraints": [
32
+ "H_out == (H + 2*pad_top - (Kh-1) - 1) // Sh + 1",
33
+ "W_out == (W + 2*pad_left - (Kw-1) - 1) // Sw + 1"
34
+ ],
35
+ "reference": "import numpy as np\nimport torch\nimport torch.nn.functional as F\n\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input.astype(np.float32)).permute(0, 3, 1, 2)\n w = torch.from_numpy(weight.astype(np.float32)).permute(2, 0, 1).unsqueeze(1)\n b = torch.from_numpy(bias.astype(np.float32))\n y = F.conv2d(x, w, b, stride=(1, 1), padding=(1, 1), dilation=(1, 1), groups=x.shape[1])\n return y.permute(0, 2, 3, 1).contiguous().numpy().astype(np.float32)\n"
36
+ }
definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(1,1) dilation=(1,1) pad=(1,1). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 3
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 3
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 1
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 1
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 1
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 1
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "float32"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "float32"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ }
95
+ },
96
+ "outputs": {
97
+ "output": {
98
+ "shape": [
99
+ "N",
100
+ "C",
101
+ "H_out",
102
+ "W_out"
103
+ ],
104
+ "dtype": "float32"
105
+ }
106
+ },
107
+ "constraints": [
108
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
109
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
110
+ ],
111
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(1, 1),\n dilation=(1, 1), groups=x.shape[1]).numpy()\n"
112
+ }
definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(2,2) dilation=(1,1) pad=(1,1). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 3
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 3
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 2
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 2
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 1
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 1
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "float32"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "float32"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ }
95
+ },
96
+ "outputs": {
97
+ "output": {
98
+ "shape": [
99
+ "N",
100
+ "C",
101
+ "H_out",
102
+ "W_out"
103
+ ],
104
+ "dtype": "float32"
105
+ }
106
+ },
107
+ "constraints": [
108
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
109
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
110
+ ],
111
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(1, 1),\n dilation=(1, 1), groups=x.shape[1]).numpy()\n"
112
+ }
definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 5x5 stride=(1,1) dilation=(1,1) pad=(2,2). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 5
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 5
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 1
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 1
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 2
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 2
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "float32"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "float32"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ }
95
+ },
96
+ "outputs": {
97
+ "output": {
98
+ "shape": [
99
+ "N",
100
+ "C",
101
+ "H_out",
102
+ "W_out"
103
+ ],
104
+ "dtype": "float32"
105
+ }
106
+ },
107
+ "constraints": [
108
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
109
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
110
+ ],
111
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(2, 2),\n dilation=(1, 1), groups=x.shape[1]).numpy()\n"
112
+ }
definitions/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 5x5 stride=(2,2) dilation=(1,1) pad=(2,2). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 5
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 5
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 2
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 2
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 2
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 2
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "float32"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "float32"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ }
95
+ },
96
+ "outputs": {
97
+ "output": {
98
+ "shape": [
99
+ "N",
100
+ "C",
101
+ "H_out",
102
+ "W_out"
103
+ ],
104
+ "dtype": "float32"
105
+ }
106
+ },
107
+ "constraints": [
108
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
109
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
110
+ ],
111
+ "reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(2, 2),\n dilation=(1, 1), groups=x.shape[1]).numpy()\n"
112
+ }
definitions/conv2d_depthwise/conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(1,1) 'same' pad=(1,1), NHWC layout, depth_multiplier=1 (C_in=C_out=C=groups), N=1. NHWC (not NCHW like conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1) because this definition exists to host a KleidiAI SME2 baseline (kai_dwconv_clamp_f32_f32_f32p1vlx1b_3x3_s1_4xc_sme2_mla), which requires NHWC and only supports Kh=Kw=3/stride=1/depth_multiplier=1 (no dilation). H/W/C vary per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "H": { "type": "var" },
11
+ "W": { "type": "var" },
12
+ "H_out": { "type": "var" },
13
+ "W_out": { "type": "var" },
14
+ "C": { "type": "var" },
15
+ "N": { "type": "const", "value": 1 },
16
+ "Kh": { "type": "const", "value": 3 },
17
+ "Kw": { "type": "const", "value": 3 },
18
+ "Sh": { "type": "const", "value": 1 },
19
+ "Sw": { "type": "const", "value": 1 },
20
+ "pad_top": { "type": "const", "value": 1 },
21
+ "pad_left": { "type": "const", "value": 1 }
22
+ },
23
+ "inputs": {
24
+ "input": { "shape": ["N", "H", "W", "C"], "dtype": "float32" },
25
+ "weight": { "shape": ["Kh", "Kw", "C"], "dtype": "float32" },
26
+ "bias": { "shape": ["C"], "dtype": "float32" }
27
+ },
28
+ "outputs": {
29
+ "output": { "shape": ["N", "H_out", "W_out", "C"], "dtype": "float32" }
30
+ },
31
+ "constraints": [
32
+ "H_out == (H + 2*pad_top - (Kh-1) - 1) // Sh + 1",
33
+ "W_out == (W + 2*pad_left - (Kw-1) - 1) // Sw + 1"
34
+ ],
35
+ "reference": "import torch\nimport torch.nn.functional as F\n\n\ndef run(input, weight, bias):\n # input: [N,H,W,C] -> NCHW for torch\n x = torch.from_numpy(input).permute(0, 3, 1, 2)\n # weight: [Kh,Kw,C] -> torch depthwise weight [C,1,Kh,Kw]\n w = torch.from_numpy(weight).permute(2, 0, 1).unsqueeze(1)\n b = torch.from_numpy(bias)\n y = F.conv2d(x, w, b, stride=(1, 1), padding=(1, 1), dilation=(1, 1), groups=x.shape[1])\n return y.permute(0, 2, 3, 1).contiguous().numpy()\n"
36
+ }
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(1,1) dilation=(1,1) pad=(1,1). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 3
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 3
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 1
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 1
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 1
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 1
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "int8"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "int8"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ },
95
+ "input_scales": {
96
+ "shape": [
97
+ "C"
98
+ ],
99
+ "dtype": "float32"
100
+ },
101
+ "weight_scales": {
102
+ "shape": [
103
+ "C"
104
+ ],
105
+ "dtype": "float32"
106
+ }
107
+ },
108
+ "outputs": {
109
+ "output": {
110
+ "shape": [
111
+ "N",
112
+ "C",
113
+ "H_out",
114
+ "W_out"
115
+ ],
116
+ "dtype": "float32"
117
+ }
118
+ },
119
+ "constraints": [
120
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
121
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
122
+ ],
123
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * input_scales.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n weight_f = weight.astype(np.float32)[:, 0, :, :] * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, C, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * weight_f[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
124
+ }
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 3x3 stride=(2,2) dilation=(1,1) pad=(1,1). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 3
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 3
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 2
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 2
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 1
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 1
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "int8"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "int8"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ },
95
+ "input_scales": {
96
+ "shape": [
97
+ "C"
98
+ ],
99
+ "dtype": "float32"
100
+ },
101
+ "weight_scales": {
102
+ "shape": [
103
+ "C"
104
+ ],
105
+ "dtype": "float32"
106
+ }
107
+ },
108
+ "outputs": {
109
+ "output": {
110
+ "shape": [
111
+ "N",
112
+ "C",
113
+ "H_out",
114
+ "W_out"
115
+ ],
116
+ "dtype": "float32"
117
+ }
118
+ },
119
+ "constraints": [
120
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
121
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
122
+ ],
123
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * input_scales.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n weight_f = weight.astype(np.float32)[:, 0, :, :] * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, C, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * weight_f[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
124
+ }
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 5x5 stride=(1,1) dilation=(1,1) pad=(2,2). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 5
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 5
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 1
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 1
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 2
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 2
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "int8"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "int8"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ },
95
+ "input_scales": {
96
+ "shape": [
97
+ "C"
98
+ ],
99
+ "dtype": "float32"
100
+ },
101
+ "weight_scales": {
102
+ "shape": [
103
+ "C"
104
+ ],
105
+ "dtype": "float32"
106
+ }
107
+ },
108
+ "outputs": {
109
+ "output": {
110
+ "shape": [
111
+ "N",
112
+ "C",
113
+ "H_out",
114
+ "W_out"
115
+ ],
116
+ "dtype": "float32"
117
+ }
118
+ },
119
+ "constraints": [
120
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
121
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
122
+ ],
123
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * input_scales.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n weight_f = weight.astype(np.float32)[:, 0, :, :] * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, C, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * weight_f[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
124
+ }
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2",
3
+ "op_type": "conv2d_depthwise",
4
+ "description": "Depthwise 2D conv 5x5 stride=(2,2) dilation=(1,1) pad=(2,2). C (=C_in=C_out=groups) varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "model:mobilenetv3-large",
8
+ "baseline-solution:ncnn"
9
+ ],
10
+ "axes": {
11
+ "N": {
12
+ "type": "var"
13
+ },
14
+ "H": {
15
+ "type": "var",
16
+ "parent": "N"
17
+ },
18
+ "W": {
19
+ "type": "var",
20
+ "parent": "N"
21
+ },
22
+ "H_out": {
23
+ "type": "var",
24
+ "parent": "N"
25
+ },
26
+ "W_out": {
27
+ "type": "var",
28
+ "parent": "N"
29
+ },
30
+ "C": {
31
+ "type": "var"
32
+ },
33
+ "C_group": {
34
+ "type": "const",
35
+ "value": 1
36
+ },
37
+ "Kh": {
38
+ "type": "const",
39
+ "value": 5
40
+ },
41
+ "Kw": {
42
+ "type": "const",
43
+ "value": 5
44
+ },
45
+ "Sh": {
46
+ "type": "const",
47
+ "value": 2
48
+ },
49
+ "Sw": {
50
+ "type": "const",
51
+ "value": 2
52
+ },
53
+ "Dh": {
54
+ "type": "const",
55
+ "value": 1
56
+ },
57
+ "Dw": {
58
+ "type": "const",
59
+ "value": 1
60
+ },
61
+ "pad_top": {
62
+ "type": "const",
63
+ "value": 2
64
+ },
65
+ "pad_left": {
66
+ "type": "const",
67
+ "value": 2
68
+ }
69
+ },
70
+ "inputs": {
71
+ "input": {
72
+ "shape": [
73
+ "N",
74
+ "C",
75
+ "H",
76
+ "W"
77
+ ],
78
+ "dtype": "int8"
79
+ },
80
+ "weight": {
81
+ "shape": [
82
+ "C",
83
+ "C_group",
84
+ "Kh",
85
+ "Kw"
86
+ ],
87
+ "dtype": "int8"
88
+ },
89
+ "bias": {
90
+ "shape": [
91
+ "C"
92
+ ],
93
+ "dtype": "float32"
94
+ },
95
+ "input_scales": {
96
+ "shape": [
97
+ "C"
98
+ ],
99
+ "dtype": "float32"
100
+ },
101
+ "weight_scales": {
102
+ "shape": [
103
+ "C"
104
+ ],
105
+ "dtype": "float32"
106
+ }
107
+ },
108
+ "outputs": {
109
+ "output": {
110
+ "shape": [
111
+ "N",
112
+ "C",
113
+ "H_out",
114
+ "W_out"
115
+ ],
116
+ "dtype": "float32"
117
+ }
118
+ },
119
+ "constraints": [
120
+ "H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
121
+ "W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
122
+ ],
123
+ "reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n input_f = input.astype(np.float32) * input_scales.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n weight_f = weight.astype(np.float32)[:, 0, :, :] * weight_scales.astype(np.float32)[:, np.newaxis, np.newaxis]\n xp = np.pad(input_f, ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n acc = np.zeros((N, C, Hout, Wout), dtype=np.float32)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * weight_f[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n acc += bias.astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]\n return acc.astype(np.float32)\n"
124
+ }
definitions/gemm/gemm_bf16_n1024_k2048.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n1024_k2048",
3
+ "op_type": "gemm",
4
+ "description": "expert ffn N=1024 K=2048",
5
+ "tags": [
6
+ "status:active",
7
+ "model:olmoe-1b-7b",
8
+ "baseline-solution:llama.cpp"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 1024
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 2048
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "bfloat16"
30
+ },
31
+ "B": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "bfloat16"
37
+ }
38
+ },
39
+ "outputs": {
40
+ "C": {
41
+ "shape": [
42
+ "M",
43
+ "N"
44
+ ],
45
+ "dtype": "float32"
46
+ }
47
+ },
48
+ "constraints": [],
49
+ "reference": "import numpy as np\ndef run(A, B):\n return A.astype(np.float32) @ B.astype(np.float32).T\n"
50
+ }
definitions/gemm/gemm_bf16_n1408_k2048.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n1408_k2048",
3
+ "op_type": "gemm",
4
+ "description": "expert ffn N=1408 K=2048",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen1.5-moe-a2.7b",
8
+ "baseline-solution:llama.cpp"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 1408
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 2048
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "bfloat16"
30
+ },
31
+ "B": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "bfloat16"
37
+ }
38
+ },
39
+ "outputs": {
40
+ "C": {
41
+ "shape": [
42
+ "M",
43
+ "N"
44
+ ],
45
+ "dtype": "float32"
46
+ }
47
+ },
48
+ "constraints": [],
49
+ "reference": "import numpy as np\ndef run(A, B):\n return A.astype(np.float32) @ B.astype(np.float32).T\n"
50
+ }
definitions/gemm/gemm_bf16_n2048_k1024.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n2048_k1024",
3
+ "op_type": "gemm",
4
+ "description": "expert ffn N=2048 K=1024",
5
+ "tags": [
6
+ "status:active",
7
+ "model:olmoe-1b-7b",
8
+ "baseline-solution:llama.cpp"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 2048
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 1024
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "bfloat16"
30
+ },
31
+ "B": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "bfloat16"
37
+ }
38
+ },
39
+ "outputs": {
40
+ "C": {
41
+ "shape": [
42
+ "M",
43
+ "N"
44
+ ],
45
+ "dtype": "float32"
46
+ }
47
+ },
48
+ "constraints": [],
49
+ "reference": "import numpy as np\ndef run(A, B):\n return A.astype(np.float32) @ B.astype(np.float32).T\n"
50
+ }
definitions/gemm/gemm_bf16_n2048_k1408.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n2048_k1408",
3
+ "op_type": "gemm",
4
+ "description": "expert ffn N=2048 K=1408",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen1.5-moe-a2.7b",
8
+ "baseline-solution:llama.cpp"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 2048
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 1408
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "bfloat16"
30
+ },
31
+ "B": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "bfloat16"
37
+ }
38
+ },
39
+ "outputs": {
40
+ "C": {
41
+ "shape": [
42
+ "M",
43
+ "N"
44
+ ],
45
+ "dtype": "float32"
46
+ }
47
+ },
48
+ "constraints": [],
49
+ "reference": "import numpy as np\ndef run(A, B):\n return A.astype(np.float32) @ B.astype(np.float32).T\n"
50
+ }
definitions/gemm/gemm_bf16_n2048_k2048.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n2048_k2048",
3
+ "op_type": "gemm",
4
+ "description": "attn proj N=2048 K=2048",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen1.5-moe-a2.7b",
8
+ "baseline-solution:llama.cpp"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 2048
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 2048
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "bfloat16"
30
+ },
31
+ "B": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "bfloat16"
37
+ }
38
+ },
39
+ "outputs": {
40
+ "C": {
41
+ "shape": [
42
+ "M",
43
+ "N"
44
+ ],
45
+ "dtype": "float32"
46
+ }
47
+ },
48
+ "constraints": [],
49
+ "reference": "import numpy as np\ndef run(A, B):\n return A.astype(np.float32) @ B.astype(np.float32).T\n"
50
+ }
definitions/gemm/gemm_bf16_n512_k512.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_bf16_n512_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=512 K=512, compute-precision-only bf16: A[M,K]/B[K,N]/bias[N] are fp32 wire format (the actual KleidiAI packers kai_lhs_pack_bf16p2vlx2_f32_sme2 / kai_rhs_pack_kxn_bf16p2vlx2b_f32_x32_sme both take raw f32 input and truncate to bf16 internally as part of packing -- there is no bf16 data anywhere upstream, this is a lossy compute-precision optimization applied on the fly, analogous to gemm_qs4c32_n256_k512's dynamic LHS quantization, NOT a pre-quantized-weight contract like gemm_q4_k_m_*). B is [K,N] ('kxn' layout, matching the RHS packer's native input layout directly, no transpose needed) -- unlike this repo's other plain gemm definitions, which use [N,K]. Output is float32. Baseline: kai_matmul_clamp_f32_bf16p2vlx2_bf16p2vlx2_2vlx2vl_sme2_mopa. Judged by element tolerance with a matched-ratio bar sized to bf16 (7 mantissa bits) truncation -- no dequantization is involved, so not SQNR. M varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "M": {
11
+ "type": "var"
12
+ },
13
+ "N": {
14
+ "type": "const",
15
+ "value": 512
16
+ },
17
+ "K": {
18
+ "type": "const",
19
+ "value": 512
20
+ }
21
+ },
22
+ "inputs": {
23
+ "A": {
24
+ "shape": [
25
+ "M",
26
+ "K"
27
+ ],
28
+ "dtype": "float32"
29
+ },
30
+ "B": {
31
+ "shape": [
32
+ "K",
33
+ "N"
34
+ ],
35
+ "dtype": "float32"
36
+ },
37
+ "bias": {
38
+ "shape": [
39
+ "N"
40
+ ],
41
+ "dtype": "float32"
42
+ }
43
+ },
44
+ "outputs": {
45
+ "C": {
46
+ "shape": [
47
+ "M",
48
+ "N"
49
+ ],
50
+ "dtype": "float32"
51
+ }
52
+ },
53
+ "constraints": [],
54
+ "reference": "import numpy as np\n\n\ndef run(A, B, bias):\n return (A.astype(np.float32) @ B.astype(np.float32) + bias.astype(np.float32)).astype(np.float32)\n"
55
+ }
definitions/gemm/gemm_f16_n512_k512.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f16_n512_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=512 K=512, f16 throughout inputs (A[M,K], B[K,N] -- 'kxn' layout matching kai_rhs_pack_kxn_x16p2vlx2b_x16_x16_sme's native input layout, no transpose needed -- and bias[N], all raw uint16 bit patterns per this repo's raw ABI convention for float16-dtype tensors), f32 output (RawDataset always allocates float32 output; kernel's native f16 output is converted). This definition exists to host a KleidiAI SME2 baseline (kai_matmul_clamp_f16_f16_f16p2vlx2b_1x16vl_sme2_dot) -- pure f16 in/out, distinct from gemm_bf16_n512_k512 (fp32 wire format, bf16-compute) and conv2d_f16_nhwc_kh3_kw3_valid_c32_c64 (conv2d, not gemm). Like gemm_fp32_sme2_n512_k512, the LHS is UNPACKED and the kernel has an 'm==1' tile restriction requiring a per-row loop. M varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "M": { "type": "var" },
11
+ "N": { "type": "const", "value": 512 },
12
+ "K": { "type": "const", "value": 512 }
13
+ },
14
+ "inputs": {
15
+ "A": { "shape": ["M", "K"], "dtype": "float16" },
16
+ "B": { "shape": ["K", "N"], "dtype": "float16" },
17
+ "bias": { "shape": ["N"], "dtype": "float16" }
18
+ },
19
+ "outputs": {
20
+ "C": { "shape": ["M", "N"], "dtype": "float32" }
21
+ },
22
+ "constraints": [],
23
+ "reference": "import numpy as np\n\n\ndef run(A, B, bias):\n return (A.astype(np.float32) @ B.astype(np.float32) + bias.astype(np.float32)).astype(np.float32)\n"
24
+ }
definitions/gemm/gemm_f16_qai4c32_sme2_n256_k512.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f16_qai4c32_sme2_n256_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=256 K=512, fp16 activations x block-wise asymmetric int4 weights, fp16 kernel family (SME2): A float16 [M,K] (raw patterns), B_q4 uint8 [N,K/2] adjacent-pair nibbles (byte j: k=2j low, k=2j+1 high), per-block (length 32) fp32 scale B_scales and fp32 additive offset B_zeros [N,K/32] already in the real domain (= -zero_point*scale), fp32 bias [N]; dequant via value=(nibble-8)*scale+zero. The kernel's native output is fp16; the raw ABI allocates float32 outputs, so the binding widens it (exact), and fp16 rounding is part of what the baseline-relative SQNR gate absorbs. M varies per workload. Baseline: kai_matmul_clamp_f16_qsi8d32p1vlx4_qai4c32p4vlx4_1vlx4vl_sme2_mopa.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai",
8
+ "correctness:sqnr"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 256
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 512
21
+ },
22
+ "K_half": {
23
+ "type": "const",
24
+ "value": 256
25
+ },
26
+ "K_blocks": {
27
+ "type": "const",
28
+ "value": 16
29
+ }
30
+ },
31
+ "inputs": {
32
+ "A": {
33
+ "shape": [
34
+ "M",
35
+ "K"
36
+ ],
37
+ "dtype": "float16"
38
+ },
39
+ "B_q4": {
40
+ "shape": [
41
+ "N",
42
+ "K_half"
43
+ ],
44
+ "dtype": "uint8"
45
+ },
46
+ "B_scales": {
47
+ "shape": [
48
+ "N",
49
+ "K_blocks"
50
+ ],
51
+ "dtype": "float32"
52
+ },
53
+ "B_zeros": {
54
+ "shape": [
55
+ "N",
56
+ "K_blocks"
57
+ ],
58
+ "dtype": "float32"
59
+ },
60
+ "bias": {
61
+ "shape": [
62
+ "N"
63
+ ],
64
+ "dtype": "float32"
65
+ }
66
+ },
67
+ "outputs": {
68
+ "C": {
69
+ "shape": [
70
+ "M",
71
+ "N"
72
+ ],
73
+ "dtype": "float32"
74
+ }
75
+ },
76
+ "reference": "import numpy as np\n\n\ndef run(A, B_q4, B_scales, B_zeros, bias):\n n, k_half = B_q4.shape\n deq = np.empty((n, k_half * 2), dtype=np.float32)\n deq[:, 0::2] = (B_q4 & 0x0F).astype(np.float32) - 8.0\n deq[:, 1::2] = (B_q4 >> 4).astype(np.float32) - 8.0\n s = np.repeat(B_scales.astype(np.float32), 32, axis=1)\n z = np.repeat(B_zeros.astype(np.float32), 32, axis=1)\n B = deq * s + z\n return (A.astype(np.float32) @ B.T + bias.astype(np.float32)).astype(np.float32)\n"
77
+ }
definitions/gemm/gemm_f16_qs4cx_sme2_n256_k512.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f16_qs4cx_sme2_n256_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=256 K=512, fp16 activations x per-channel int4 weights, fp16 kernel family (SME2): A float16 [M,K] (raw patterns), B_q4 uint8 [N,K/2] adjacent-pair nibbles (byte j: k=2j low, k=2j+1 high), zero_point=8, one fp32 scale per output channel, fp32 bias [N]; dequant via value=(nibble-8)*scale. The kernel's native output is fp16; the raw ABI allocates float32 outputs, so the binding widens it (exact), and fp16 rounding is part of what the baseline-relative SQNR gate absorbs. M varies per workload. Baseline: kai_matmul_clamp_f16_qai8dxp1vlx8_qsi4cxp4vlx8_1vlx4vl_sme2_mopa.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai",
8
+ "correctness:sqnr"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 256
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 512
21
+ },
22
+ "K_half": {
23
+ "type": "const",
24
+ "value": 256
25
+ }
26
+ },
27
+ "inputs": {
28
+ "A": {
29
+ "shape": [
30
+ "M",
31
+ "K"
32
+ ],
33
+ "dtype": "float16"
34
+ },
35
+ "B_q4": {
36
+ "shape": [
37
+ "N",
38
+ "K_half"
39
+ ],
40
+ "dtype": "uint8"
41
+ },
42
+ "B_scales": {
43
+ "shape": [
44
+ "N"
45
+ ],
46
+ "dtype": "float32"
47
+ },
48
+ "bias": {
49
+ "shape": [
50
+ "N"
51
+ ],
52
+ "dtype": "float32"
53
+ }
54
+ },
55
+ "outputs": {
56
+ "C": {
57
+ "shape": [
58
+ "M",
59
+ "N"
60
+ ],
61
+ "dtype": "float32"
62
+ }
63
+ },
64
+ "reference": "import numpy as np\n\n\ndef run(A, B_q4, B_scales, bias):\n n, k_half = B_q4.shape\n deq = np.empty((n, k_half * 2), dtype=np.float32)\n deq[:, 0::2] = (B_q4 & 0x0F).astype(np.float32) - 8.0\n deq[:, 1::2] = (B_q4 >> 4).astype(np.float32) - 8.0\n B = deq * B_scales.astype(np.float32)[:, None]\n return (A.astype(np.float32) @ B.T + bias.astype(np.float32)).astype(np.float32)\n"
65
+ }
definitions/gemm/gemm_f16_qs8cx_sme2_n256_k512.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f16_qs8cx_sme2_n256_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=256 K=512, fp16 activations x per-channel int8 weights, fp16 kernel family (SME2): A float16 [M,K] (raw patterns), B_q8 int8 [N,K] + one fp32 scale per output channel (value=q*scale, no zero point), fp32 bias [N]. The kernel's native output is fp16; the raw ABI allocates float32 outputs, so the binding widens it (exact), and fp16 rounding is part of what the baseline-relative SQNR gate absorbs. M varies per workload. Baseline: kai_matmul_clamp_f16_qai8dxp1vlx4_qsi8cxp4vlx4_1vlx4vl_sme2_mopa (LHS via kai_lhs_quant_pack_qai8dxp_f16_neon).",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai",
8
+ "correctness:sqnr"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 256
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 512
21
+ }
22
+ },
23
+ "inputs": {
24
+ "A": {
25
+ "shape": [
26
+ "M",
27
+ "K"
28
+ ],
29
+ "dtype": "float16"
30
+ },
31
+ "B_q8": {
32
+ "shape": [
33
+ "N",
34
+ "K"
35
+ ],
36
+ "dtype": "int8"
37
+ },
38
+ "B_scales": {
39
+ "shape": [
40
+ "N"
41
+ ],
42
+ "dtype": "float32"
43
+ },
44
+ "bias": {
45
+ "shape": [
46
+ "N"
47
+ ],
48
+ "dtype": "float32"
49
+ }
50
+ },
51
+ "outputs": {
52
+ "C": {
53
+ "shape": [
54
+ "M",
55
+ "N"
56
+ ],
57
+ "dtype": "float32"
58
+ }
59
+ },
60
+ "reference": "import numpy as np\n\n\ndef run(A, B_q8, B_scales, bias):\n B = B_q8.astype(np.float32) * B_scales.astype(np.float32)[:, None]\n return (A.astype(np.float32) @ B.T + bias.astype(np.float32)).astype(np.float32)\n"
61
+ }
definitions/gemm/gemm_f16act_qs4c32_sme2_n256_k512.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f16act_qs4c32_sme2_n256_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM, N=256 K=512, fp16 activations x block-wise int4 weights (SME2): A is float16 [M,K] (raw 16-bit patterns per the raw ABI), B_q4 uint8 [N,K/2] and f16 per-block scales exactly as gemm_qs4c32_sme2_n256_k512 (block length 32, zero_point=8, split-half nibbles); no bias; f32 output. The mixed fp16-activation / int4-weight case. M varies per workload. Baseline: kai_matmul_clamp_f32_f16p1vlx2_qsi4c32p4vlx2_1vlx4vl_sme2_mopa (needs SME2 and FP16).",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai",
8
+ "correctness:sqnr"
9
+ ],
10
+ "axes": {
11
+ "M": {
12
+ "type": "var"
13
+ },
14
+ "N": {
15
+ "type": "const",
16
+ "value": 256
17
+ },
18
+ "K": {
19
+ "type": "const",
20
+ "value": 512
21
+ },
22
+ "K_half": {
23
+ "type": "const",
24
+ "value": 256
25
+ },
26
+ "K_blocks": {
27
+ "type": "const",
28
+ "value": 16
29
+ }
30
+ },
31
+ "inputs": {
32
+ "A": {
33
+ "shape": [
34
+ "M",
35
+ "K"
36
+ ],
37
+ "dtype": "float16"
38
+ },
39
+ "B_q4": {
40
+ "shape": [
41
+ "N",
42
+ "K_half"
43
+ ],
44
+ "dtype": "uint8"
45
+ },
46
+ "B_scales": {
47
+ "shape": [
48
+ "N",
49
+ "K_blocks"
50
+ ],
51
+ "dtype": "float16"
52
+ }
53
+ },
54
+ "outputs": {
55
+ "C": {
56
+ "shape": [
57
+ "M",
58
+ "N"
59
+ ],
60
+ "dtype": "float32"
61
+ }
62
+ },
63
+ "reference": "import numpy as np\n\n\ndef run(A, B_q4, B_scales):\n n, k_half = B_q4.shape\n bl = 32\n nb = k_half // (bl // 2)\n lo = (B_q4 & 0x0F).astype(np.float32) - 8.0\n hi = (B_q4 >> 4).astype(np.float32) - 8.0\n deq = np.concatenate([lo.reshape(n, nb, bl // 2), hi.reshape(n, nb, bl // 2)], axis=-1).reshape(n, nb * bl)\n B = deq * np.repeat(B_scales.astype(np.float32), bl, axis=-1)\n return (A.astype(np.float32) @ B.T).astype(np.float32)\n"
64
+ }
definitions/gemm/gemm_f32_bf16_n512_k512.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_f32_bf16_n512_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=512 K=512, compute-precision-only bf16 on NEON bfmmla: A[M,K]/B[K,N]/bias[N] are fp32 wire format; the baseline packers (kai_lhs_quant_pack_bf16p8x4_f32_neon, kai_rhs_quant_pack_kxn_bf16p12x4biasf32_f32_neon) truncate to bf16 internally, as in gemm_bf16_n512_k512 (the SME2 variant). M varies per workload. Baseline: kai_matmul_clamp_f32_bf16p8x4_bf16p12x4b_8x12_neon_mmla.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "M": {
11
+ "type": "var"
12
+ },
13
+ "N": {
14
+ "type": "const",
15
+ "value": 512
16
+ },
17
+ "K": {
18
+ "type": "const",
19
+ "value": 512
20
+ }
21
+ },
22
+ "inputs": {
23
+ "A": {
24
+ "shape": [
25
+ "M",
26
+ "K"
27
+ ],
28
+ "dtype": "float32"
29
+ },
30
+ "B": {
31
+ "shape": [
32
+ "K",
33
+ "N"
34
+ ],
35
+ "dtype": "float32"
36
+ },
37
+ "bias": {
38
+ "shape": [
39
+ "N"
40
+ ],
41
+ "dtype": "float32"
42
+ }
43
+ },
44
+ "outputs": {
45
+ "C": {
46
+ "shape": [
47
+ "M",
48
+ "N"
49
+ ],
50
+ "dtype": "float32"
51
+ }
52
+ },
53
+ "reference": "import numpy as np\n\n\ndef run(A, B, bias):\n return (A.astype(np.float32) @ B.astype(np.float32) + bias.astype(np.float32)).astype(np.float32)\n"
54
+ }
definitions/gemm/gemm_fp32_n512_k512.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_fp32_n512_k512",
3
+ "op_type": "gemm",
4
+ "description": "fc N=512 K=512",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "M": {
11
+ "type": "var"
12
+ },
13
+ "N": {
14
+ "type": "const",
15
+ "value": 512
16
+ },
17
+ "K": {
18
+ "type": "const",
19
+ "value": 512
20
+ }
21
+ },
22
+ "inputs": {
23
+ "A": {
24
+ "shape": [
25
+ "M",
26
+ "K"
27
+ ],
28
+ "dtype": "float32"
29
+ },
30
+ "B": {
31
+ "shape": [
32
+ "N",
33
+ "K"
34
+ ],
35
+ "dtype": "float32"
36
+ }
37
+ },
38
+ "outputs": {
39
+ "C": {
40
+ "shape": [
41
+ "M",
42
+ "N"
43
+ ],
44
+ "dtype": "float32"
45
+ }
46
+ },
47
+ "constraints": [],
48
+ "reference": "import numpy as np\ndef run(A, B):\n return A @ B.T\n"
49
+ }
definitions/gemm/gemm_fp32_sme2_n512_k512.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_fp32_sme2_n512_k512",
3
+ "op_type": "gemm",
4
+ "description": "GEMM+bias, N=512 K=512, full fp32 throughout (A[M,K], B[K,N] -- 'kxn' layout matching kai_rhs_pack_kxn_f32p16vlx1b_f32_f32_sme's native input layout, no transpose needed -- and bias[N]), f32 output. This definition exists to host a KleidiAI SME2 baseline (kai_matmul_clamp_f32_f32_f32p16vlx1b_1x16vl_sme2_mla) -- the SME2-native counterpart to gemm_fp32_n512_k512 (SVE). No internal precision loss (unlike gemm_bf16_n512_k512) -- both LHS and RHS stay fp32 end to end, so this uses the default tight elementwise tolerance, not correctness:sqnr. The kernel's LHS is UNPACKED (raw f32 rows consumed directly, no LHS-pack step) but its 'm==1' tile restriction means the caller must loop one output row at a time -- matching gemm_qs4c32_n256_k512's per-row-loop pattern (different kernel family, same shape of restriction). M varies per workload.",
5
+ "tags": [
6
+ "status:active",
7
+ "baseline-solution:kleidiai"
8
+ ],
9
+ "axes": {
10
+ "M": { "type": "var" },
11
+ "N": { "type": "const", "value": 512 },
12
+ "K": { "type": "const", "value": 512 }
13
+ },
14
+ "inputs": {
15
+ "A": { "shape": ["M", "K"], "dtype": "float32" },
16
+ "B": { "shape": ["K", "N"], "dtype": "float32" },
17
+ "bias": { "shape": ["N"], "dtype": "float32" }
18
+ },
19
+ "outputs": {
20
+ "C": { "shape": ["M", "N"], "dtype": "float32" }
21
+ },
22
+ "constraints": [],
23
+ "reference": "import numpy as np\n\n\ndef run(A, B, bias):\n return (A.astype(np.float32) @ B.astype(np.float32) + bias.astype(np.float32)).astype(np.float32)\n"
24
+ }
definitions/gemm/gemm_ggml_q4_K_n1024_k2560.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n1024_k2560",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.attn_k.weight\u00d78, blk.N.attn_v.weight\u00d73: N=1024 K=2560, ggml Q4_K block rows (e2e, 0.6% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.0059"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 1024
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 2560
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 10
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 1440
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n1024_k4096.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n1024_k4096",
3
+ "op_type": "gemm",
4
+ "description": "llama blk.N.attn_k.weight\u00d732, blk.N.attn_v.weight\u00d716: N=1024 K=4096, ggml Q4_K block rows (e2e, 2.5% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:llama-3.1-8b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:llama-3.1-8b",
11
+ "e2e-share:0.0246"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 1024
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 4096
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 16
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 2304
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n14336_k4096.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n14336_k4096",
3
+ "op_type": "gemm",
4
+ "description": "llama blk.N.ffn_gate.weight\u00d732, blk.N.ffn_up.weight\u00d732: N=14336 K=4096, ggml Q4_K block rows (e2e, 45.8% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:llama-3.1-8b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:llama-3.1-8b",
11
+ "e2e-share:0.4578"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 14336
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 4096
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 16
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 2304
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n2560_k4096.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n2560_k4096",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.attn_output.weight\u00d78: N=2560 K=4096, ggml Q4_K block rows (e2e, 1.7% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.0173"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 2560
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 4096
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 16
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 2304
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n2560_k9216.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n2560_k9216",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.ffn_down.weight\u00d716: N=2560 K=9216, ggml Q4_K block rows (e2e, 7.8% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.0778"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 2560
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 9216
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 36
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 5184
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n4096_k14336.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n4096_k14336",
3
+ "op_type": "gemm",
4
+ "description": "llama blk.N.ffn_down.weight\u00d716: N=4096 K=14336, ggml Q4_K block rows (e2e, 11.5% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:llama-3.1-8b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:llama-3.1-8b",
11
+ "e2e-share:0.1145"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 4096
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 14336
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 56
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 8064
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n4096_k2560.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n4096_k2560",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.attn_gate.weight\u00d724: N=4096 K=2560, ggml Q4_K block rows (e2e, 5.2% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.0519"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 4096
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 2560
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 10
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 1440
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n4096_k4096.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n4096_k4096",
3
+ "op_type": "gemm",
4
+ "description": "llama blk.N.attn_output.weight\u00d732, blk.N.attn_q.weight\u00d732: N=4096 K=4096, ggml Q4_K block rows (e2e, 13.1% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:llama-3.1-8b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:llama-3.1-8b",
11
+ "e2e-share:0.1308"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 4096
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 4096
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 16
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 2304
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n8192_k2560.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n8192_k2560",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.attn_q.weight\u00d78: N=8192 K=2560, ggml Q4_K block rows (e2e, 3.5% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.0346"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 8192
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 2560
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 10
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 1440
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }
definitions/gemm/gemm_ggml_q4_K_n9216_k2560.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemm_ggml_q4_K_n9216_k2560",
3
+ "op_type": "gemm",
4
+ "description": "qwen35 blk.N.ffn_gate.weight\u00d732, blk.N.ffn_up.weight\u00d732: N=9216 K=2560, ggml Q4_K block rows (e2e, 31.1% of decode bytes)",
5
+ "tags": [
6
+ "status:active",
7
+ "model:qwen3.5-4b",
8
+ "baseline-solution:llama.cpp",
9
+ "correctness:sqnr",
10
+ "e2e:qwen3.5-4b",
11
+ "e2e-share:0.3112"
12
+ ],
13
+ "axes": {
14
+ "M": {
15
+ "type": "var"
16
+ },
17
+ "N": {
18
+ "type": "const",
19
+ "value": 9216
20
+ },
21
+ "K": {
22
+ "type": "const",
23
+ "value": 2560
24
+ },
25
+ "K_blk": {
26
+ "type": "const",
27
+ "value": 10
28
+ },
29
+ "K_bytes": {
30
+ "type": "const",
31
+ "value": 1440
32
+ }
33
+ },
34
+ "inputs": {
35
+ "A": {
36
+ "shape": [
37
+ "M",
38
+ "K"
39
+ ],
40
+ "dtype": "bfloat16"
41
+ },
42
+ "B": {
43
+ "shape": [
44
+ "N",
45
+ "K_bytes"
46
+ ],
47
+ "dtype": "uint8"
48
+ }
49
+ },
50
+ "outputs": {
51
+ "C": {
52
+ "shape": [
53
+ "M",
54
+ "N"
55
+ ],
56
+ "dtype": "float32"
57
+ }
58
+ },
59
+ "constraints": [],
60
+ "reference": "import numpy as np\n\n\ndef unpack_scales_k4(s12):\n # ggml get_scale_min_k4 over the 12-byte packed field -> (sc, mn) [..., 8]\n s12 = s12.astype(np.uint8)\n sc = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n mn = np.empty(s12.shape[:-1] + (8,), dtype=np.float32)\n for j in range(4):\n sc[..., j] = s12[..., j] & 63\n mn[..., j] = s12[..., j + 4] & 63\n for j in range(4, 8):\n sc[..., j] = (s12[..., j + 4] & 0xF) | ((s12[..., j - 4] >> 6) << 4)\n mn[..., j] = (s12[..., j + 4] >> 4) | ((s12[..., j] >> 6) << 4)\n return sc, mn\n\n\ndef f16(b):\n # little-endian fp16 bytes [..., 2] -> float32 [...]\n return np.ascontiguousarray(b).view(\"<f2\")[..., 0].astype(np.float32)\n\n\ndef dequant_ggml_q4_K(B):\n # B: uint8 [N, K/256 * 144] rows of ggml block_q4_K\n # {fp16 d; fp16 dmin; uint8 scales[12]; uint8 qs[128]}\n n_rows, k_bytes = B.shape\n nb = k_bytes // 144\n blk = np.ascontiguousarray(B).reshape(n_rows, nb, 144)\n d = f16(blk[:, :, 0:2])\n dmin = f16(blk[:, :, 2:4])\n sc, mn = unpack_scales_k4(blk[:, :, 4:16])\n qs = blk[:, :, 16:144].reshape(n_rows, nb, 4, 32)\n q = np.empty((n_rows, nb, 4, 2, 32), dtype=np.float32)\n q[:, :, :, 0, :] = qs & 0x0F\n q[:, :, :, 1, :] = qs >> 4\n ds = np.repeat(d[..., None] * sc, 32, axis=-1)\n dm = np.repeat(dmin[..., None] * mn, 32, axis=-1)\n w = ds * q.reshape(n_rows, nb, 256) - dm\n return w.reshape(n_rows, nb * 256)\n\n\ndef run(A, B):\n # Chunk over weight rows: dequantizing all of B at once needs ~4x N*K*4\n # bytes of temporaries (10+ GB for a 248320 x 2560 lm_head), which does\n # not fit an 8 GB box. ~128 MB of fp32 weights per chunk keeps the peak\n # under ~1 GB regardless of N.\n A_f = A.astype(np.float32)\n n_rows, k_bytes = B.shape\n K = (k_bytes // {\"dequant_ggml_q4_K\": 144, \"dequant_ggml_q5_K\": 176, \"dequant_ggml_q6_K\": 210}[\"dequant_ggml_q4_K\"]) * 256\n step = max(256, ((128 << 20) // (K * 4)) // 256 * 256)\n out = np.empty((A_f.shape[0], n_rows), dtype=np.float32)\n for i in range(0, n_rows, step):\n out[:, i:i + step] = A_f @ dequant_ggml_q4_K(B[i:i + step]).T\n return out\n"
61
+ }