Groverkss/mlir-tutor: Exercises for Learning MLIR (Originally written for PPoPP 2026)


Installation Instructions

  1. Create a virtual environment and activate it:
python3 -m venv venv
source venv/bin/activate
  1. Install required packages:
pip install -r requirements.txt
  1. Check if the installation was successful:
python3 -m mlir_wheel --root-dir
  1. Configure CMake:
mkdir build
cd build
cmake ../ -DCMAKE_PREFIX_PATH=$(python -m mlir_wheel --root-dir) -DLLVM_EXTERNAL_LIT=$(which lit)
  1. Build:

Installing Python Package

  1. Install the Python DSL package (editable mode):
# From project root directory (not the build directory).
pip install -e python/
  1. Set the TUTORIAL_OPT environment variable to point to the built tutorial-opt binary:
export TUTORIAL_OPT=$PWD/build/tutorial/tutorial-opt
  1. Run an example to verify:
python tutorial/ch1-cpu-vector-dsl/square.py

The examples will print the generated MLIR at each lowering stage.

Each tutorial chapter has a README.md file explaining how to start with the exercise and some basic explanation of the exercise. For example, check out tutorial/ch1-cpu-vector-dsl/README.md



Source link