MLIR Beginner: MLIR backend for custom accelerator

Hello! I am trying to get accustomed to MLIR in order to be able to use it to generate code for a custom accelerator.

Currently I am running over Chapter 2: Emitting Basic MLIR - MLIR and figuring out the code.

While the tutorial covers well the toy dialect construction, ops definitions and tablegen, I am trying to learn the MLIR API , i.e. the way the methods build(), parse() and verify() are defined in Dialect.cpp and the generation of IR code from MLIRGen.cpp.

Basically I am looking for a method to learn the MLIR API, what each class does and where to use it.

My scope would be to define a dialect from MLIR then to lower it into binary representation. How one can ‘learn’ the MLIR, is there are systematic approach method?

I would like to know what would be the right approach to accomplish my goal, given that I am completely new to MLIR development.


The code for the tutorial is in the repo, did you build it, modify it, extend it?
There should enough there to cover a quite significant part of the API surface I think.

Yes, I’ve built it, I’m debugging it to understand how it works, so the next step would be to then a new operator to the toy language?

You mentioned you’re running over Chapter 2, so I would say the next step is chapter 3 :wink:
Probably worth completing a few of the chapters before trying to modify the code too heavily. Instead of adding operator, doing some change is an easier start probably.