Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
9
29
difficulty
stringclasses
3 values
nl
stringlengths
50
126
mlir
stringlengths
144
340
notes
stringlengths
3
23
dialect
stringclasses
1 value
01_add-1d
easy
Write a function that adds two 1-D f32 tensors of 16 elements using stablehlo.add.
module { func.func @a(%a: tensor<16xf32>, %b: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.add %a, %b : tensor<16xf32> return %0 : tensor<16xf32> } }
canonical stablehlo.add
stablehlo+func
02_add-2d-dynamic
easy
Write a function that adds two 2-D f32 tensors with dynamic shapes and returns the result.
module { func.func @add2d(%a: tensor<?x?xf32>, %b: tensor<?x?xf32>) -> tensor<?x?xf32> { %0 = stablehlo.add %a, %b : tensor<?x?xf32> return %0 : tensor<?x?xf32> } }
dynamic-shape addition
stablehlo+func
03_subtract-1d-i32
easy
Write a function that subtracts two 1-D i32 tensors elementwise.
module { func.func @sub(%a: tensor<8xi32>, %b: tensor<8xi32>) -> tensor<8xi32> { %0 = stablehlo.subtract %a, %b : tensor<8xi32> return %0 : tensor<8xi32> } }
integer subtraction
stablehlo+func
04_multiply-2d
easy
Write a function that multiplies two 4x4 f32 tensors elementwise using stablehlo.multiply.
module { func.func @mul(%a: tensor<4x4xf32>, %b: tensor<4x4xf32>) -> tensor<4x4xf32> { %0 = stablehlo.multiply %a, %b : tensor<4x4xf32> return %0 : tensor<4x4xf32> } }
static 4x4 multiply
stablehlo+func
05_divide-f64
easy
Write a function that divides two 1-D f64 tensors of 32 elements using stablehlo.divide.
module { func.func @div(%a: tensor<32xf64>, %b: tensor<32xf64>) -> tensor<32xf64> { %0 = stablehlo.divide %a, %b : tensor<32xf64> return %0 : tensor<32xf64> } }
f64 division
stablehlo+func
06_abs-f32
easy
Write a function that computes the elementwise absolute value of a 1-D f32 tensor.
module { func.func @ab(%a: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.abs %a : tensor<16xf32> return %0 : tensor<16xf32> } }
abs
stablehlo+func
07_exp-1d
easy
Write a function that computes the elementwise exponential of a 1-D f32 tensor of 10 elements.
module { func.func @ex(%a: tensor<10xf32>) -> tensor<10xf32> { %0 = stablehlo.exponential %a : tensor<10xf32> return %0 : tensor<10xf32> } }
exp
stablehlo+func
08_abs-dynamic
medium
Write a function that computes the elementwise absolute value of a dynamic-shape 2-D f32 tensor.
module { func.func @abd(%a: tensor<?x?xf32>) -> tensor<?x?xf32> { %0 = stablehlo.abs %a : tensor<?x?xf32> return %0 : tensor<?x?xf32> } }
dynamic abs
stablehlo+func
09_transpose-2d
medium
Write a function that transposes a 4x8 f32 tensor producing an 8x4 tensor.
module { func.func @t(%a: tensor<4x8xf32>) -> tensor<8x4xf32> { %0 = stablehlo.transpose %a, dims = [1, 0] : (tensor<4x8xf32>) -> tensor<8x4xf32> return %0 : tensor<8x4xf32> } }
transpose 2D
stablehlo+func
10_transpose-3d
medium
Write a function that transposes a 2x3x4 f32 tensor with permutation [2, 0, 1] producing a 4x2x3 tensor.
module { func.func @t3(%a: tensor<2x3x4xf32>) -> tensor<4x2x3xf32> { %0 = stablehlo.transpose %a, dims = [2, 0, 1] : (tensor<2x3x4xf32>) -> tensor<4x2x3xf32> return %0 : tensor<4x2x3xf32> } }
3D transpose
stablehlo+func
11_transpose-square
easy
Write a function that transposes a 3x3 f32 tensor.
module { func.func @t(%a: tensor<3x3xf32>) -> tensor<3x3xf32> { %0 = stablehlo.transpose %a, dims = [1, 0] : (tensor<3x3xf32>) -> tensor<3x3xf32> return %0 : tensor<3x3xf32> } }
square transpose
stablehlo+func
12_broadcast-1d-to-2d
medium
Write a function that broadcasts a 1-D f32 tensor of 8 elements to a 4x8 2-D tensor along dimension 1.
module { func.func @b(%a: tensor<8xf32>) -> tensor<4x8xf32> { %0 = stablehlo.broadcast_in_dim %a, dims = [1] : (tensor<8xf32>) -> tensor<4x8xf32> return %0 : tensor<4x8xf32> } }
broadcast 1D to 2D
stablehlo+func
13_broadcast-scalar-to-vector
medium
Write a function that broadcasts a scalar f32 (shape [1]) to a 1-D f32 tensor of 16 elements.
module { func.func @bs(%a: tensor<1xf32>) -> tensor<16xf32> { %0 = stablehlo.broadcast_in_dim %a, dims = [0] : (tensor<1xf32>) -> tensor<16xf32> return %0 : tensor<16xf32> } }
scalar broadcast
stablehlo+func
14_reshape-flatten
medium
Write a function that flattens a 4x8 f32 tensor into a 1-D tensor of 32 elements.
module { func.func @r(%a: tensor<4x8xf32>) -> tensor<32xf32> { %0 = stablehlo.reshape %a : (tensor<4x8xf32>) -> tensor<32xf32> return %0 : tensor<32xf32> } }
flatten
stablehlo+func
15_reshape-2d-to-3d
medium
Write a function that reshapes a 12x8 f32 tensor into a 3x4x8 3-D tensor.
module { func.func @r(%a: tensor<12x8xf32>) -> tensor<3x4x8xf32> { %0 = stablehlo.reshape %a : (tensor<12x8xf32>) -> tensor<3x4x8xf32> return %0 : tensor<3x4x8xf32> } }
2D to 3D reshape
stablehlo+func
16_reshape-transpose-chain
hard
Write a function that flattens a 4x8 f32 tensor, then transposes the result — no wait, simpler: reshape a 4x8 tensor into 8x4.
module { func.func @r(%a: tensor<4x8xf32>) -> tensor<8x4xf32> { %0 = stablehlo.reshape %a : (tensor<4x8xf32>) -> tensor<8x4xf32> return %0 : tensor<8x4xf32> } }
reshape shape change
stablehlo+func
17_dot_general-matmul
medium
Write a function that performs a matrix multiplication of a 4x8 f32 tensor and an 8x16 f32 tensor using stablehlo.dot_general.
module { func.func @m(%a: tensor<4x8xf32>, %b: tensor<8x16xf32>) -> tensor<4x16xf32> { %0 = stablehlo.dot_general %a, %b, contracting_dims = [1] x [0] : (tensor<4x8xf32>, tensor<8x16xf32>) -> tensor<4x16xf32> return %0 : tensor<4x16xf32> } }
canonical matmul
stablehlo+func
18_dot_general-square
medium
Write a function that multiplies two 8x8 f32 tensors using stablehlo.dot_general.
module { func.func @m(%a: tensor<8x8xf32>, %b: tensor<8x8xf32>) -> tensor<8x8xf32> { %0 = stablehlo.dot_general %a, %b, contracting_dims = [1] x [0] : (tensor<8x8xf32>, tensor<8x8xf32>) -> tensor<8x8xf32> return %0 : tensor<8x8xf32> } }
square matmul
stablehlo+func
19_dot_general-tall-thin
medium
Multiply a 128x16 f32 tensor by a 16x4 f32 tensor using stablehlo.dot_general.
module { func.func @m(%a: tensor<128x16xf32>, %b: tensor<16x4xf32>) -> tensor<128x4xf32> { %0 = stablehlo.dot_general %a, %b, contracting_dims = [1] x [0] : (tensor<128x16xf32>, tensor<16x4xf32>) -> tensor<128x4xf32> return %0 : tensor<128x4xf32> } }
tall-thin matmul
stablehlo+func
20_add-multiply-chain
medium
Write a function that adds two 1-D f32 tensors and then multiplies the sum by the first input.
module { func.func @c(%a: tensor<16xf32>, %b: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.add %a, %b : tensor<16xf32> %1 = stablehlo.multiply %0, %a : tensor<16xf32> return %1 : tensor<16xf32> } }
add-then-multiply
stablehlo+func
21_abs-exp-chain
medium
Write a function that computes the exponential of the absolute value of a 1-D f32 tensor.
module { func.func @c(%a: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.abs %a : tensor<16xf32> %1 = stablehlo.exponential %0 : tensor<16xf32> return %1 : tensor<16xf32> } }
abs then exp
stablehlo+func
22_matmul-add-bias
hard
Matrix-multiply a 4x8 f32 tensor by an 8x16 f32 tensor, then add a 4x16 bias tensor.
module { func.func @lin(%a: tensor<4x8xf32>, %b: tensor<8x16xf32>, %bias: tensor<4x16xf32>) -> tensor<4x16xf32> { %0 = stablehlo.dot_general %a, %b, contracting_dims = [1] x [0] : (tensor<4x8xf32>, tensor<8x16xf32>) -> tensor<4x16xf32> %1 = stablehlo.add %0, %bias : tensor<4x16xf32> return %1 : tensor<4x1...
linear layer
stablehlo+func
23_transpose-matmul
hard
Transpose a 8x4 f32 tensor, then matrix-multiply the result with a 4x16 f32 tensor.
module { func.func @tm(%a: tensor<8x4xf32>, %b: tensor<8x16xf32>) -> tensor<4x16xf32> { %0 = stablehlo.transpose %a, dims = [1, 0] : (tensor<8x4xf32>) -> tensor<4x8xf32> %1 = stablehlo.dot_general %0, %b, contracting_dims = [1] x [0] : (tensor<4x8xf32>, tensor<8x16xf32>) -> tensor<4x16xf32> return %1 : te...
transpose+matmul
stablehlo+func
24_reshape-add
medium
Reshape a 4x4 f32 tensor into a 16-element 1-D tensor, then add to an existing 16-element tensor.
module { func.func @ra(%a: tensor<4x4xf32>, %b: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.reshape %a : (tensor<4x4xf32>) -> tensor<16xf32> %1 = stablehlo.add %0, %b : tensor<16xf32> return %1 : tensor<16xf32> } }
reshape+add
stablehlo+func
25_broadcast-multiply
hard
Broadcast a length-8 1-D f32 tensor to a 4x8 tensor, then multiply with an existing 4x8 tensor.
module { func.func @bm(%a: tensor<8xf32>, %b: tensor<4x8xf32>) -> tensor<4x8xf32> { %0 = stablehlo.broadcast_in_dim %a, dims = [1] : (tensor<8xf32>) -> tensor<4x8xf32> %1 = stablehlo.multiply %0, %b : tensor<4x8xf32> return %1 : tensor<4x8xf32> } }
broadcast+multiply
stablehlo+func
26_add-3d
easy
Write a function that adds two 2x3x4 f32 tensors elementwise.
module { func.func @a3(%a: tensor<2x3x4xf32>, %b: tensor<2x3x4xf32>) -> tensor<2x3x4xf32> { %0 = stablehlo.add %a, %b : tensor<2x3x4xf32> return %0 : tensor<2x3x4xf32> } }
3D add
stablehlo+func
27_subtract-bf16
easy
Write a function that subtracts two 16-element bf16 tensors elementwise.
module { func.func @s(%a: tensor<16xbf16>, %b: tensor<16xbf16>) -> tensor<16xbf16> { %0 = stablehlo.subtract %a, %b : tensor<16xbf16> return %0 : tensor<16xbf16> } }
bf16 arithmetic
stablehlo+func
28_dot_general-f16
medium
Multiply two 16x16 f16 tensors using stablehlo.dot_general.
module { func.func @m(%a: tensor<16x16xf16>, %b: tensor<16x16xf16>) -> tensor<16x16xf16> { %0 = stablehlo.dot_general %a, %b, contracting_dims = [1] x [0] : (tensor<16x16xf16>, tensor<16x16xf16>) -> tensor<16x16xf16> return %0 : tensor<16x16xf16> } }
f16 matmul
stablehlo+func
29_add-multiply-abs-chain
hard
Write a function that computes the absolute value of (a + b) * a for two 1-D f32 tensors.
module { func.func @c(%a: tensor<16xf32>, %b: tensor<16xf32>) -> tensor<16xf32> { %0 = stablehlo.add %a, %b : tensor<16xf32> %1 = stablehlo.multiply %0, %a : tensor<16xf32> %2 = stablehlo.abs %1 : tensor<16xf32> return %2 : tensor<16xf32> } }
3-op chain
stablehlo+func
30_transpose-add
medium
Transpose a 4x4 f32 tensor then add it back to the original.
module { func.func @ta(%a: tensor<4x4xf32>) -> tensor<4x4xf32> { %0 = stablehlo.transpose %a, dims = [1, 0] : (tensor<4x4xf32>) -> tensor<4x4xf32> %1 = stablehlo.add %0, %a : tensor<4x4xf32> return %1 : tensor<4x4xf32> } }
symmetric sum
stablehlo+func

StableHLO-Spec-30

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

Hand-authored NL→StableHLO pairs across 10 op families (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: stablehlo-opt v1.4.0 (upstream truth) and iree-compile --compile-to=input (substitute, 50/50 concordant on a stratified n=50 sample)
  • License: Apache-2.0 (SPDX: Apache-2.0). No third-party IP restrictions.

Loading

from datasets import load_dataset
ds = load_dataset("plawanrath/StableHLO-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/stablehlo_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
133

Collection including plawanrath/StableHLO-Spec-30

Paper for plawanrath/StableHLO-Spec-30