benchmarks.SaturnNPU.scripts.generate_mlir_golden_data
Source: benchmarks/SaturnNPU/scripts/generate_mlir_golden_data.py
benchmarks.SaturnNPU.scripts.generate_mlir_golden_data
Generate golden test data by compiling and executing MLIR ops via IREE.
For each key op type found in the global-optimization MLIR, this script: 1. Creates a standalone MLIR function wrapping the operation 2. Compiles it with iree.compiler (target: llvm-cpu) 3. Executes it with iree.runtime using random inputs 4. Saves input/output as .npy golden data
This gives numerically correct golden data from the actual MLIR compiler, not just PyTorch reference implementations.
Usage
python tools/generate_mlir_golden_data.py --output-dir benchmarks/SaturnNPU/golden_data/mlir_level/
compile_and_run(mlir_text, func_name, inputs)
Compile MLIR and execute with given inputs, return output.