A minimal-er minimal MLIR project example

Recently, I noticed a couple of these “minimal” MLIR project repos/demos (zincnode/mlir-he, jmgorius/mlir-standalone-template, Lewuathe/mlir-hello). They’re good/solid but to my taste they’re not minimal enough. Since I just finished my PhD in CMake I thought I’d take a crack at putting together a more minimal setup: makslevental/mmlir. It demos a slightly unconventional way to bootstrap an MLIR project:

  1. It relies on https://makslevental.github.io/wheels for the upstream distribution of MLIR
  2. It smashes all the include headers into a single header include/MinimalDialect.h and all the tablegen into a single include/MinimalDialect.td and also emits all the tablegen into the source tree itself;
    a. I think seeing the emitted tablegen is useful for demystifying how MLIR works
  3. It smashes all the implementation into a single src/MinimalDialect.cpp
  4. Python bindings @ mmlir/dialects are arranged to have generated artifacts to be dumped in place.

It is primarily meant to be used a learning aid (e.g., for understanding which parts of the upstream CMake are essential and which aren’t) and not as a germ/seed/cookiecutter for a production quality project.

I’ve also set it to build and test nightly (based on nightly builds of MLIR from the wheels repo…) so it’ll stay in sync.

13 Likes

Thanks for the recognition! I’m excited to see more projects like this. I’ll keep watching. :smile:

1 Like

I also pretend to have very minimal example for total beginners in compilers. This project even doesn’t have any own dialect, but it is focused mostly on general purpose programming language initial design (not all parts, of course). At the same time it demonstrates an ability to infer types for small subset of dynamically typed language. The slides will be published later, now only the code: GitHub - vasily-v-ryabov/phdays24: Code for PHDays'2024 talk "Compilers without reinventing the wheel: what's up with MLIR, Mojo🔥 and beyond?" Though some listeners told me it is still complicated enough. :smile: Maybe it hardly depends on a target audience. Hope it is useful anyway.

4 Likes