Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
9
24
dialect
stringclasses
2 values
difficulty
stringclasses
3 values
nl
stringlengths
54
155
mlir
stringlengths
131
318
notes
stringlengths
6
25
01_matmul-dynamic
linalg+memref+func
easy
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.
module { func.func @mm(%A: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) { linalg.matmul ins(%A, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>) return } }
canonical linalg.matmul
02_matmul-static-2x2
linalg+memref+func
easy
Write a function that performs a 2x2 matrix multiplication of f32 matrices. All inputs are statically-shaped memrefs.
module { func.func @mm22(%A: memref<2x2xf32>, %B: memref<2x2xf32>, %C: memref<2x2xf32>) { linalg.matmul ins(%A, %B : memref<2x2xf32>, memref<2x2xf32>) outs(%C : memref<2x2xf32>) return } }
static-shape matmul
03_matmul-rectangular
linalg+memref+func
medium
Write a function that multiplies a 4x8xf32 matrix by an 8x2xf32 matrix, writing to a 4x2xf32 result memref.
module { func.func @mm482(%A: memref<4x8xf32>, %B: memref<8x2xf32>, %C: memref<4x2xf32>) { linalg.matmul ins(%A, %B : memref<4x8xf32>, memref<8x2xf32>) outs(%C : memref<4x2xf32>) return } }
rectangular MxK * KxN
04_matmul-f64
linalg+memref+func
medium
Write a function that performs matmul on two f64 2-D memrefs into an f64 output memref.
module { func.func @mmf64(%A: memref<?x?xf64>, %B: memref<?x?xf64>, %C: memref<?x?xf64>) { linalg.matmul ins(%A, %B : memref<?x?xf64>, memref<?x?xf64>) outs(%C : memref<?x?xf64>) return } }
f64 matmul
05_fill-matmul-chain
linalg+memref+arith+func
hard
Write a function that zeroes an f32 output memref using linalg.fill, then computes matmul of two input memrefs into it.
module { func.func @fm(%A: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) { %z = arith.constant 0.0 : f32 linalg.fill ins(%z : f32) outs(%C : memref<?x?xf32>) linalg.matmul ins(%A, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>) return } }
zero-then-matmul idiom
06_fill-zero-1d
linalg+memref+arith+func
easy
Write a function that fills a 1-D f32 memref with zeros.
module { func.func @f0(%m: memref<?xf32>) { %z = arith.constant 0.0 : f32 linalg.fill ins(%z : f32) outs(%m : memref<?xf32>) return } }
zero-fill 1D
07_fill-value-param
linalg+memref+func
easy
Write a function that fills a 2-D f32 memref with a given f32 value passed as a parameter.
module { func.func @fp(%v: f32, %m: memref<?x?xf32>) { linalg.fill ins(%v : f32) outs(%m : memref<?x?xf32>) return } }
fill with parameter value
08_fill-i32
linalg+memref+arith+func
easy
Write a function that fills a 1-D i32 memref with the integer constant 7.
module { func.func @f7(%m: memref<?xi32>) { %c7 = arith.constant 7 : i32 linalg.fill ins(%c7 : i32) outs(%m : memref<?xi32>) return } }
integer-typed fill
09_copy-1d
linalg+memref+func
easy
Write a function that copies a 1-D f32 memref into another 1-D f32 memref of the same shape.
module { func.func @c1(%s: memref<?xf32>, %d: memref<?xf32>) { linalg.copy ins(%s : memref<?xf32>) outs(%d : memref<?xf32>) return } }
1D copy
10_copy-2d-static
linalg+memref+func
easy
Write a function that copies a 4x4xf32 static memref into another 4x4xf32 memref.
module { func.func @c2(%s: memref<4x4xf32>, %d: memref<4x4xf32>) { linalg.copy ins(%s : memref<4x4xf32>) outs(%d : memref<4x4xf32>) return } }
2D static copy
11_copy-i32
linalg+memref+func
easy
Write a function that copies a 1-D i32 memref into another 1-D i32 memref of the same shape.
module { func.func @ci(%s: memref<?xi32>, %d: memref<?xi32>) { linalg.copy ins(%s : memref<?xi32>) outs(%d : memref<?xi32>) return } }
i32 copy
12_transpose-2d
linalg+memref+func
medium
Write a function that transposes a 2-D f32 memref into another 2-D f32 memref using permutation [1, 0].
module { func.func @t2(%s: memref<?x?xf32>, %d: memref<?x?xf32>) { linalg.transpose ins(%s : memref<?x?xf32>) outs(%d : memref<?x?xf32>) permutation = [1, 0] return } }
2D transpose
13_transpose-3d
linalg+memref+func
hard
Write a function that transposes a 3-D f32 memref using permutation [0, 2, 1] (swap the last two dimensions).
module { func.func @t3(%s: memref<?x?x?xf32>, %d: memref<?x?x?xf32>) { linalg.transpose ins(%s : memref<?x?x?xf32>) outs(%d : memref<?x?x?xf32>) permutation = [0, 2, 1] return } }
3D transpose
14_transpose-static
linalg+memref+func
medium
Write a function that transposes a 3x5xf32 memref to a 5x3xf32 memref using permutation [1, 0].
module { func.func @ts(%s: memref<3x5xf32>, %d: memref<5x3xf32>) { linalg.transpose ins(%s : memref<3x5xf32>) outs(%d : memref<5x3xf32>) permutation = [1, 0] return } }
static-shape transpose
15_broadcast-1d-to-2d
linalg+memref+func
medium
Write a function that broadcasts a 1-D f32 memref to a 2-D f32 memref along the 0th dimension.
module { func.func @b1(%s: memref<?xf32>, %d: memref<?x?xf32>) { linalg.broadcast ins(%s : memref<?xf32>) outs(%d : memref<?x?xf32>) dimensions = [0] return } }
1D to 2D broadcast, dim 0
16_broadcast-dim1
linalg+memref+func
medium
Write a function that broadcasts a 1-D f32 memref to a 2-D f32 memref along the 1st dimension.
module { func.func @b2(%s: memref<?xf32>, %d: memref<?x?xf32>) { linalg.broadcast ins(%s : memref<?xf32>) outs(%d : memref<?x?xf32>) dimensions = [1] return } }
1D to 2D broadcast, dim 1
17_matvec
linalg+memref+func
medium
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.
module { func.func @mv(%A: memref<?x?xf32>, %x: memref<?xf32>, %y: memref<?xf32>) { linalg.matvec ins(%A, %x : memref<?x?xf32>, memref<?xf32>) outs(%y : memref<?xf32>) return } }
canonical matvec
18_matvec-static
linalg+memref+func
medium
Write a function that multiplies a 4x8xf32 matrix by an 8xf32 vector, writing to a 4xf32 result memref.
module { func.func @mvs(%A: memref<4x8xf32>, %x: memref<8xf32>, %y: memref<4xf32>) { linalg.matvec ins(%A, %x : memref<4x8xf32>, memref<8xf32>) outs(%y : memref<4xf32>) return } }
static matvec 4x8 by 8
19_matvec-f64
linalg+memref+func
medium
Write a function that performs a matvec on f64 inputs.
module { func.func @mvd(%A: memref<?x?xf64>, %x: memref<?xf64>, %y: memref<?xf64>) { linalg.matvec ins(%A, %x : memref<?x?xf64>, memref<?xf64>) outs(%y : memref<?xf64>) return } }
f64 matvec
20_add-elemwise
linalg+memref+func
easy
Write a function that adds two 1-D f32 memrefs element-wise into a third output memref.
module { func.func @ae(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) { linalg.add ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>) return } }
elemwise add
21_sub-elemwise
linalg+memref+func
easy
Write a function that subtracts two 1-D f32 memrefs element-wise.
module { func.func @se(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) { linalg.sub ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>) return } }
elemwise sub
22_mul-elemwise-2d
linalg+memref+func
medium
Write a function that multiplies two 2-D f32 memrefs element-wise (Hadamard product) into an output memref.
module { func.func @me(%a: memref<?x?xf32>, %b: memref<?x?xf32>, %c: memref<?x?xf32>) { linalg.mul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>) outs(%c : memref<?x?xf32>) return } }
Hadamard product
23_div-elemwise
linalg+memref+func
medium
Write a function that divides two 1-D f32 memrefs element-wise.
module { func.func @de(%a: memref<?xf32>, %b: memref<?xf32>, %c: memref<?xf32>) { linalg.div ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%c : memref<?xf32>) return } }
elemwise div
24_exp-elemwise
linalg+memref+func
easy
Write a function that applies the elementwise exponential to a 1-D f32 memref, writing the result into another memref.
module { func.func @ee(%x: memref<?xf32>, %y: memref<?xf32>) { linalg.exp ins(%x : memref<?xf32>) outs(%y : memref<?xf32>) return } }
elemwise exp
25_exp-2d
linalg+memref+func
easy
Write a function that applies elementwise exp to a 2-D f32 memref, writing into an output memref of the same shape.
module { func.func @e2(%x: memref<?x?xf32>, %y: memref<?x?xf32>) { linalg.exp ins(%x : memref<?x?xf32>) outs(%y : memref<?x?xf32>) return } }
2D exp
26_abs-elemwise
linalg+memref+func
easy
Write a function that applies the elementwise absolute value to a 1-D f32 memref, writing the result into another memref.
module { func.func @ae(%x: memref<?xf32>, %y: memref<?xf32>) { linalg.abs ins(%x : memref<?xf32>) outs(%y : memref<?xf32>) return } }
elemwise abs
27_abs-2d
linalg+memref+func
easy
Write a function that applies elementwise abs to a 2-D f32 memref.
module { func.func @a2(%x: memref<?x?xf32>, %y: memref<?x?xf32>) { linalg.abs ins(%x : memref<?x?xf32>) outs(%y : memref<?x?xf32>) return } }
2D abs
28_fill-then-copy
linalg+memref+arith+func
hard
Write a function that fills a 1-D f32 memref with 1.0 and then copies its contents into a second memref.
module { func.func @fc(%m: memref<?xf32>, %d: memref<?xf32>) { %one = arith.constant 1.0 : f32 linalg.fill ins(%one : f32) outs(%m : memref<?xf32>) linalg.copy ins(%m : memref<?xf32>) outs(%d : memref<?xf32>) return } }
fill-then-copy chain
29_add-then-exp
linalg+memref+func
hard
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.
module { func.func @ax(%a: memref<?xf32>, %b: memref<?xf32>, %t: memref<?xf32>, %y: memref<?xf32>) { linalg.add ins(%a, %b : memref<?xf32>, memref<?xf32>) outs(%t : memref<?xf32>) linalg.exp ins(%t : memref<?xf32>) outs(%y : memref<?xf32>) return } }
add-then-exp chain
30_transpose-then-matmul
linalg+memref+func
hard
Write a function that transposes A (2-D f32) into a temp memref and then performs matmul of transposed A and B.
module { func.func @tm(%A: memref<?x?xf32>, %At: memref<?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) { linalg.transpose ins(%A : memref<?x?xf32>) outs(%At : memref<?x?xf32>) permutation = [1, 0] linalg.matmul ins(%At, %B : memref<?x?xf32>, memref<?x?xf32>) outs(%C : memref<?x?xf32>) return } }
transpose-then-matmul

