plawanrath commited on
Commit
8a682b8
·
verified ·
1 Parent(s): 4645978

Initial upload of NL→MLIR benchmark

Browse files
Files changed (4) hide show
  1. LICENSE +19 -0
  2. README.md +95 -0
  3. croissant.json +110 -0
  4. data/test.jsonl +30 -0
LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ See the full Apache-2.0 text at https://www.apache.org/licenses/LICENSE-2.0.txt
18
+
19
+ Copyright (c) 2026 Anonymous (double-blind submission, NeurIPS 2026 E&D Track).
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pretty_name: Linalg-Spec-30
6
+ size_categories:
7
+ - n<1K
8
+ task_categories:
9
+ - text-generation
10
+ - text2text-generation
11
+ tags:
12
+ - mlir
13
+ - code-generation
14
+ - compiler
15
+ - constrained-decoding
16
+ - linalg
17
+ - memref
18
+ configs:
19
+ - config_name: default
20
+ data_files:
21
+ - split: test
22
+ path: data/test.jsonl
23
+ ---
24
+
25
+ # Linalg-Spec-30
26
+
27
+ Hand-authored NL→MLIR pairs for linalg named ops under memref semantics (n=30).
28
+
29
+ This dataset is one of six NL→MLIR benchmarks released alongside the NeurIPS
30
+ 2026 Evaluations & Datasets track paper *Cross-Dialect Generalization Without
31
+ Retraining: Benchmarks and Evaluation of Schema-Derived Constrained Decoding
32
+ for MLIR* (anonymous submission). The full suite — `MLIR-Spec-150`,
33
+ `Linalg-Spec-30`, `StableHLO-Spec-30`, `StableHLO-Held-Out-200`,
34
+ `StableHLO-OutOfGrammar-25`, and `MLIR-Functional-Reference-30` — totals 465
35
+ instances across three MLIR dialects.
36
+
37
+ ## Composition
38
+
39
+ - **Instances**: 30
40
+ - **Format**: one JSON record per line in `data/test.jsonl`
41
+ - **Schema**: fields = `dialect`, `difficulty`, `id`, `mlir`, `nl`, `notes`
42
+ - **Verifier**: `mlir-opt --verify-diagnostics` against pinned LLVM 19.1.7
43
+ - **License**: Apache-2.0 (SPDX: Apache-2.0). No third-party IP restrictions.
44
+
45
+ ## Loading
46
+
47
+ ```python
48
+ from datasets import load_dataset
49
+ ds = load_dataset("plawanrath/Linalg-Spec-30", split="test")
50
+ print(ds[0])
51
+ ```
52
+
53
+ Each record is a self-contained natural-language→MLIR pair; verify-valid
54
+ pass-rate under the dialect's verifier is the primary evaluation metric.
55
+
56
+ ## Source format
57
+
58
+ For paper reproducibility, individual per-record JSON files (the
59
+ `examples/*.json` layout used by the companion code repository) and the
60
+ MLCommons Croissant 1.0 metadata (`croissant.json`) ship together with the
61
+ release. The JSONL file at `data/test.jsonl` is the canonical HuggingFace
62
+ interface; it is generated 1-to-1 from the source records.
63
+
64
+ ## Datasheet
65
+
66
+ A full Gebru-style datasheet covering motivation, collection, preprocessing,
67
+ uses, distribution, and maintenance is included in the companion
68
+ reproducibility archive (`docs/datasheets/datasheet.md`). Key points:
69
+
70
+ - All reference MLIR programs are verifier-clean at the time of release.
71
+ - Hand-authored single-author (no crowdsourcing, no LLM-authored references).
72
+ - Test-only — fine-tuning on these benchmarks contaminates future evaluation
73
+ and is explicitly out of scope.
74
+
75
+ ## Companion artifacts
76
+
77
+ - Reproducibility archive (code + scripts): `submission_artifact.tar.gz`
78
+ in the OpenReview attachment / Zenodo mirror.
79
+ - Companion code repository: <will be populated at camera-ready>.
80
+
81
+ ## Citation
82
+
83
+ ```
84
+ @inproceedings{anonymous2026crossdialect,
85
+ title = {Cross-Dialect Generalization Without Retraining: Benchmarks and Evaluation of Schema-Derived Constrained Decoding for MLIR},
86
+ author = {Anonymous},
87
+ booktitle = {Advances in Neural Information Processing Systems (NeurIPS), Datasets and Benchmarks Track},
88
+ year = {2026},
89
+ note = {Anonymous submission under review.}
90
+ }
91
+ ```
92
+
93
+ ## License
94
+
95
+ Apache-2.0. See `LICENSE`.
croissant.json ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "@context": {
3
+ "@language": "en",
4
+ "@vocab": "https://schema.org/",
5
+ "sc": "https://schema.org/",
6
+ "cr": "http://mlcommons.org/croissant/",
7
+ "rai": "http://mlcommons.org/croissant/RAI/",
8
+ "dct": "http://purl.org/dc/terms/",
9
+ "data": {
10
+ "@id": "cr:data",
11
+ "@type": "@json"
12
+ },
13
+ "dataType": {
14
+ "@id": "cr:dataType",
15
+ "@type": "@vocab"
16
+ },
17
+ "examples": {
18
+ "@id": "cr:examples",
19
+ "@type": "@json"
20
+ }
21
+ },
22
+ "@type": "sc:Dataset",
23
+ "name": "Linalg-Spec-30",
24
+ "description": "Hand-authored NL\u2192MLIR pairs for linalg named ops under memref semantics (matmul, matvec, fill, copy, transpose, broadcast, add, sub, mul, div, exp, abs).",
25
+ "conformsTo": "http://mlcommons.org/croissant/1.0",
26
+ "license": "https://spdx.org/licenses/Apache-2.0.html",
27
+ "version": "1.0.0",
28
+ "datePublished": "2026-04-21",
29
+ "citeAs": "(anonymous submission to NeurIPS 2026 E&D track)",
30
+ "url": "<populated-at-camera-ready>",
31
+ "distribution": [
32
+ {
33
+ "@type": "cr:FileObject",
34
+ "@id": "Linalg-Spec-30-archive",
35
+ "name": "Linalg-Spec-30.zip",
36
+ "contentUrl": "<populated-at-camera-ready>",
37
+ "encodingFormat": "application/zip",
38
+ "sha256": "<populated-at-camera-ready>"
39
+ }
40
+ ],
41
+ "recordSet": [
42
+ {
43
+ "@type": "cr:RecordSet",
44
+ "@id": "records",
45
+ "name": "records",
46
+ "description": "One MLIR prompt/reference pair per record.",
47
+ "field": [
48
+ {
49
+ "@type": "cr:Field",
50
+ "@id": "records/id",
51
+ "name": "id",
52
+ "dataType": "sc:Text",
53
+ "description": "Unique record identifier."
54
+ },
55
+ {
56
+ "@type": "cr:Field",
57
+ "@id": "records/nl",
58
+ "name": "nl",
59
+ "dataType": "sc:Text",
60
+ "description": "Natural-language description."
61
+ },
62
+ {
63
+ "@type": "cr:Field",
64
+ "@id": "records/mlir",
65
+ "name": "mlir",
66
+ "dataType": "sc:Text",
67
+ "description": "Reference MLIR that verifies under mlir-opt/iree-compile."
68
+ },
69
+ {
70
+ "@type": "cr:Field",
71
+ "@id": "records/dialect",
72
+ "name": "dialect",
73
+ "dataType": "sc:Text",
74
+ "description": "MLIR dialect of the reference program."
75
+ },
76
+ {
77
+ "@type": "cr:Field",
78
+ "@id": "records/difficulty",
79
+ "name": "difficulty",
80
+ "dataType": "sc:Text",
81
+ "description": "Author-assigned difficulty or 'programmatic'."
82
+ }
83
+ ]
84
+ }
85
+ ],
86
+ "rai:dataCollection": "Hand-authored by the submitting author against the target MLIR dialect's ODS.",
87
+ "rai:dataBiases": [
88
+ "Author-curated: prompts reflect the submitting author's mental model of the target dialect; may under-represent op combinations not present in the spec examples.",
89
+ "No human-subject data; no PII; no demographic bias dimensions apply."
90
+ ],
91
+ "rai:dataLimitations": [
92
+ "Verify-valid pass-rate measures structural validity under mlir-opt/iree-compile, not functional correctness. Programs that pass the gate may still compute the wrong function.",
93
+ "English natural-language descriptions only.",
94
+ "Small n (30-200 prompts per dataset) yields CI half-widths of ~3-10pp at p=0.5."
95
+ ],
96
+ "rai:annotationsPerExample": 0,
97
+ "rai:annotationDemographics": "N/A \u2014 no human annotators.",
98
+ "rai:personalSensitiveInformation": "None.",
99
+ "rai:useCases": [
100
+ "Evaluating NL\u2192MLIR generation systems (constrained or unconstrained) under a verifier-based pass-rate metric."
101
+ ],
102
+ "rai:excludedUseCases": [
103
+ "Evaluating functional correctness without an additional lowering + execution harness.",
104
+ "Training or fine-tuning production code-generation models without a separate held-out corpus."
105
+ ],
106
+ "extra": {
107
+ "size": 30,
108
+ "sampling": "Author-curated (single author), 12 linalg named ops."
109
+ }
110
+ }
data/test.jsonl ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "01_matmul-dynamic", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that performs a matrix multiplication of two 2-D f32 memrefs with dynamic shapes and writes the result into a pre-allocated output memref.", "mlir": "module {\n func.func @mm(%A: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) {\n linalg.matmul ins(%A, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>)\n return\n }\n}\n", "notes": "canonical linalg.matmul"}
2
+ {"id": "02_matmul-static-2x2", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that performs a 2x2 matrix multiplication of f32 matrices. All inputs are statically-shaped memrefs.", "mlir": "module {\n func.func @mm22(%A: memref<2x2xf32>, %B: memref<2x2xf32>, %C: memref<2x2xf32>) {\n linalg.matmul ins(%A, %B : memref<2x2xf32>, memref<2x2xf32>) outs(%C : memref<2x2xf32>)\n return\n }\n}\n", "notes": "static-shape matmul"}
3
+ {"id": "03_matmul-rectangular", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that multiplies a 4x8xf32 matrix by an 8x2xf32 matrix, writing to a 4x2xf32 result memref.", "mlir": "module {\n func.func @mm482(%A: memref<4x8xf32>, %B: memref<8x2xf32>, %C: memref<4x2xf32>) {\n linalg.matmul ins(%A, %B : memref<4x8xf32>, memref<8x2xf32>) outs(%C : memref<4x2xf32>)\n return\n }\n}\n", "notes": "rectangular MxK * KxN"}
4
+ {"id": "04_matmul-f64", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that performs matmul on two f64 2-D memrefs into an f64 output memref.", "mlir": "module {\n func.func @mmf64(%A: memref<?x?xf64>, %B: memref<?x?xf64>, %C: memref<?x?xf64>) {\n linalg.matmul ins(%A, %B : memref<?x?xf64>, memref<?x?xf64>) outs(%C : memref<?x?xf64>)\n return\n }\n}\n", "notes": "f64 matmul"}
5
+ {"id": "05_fill-matmul-chain", "dialect": "linalg+memref+arith+func", "difficulty": "hard", "nl": "Write a function that zeroes an f32 output memref using linalg.fill, then computes matmul of two input memrefs into it.", "mlir": "module {\n func.func @fm(%A: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) {\n %z = arith.constant 0.0 : f32\n linalg.fill ins(%z : f32) outs(%C : memref<?x?xf32>)\n linalg.matmul ins(%A, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>)\n return\n }\n}\n", "notes": "zero-then-matmul idiom"}
6
+ {"id": "06_fill-zero-1d", "dialect": "linalg+memref+arith+func", "difficulty": "easy", "nl": "Write a function that fills a 1-D f32 memref with zeros.", "mlir": "module {\n func.func @f0(%m: memref<?xf32>) {\n %z = arith.constant 0.0 : f32\n linalg.fill ins(%z : f32) outs(%m : memref<?xf32>)\n return\n }\n}\n", "notes": "zero-fill 1D"}
7
+ {"id": "07_fill-value-param", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that fills a 2-D f32 memref with a given f32 value passed as a parameter.", "mlir": "module {\n func.func @fp(%v: f32, %m: memref<?x?xf32>) {\n linalg.fill ins(%v : f32) outs(%m : memref<?x?xf32>)\n return\n }\n}\n", "notes": "fill with parameter value"}
8
+ {"id": "08_fill-i32", "dialect": "linalg+memref+arith+func", "difficulty": "easy", "nl": "Write a function that fills a 1-D i32 memref with the integer constant 7.", "mlir": "module {\n func.func @f7(%m: memref<?xi32>) {\n %c7 = arith.constant 7 : i32\n linalg.fill ins(%c7 : i32) outs(%m : memref<?xi32>)\n return\n }\n}\n", "notes": "integer-typed fill"}
9
+ {"id": "09_copy-1d", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that copies a 1-D f32 memref into another 1-D f32 memref of the same shape.", "mlir": "module {\n func.func @c1(%s: memref<?xf32>, %d: memref<?xf32>) {\n linalg.copy ins(%s : memref<?xf32>) outs(%d : memref<?xf32>)\n return\n }\n}\n", "notes": "1D copy"}
10
+ {"id": "10_copy-2d-static", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that copies a 4x4xf32 static memref into another 4x4xf32 memref.", "mlir": "module {\n func.func @c2(%s: memref<4x4xf32>, %d: memref<4x4xf32>) {\n linalg.copy ins(%s : memref<4x4xf32>) outs(%d : memref<4x4xf32>)\n return\n }\n}\n", "notes": "2D static copy"}
11
+ {"id": "11_copy-i32", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that copies a 1-D i32 memref into another 1-D i32 memref of the same shape.", "mlir": "module {\n func.func @ci(%s: memref<?xi32>, %d: memref<?xi32>) {\n linalg.copy ins(%s : memref<?xi32>) outs(%d : memref<?xi32>)\n return\n }\n}\n", "notes": "i32 copy"}
12
+ {"id": "12_transpose-2d", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that transposes a 2-D f32 memref into another 2-D f32 memref using permutation [1, 0].", "mlir": "module {\n func.func @t2(%s: memref<?x?xf32>, %d: memref<?x?xf32>) {\n linalg.transpose ins(%s : memref<?x?xf32>) outs(%d : memref<?x?xf32>) permutation = [1, 0]\n return\n }\n}\n", "notes": "2D transpose"}
13
+ {"id": "13_transpose-3d", "dialect": "linalg+memref+func", "difficulty": "hard", "nl": "Write a function that transposes a 3-D f32 memref using permutation [0, 2, 1] (swap the last two dimensions).", "mlir": "module {\n func.func @t3(%s: memref<?x?x?xf32>, %d: memref<?x?x?xf32>) {\n linalg.transpose ins(%s : memref<?x?x?xf32>) outs(%d : memref<?x?x?xf32>) permutation = [0, 2, 1]\n return\n }\n}\n", "notes": "3D transpose"}
14
+ {"id": "14_transpose-static", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that transposes a 3x5xf32 memref to a 5x3xf32 memref using permutation [1, 0].", "mlir": "module {\n func.func @ts(%s: memref<3x5xf32>, %d: memref<5x3xf32>) {\n linalg.transpose ins(%s : memref<3x5xf32>) outs(%d : memref<5x3xf32>) permutation = [1, 0]\n return\n }\n}\n", "notes": "static-shape transpose"}
15
+ {"id": "15_broadcast-1d-to-2d", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that broadcasts a 1-D f32 memref to a 2-D f32 memref along the 0th dimension.", "mlir": "module {\n func.func @b1(%s: memref<?xf32>, %d: memref<?x?xf32>) {\n linalg.broadcast ins(%s : memref<?xf32>) outs(%d : memref<?x?xf32>) dimensions = [0]\n return\n }\n}\n", "notes": "1D to 2D broadcast, dim 0"}
16
+ {"id": "16_broadcast-dim1", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that broadcasts a 1-D f32 memref to a 2-D f32 memref along the 1st dimension.", "mlir": "module {\n func.func @b2(%s: memref<?xf32>, %d: memref<?x?xf32>) {\n linalg.broadcast ins(%s : memref<?xf32>) outs(%d : memref<?x?xf32>) dimensions = [1]\n return\n }\n}\n", "notes": "1D to 2D broadcast, dim 1"}
17
+ {"id": "17_matvec", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that performs a matrix-vector multiplication: input is a 2-D f32 memref and a 1-D f32 memref; output is a 1-D f32 memref.", "mlir": "module {\n func.func @mv(%A: memref<?x?xf32>, %x: memref<?xf32>, %y: memref<?xf32>) {\n linalg.matvec ins(%A, %x : memref<?x?xf32>, memref<?xf32>) outs(%y : memref<?xf32>)\n return\n }\n}\n", "notes": "canonical matvec"}
18
+ {"id": "18_matvec-static", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that multiplies a 4x8xf32 matrix by an 8xf32 vector, writing to a 4xf32 result memref.", "mlir": "module {\n func.func @mvs(%A: memref<4x8xf32>, %x: memref<8xf32>, %y: memref<4xf32>) {\n linalg.matvec ins(%A, %x : memref<4x8xf32>, memref<8xf32>) outs(%y : memref<4xf32>)\n return\n }\n}\n", "notes": "static matvec 4x8 by 8"}
19
+ {"id": "19_matvec-f64", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that performs a matvec on f64 inputs.", "mlir": "module {\n func.func @mvd(%A: memref<?x?xf64>, %x: memref<?xf64>, %y: memref<?xf64>) {\n linalg.matvec ins(%A, %x : memref<?x?xf64>, memref<?xf64>) outs(%y : memref<?xf64>)\n return\n }\n}\n", "notes": "f64 matvec"}
20
+ {"id": "20_add-elemwise", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that adds two 1-D f32 memrefs element-wise into a third output memref.", "mlir": "module {\n func.func @ae(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) {\n linalg.add ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>)\n return\n }\n}\n", "notes": "elemwise add"}
21
+ {"id": "21_sub-elemwise", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that subtracts two 1-D f32 memrefs element-wise.", "mlir": "module {\n func.func @se(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) {\n linalg.sub ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>)\n return\n }\n}\n", "notes": "elemwise sub"}
22
+ {"id": "22_mul-elemwise-2d", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that multiplies two 2-D f32 memrefs element-wise (Hadamard product) into an output memref.", "mlir": "module {\n func.func @me(%a: memref<?x?xf32>, %b: memref<?x?xf32>, %c: memref<?x?xf32>) {\n linalg.mul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>) outs(%c : memref<?x?xf32>)\n return\n }\n}\n", "notes": "Hadamard product"}
23
+ {"id": "23_div-elemwise", "dialect": "linalg+memref+func", "difficulty": "medium", "nl": "Write a function that divides two 1-D f32 memrefs element-wise.", "mlir": "module {\n func.func @de(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) {\n linalg.div ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>)\n return\n }\n}\n", "notes": "elemwise div"}
24
+ {"id": "24_exp-elemwise", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that applies the elementwise exponential to a 1-D f32 memref, writing the result into another memref.", "mlir": "module {\n func.func @ee(%x: memref<?xf32>, %y: memref<?xf32>) {\n linalg.exp ins(%x : memref<?xf32>) outs(%y : memref<?xf32>)\n return\n }\n}\n", "notes": "elemwise exp"}
25
+ {"id": "25_exp-2d", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that applies elementwise exp to a 2-D f32 memref, writing into an output memref of the same shape.", "mlir": "module {\n func.func @e2(%x: memref<?x?xf32>, %y: memref<?x?xf32>) {\n linalg.exp ins(%x : memref<?x?xf32>) outs(%y : memref<?x?xf32>)\n return\n }\n}\n", "notes": "2D exp"}
26
+ {"id": "26_abs-elemwise", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that applies the elementwise absolute value to a 1-D f32 memref, writing the result into another memref.", "mlir": "module {\n func.func @ae(%x: memref<?xf32>, %y: memref<?xf32>) {\n linalg.abs ins(%x : memref<?xf32>) outs(%y : memref<?xf32>)\n return\n }\n}\n", "notes": "elemwise abs"}
27
+ {"id": "27_abs-2d", "dialect": "linalg+memref+func", "difficulty": "easy", "nl": "Write a function that applies elementwise abs to a 2-D f32 memref.", "mlir": "module {\n func.func @a2(%x: memref<?x?xf32>, %y: memref<?x?xf32>) {\n linalg.abs ins(%x : memref<?x?xf32>) outs(%y : memref<?x?xf32>)\n return\n }\n}\n", "notes": "2D abs"}
28
+ {"id": "28_fill-then-copy", "dialect": "linalg+memref+arith+func", "difficulty": "hard", "nl": "Write a function that fills a 1-D f32 memref with 1.0 and then copies its contents into a second memref.", "mlir": "module {\n func.func @fc(%m: memref<?xf32>, %d: memref<?xf32>) {\n %one = arith.constant 1.0 : f32\n linalg.fill ins(%one : f32) outs(%m : memref<?xf32>)\n linalg.copy ins(%m : memref<?xf32>) outs(%d : memref<?xf32>)\n return\n }\n}\n", "notes": "fill-then-copy chain"}
29
+ {"id": "29_add-then-exp", "dialect": "linalg+memref+func", "difficulty": "hard", "nl": "Write a function that adds two 1-D f32 memrefs element-wise into a temporary buffer, then applies exp to the buffer into the final output.", "mlir": "module {\n func.func @ax(%a: memref<?xf32>, %b: memref<?xf32>, %t: memref<?xf32>, %y: memref<?xf32>) {\n linalg.add ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%t : memref<?xf32>)\n linalg.exp ins(%t : memref<?xf32>) outs(%y : memref<?xf32>)\n return\n }\n}\n", "notes": "add-then-exp chain"}
30
+ {"id": "30_transpose-then-matmul", "dialect": "linalg+memref+func", "difficulty": "hard", "nl": "Write a function that transposes A (2-D f32) into a temp memref and then performs matmul of transposed A and B.", "mlir": "module {\n func.func @tm(%A: memref<?x?xf32>, %At: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) {\n linalg.transpose ins(%A : memref<?x?xf32>) outs(%At : memref<?x?xf32>) permutation = [1, 0]\n linalg.matmul ins(%At, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>)\n return\n }\n}\n", "notes": "transpose-then-matmul"}