Skip to content

benchmarks.SaturnNPU.scripts.generate_kernel_catalog

Source: benchmarks/SaturnNPU/scripts/generate_kernel_catalog.py

benchmarks.SaturnNPU.scripts.generate_kernel_catalog

Generate a per-kernel catalog with standalone MLIR files and README.

For each kernel type we need to implement, creates: kernels// README.md — description, shapes, PyTorch origin, how to test .mlir — standalone compilable MLIR for each shape variant golden/ — .npy golden data (input/output) per variant

This gives kernel developers everything in one place: the MLIR to implement against, the golden data to verify, and context about what it represents.

Usage

python tools/generate_kernel_catalog.py --linalg-input build/compiled_models/smolVLA/.../phases/module.1.input.mlir --global-opt build/compiled_models/smolVLA/.../phases/module.4.global-optimization.mlir --output-dir benchmarks/SaturnNPU/kernels/

extract_representative_snippets(lines, classify_fn, op_re)

Extract one representative MLIR snippet per classified op type.

Returns {classification: {"snippet": str, "line": int, "shapes": list[str]}}

make_standalone_mlir(cls, snippet_data)

Create a standalone compilable MLIR function from a snippet.

Returns None if the snippet can't be made standalone.