Linalg-Spec-30

Accepted to NeurIPS 2026 (Evaluations & Datasets Track)
Paper (arXiv) · Code (GitHub) · All six datasets (collection)

Hand-authored NL→MLIR pairs for linalg named ops under memref semantics (n=30).

This dataset is part of the suite released with the NeurIPS 2026 Evaluations & Datasets Track paper Cross-Dialect Generalization Without Retraining: Benchmarks and Evaluation of Schema-Derived Constrained Decoding for MLIR (arXiv:2607.18254): four NL→MLIR benchmarks (MLIR-Spec-150, Linalg-Spec-30, StableHLO-Spec-30, StableHLO-Held-Out-200) and the StableHLO-OutOfGrammar-25 stress set, 435 benchmark instances across three MLIR dialects, plus MLIR-Functional-Reference-30, which attaches hand-authored inputs and expected outputs to 30 existing Spec prompts (no new prompts).

Composition

  • Instances: 30
  • Format: one JSON record per line in data/test.jsonl
  • Schema: fields = dialect, difficulty, id, mlir, nl, notes
  • Verifier: mlir-opt --verify-diagnostics against pinned LLVM 19.1.7
  • License: Apache-2.0 (SPDX: Apache-2.0). No third-party IP restrictions.

Loading

from datasets import load_dataset
ds = load_dataset("plawanrath/Linalg-Spec-30", split="test")
print(ds[0])

Each record is a self-contained natural-language→MLIR pair; verify-valid pass-rate under the dialect's verifier is the primary evaluation metric.

Source format

The JSONL file at data/test.jsonl is the canonical HuggingFace interface. It is exported 1-to-1 from the source records (examples/*.json) in eval/benchmarks/linalg_spec_30/ of the code repository.

Datasheet

Key points (full Gebru-style datasheet: docs/datasheets/datasheet.md):

  • All reference MLIR programs are verifier-clean at the time of release.
  • Hand-authored (no crowdsourcing, no LLM-authored references).
  • Test-only — fine-tuning on these benchmarks contaminates future evaluation and is explicitly out of scope.

Croissant metadata

croissant.json in this repository is the dataset's MLCommons Croissant 1.1 metadata, including the Responsible AI (rai:) and provenance (prov:) fields required by the NeurIPS 2026 Evaluations & Datasets Track. (Hugging Face's auto-generated Croissant endpoint covers the core fields only.)

Code

Generation, verification and evaluation code: github.com/plawanrath/slm-to-mlir-constrained-emitter.

Citation

@inproceedings{rath2026crossdialect,
  title     = {Cross-Dialect Generalization Without Retraining: Benchmarks and Evaluation of Schema-Derived Constrained Decoding for {MLIR}},
  author    = {Rath, Plawan Kumar},
  booktitle = {Advances in Neural Information Processing Systems (NeurIPS), Evaluations and Datasets Track},
  year      = {2026},
  eprint    = {2607.18254},
  archivePrefix = {arXiv}
}

License

Apache-2.0 (see LICENSE). Copyright 2026 Plawan Kumar Rath.

Disclaimer

Plawan Kumar Rath (@plawanrath). This work was conducted in the author's personal capacity. The views expressed here are those of the author and do not necessarily reflect the views of Meta.

Downloads last month
104

Collection including plawanrath/Linalg-Spec-30

Paper for plawanrath/Linalg-Spec-30