I followed the toy tutorials and get the basic understanding of MLIR. But while trying to learn more by diving a little bit deeper into the openai-triton project which uses MLIR to do codegen, and having a little difficulty understanding some topics regarding dialect conversion framework.
In the original toy tutorials, we didn’t use type converter because it’s not needed there. But in a lot of occasions, for example in triton( triton ir → tritongpu ir), or in mlir’s source code, when using linalg-detensorize
pass, I saw the usage of customized type converter, and of course the usage of several hook functions. By reading the source code and docs, I only managed to understand partially due to my background is not very solid in this area.
One thing I noticed that, for example, in linalg-detensorize
pass as in mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp, the source and argument materialization use the same callback to convert from legal “element type”( not sure how to describe this, maybe a fp64 type) to an illegal TensorType( Tensor I guess); and for target materializaiton, it uses the reversed version of callback to convert from illegal TensorType to “element type”.
I also checked that in the Bufferization/Transforms/Bufferize.cpp, the same logic applys.
However, as I read the doc and the header file in DialectConversion.h here, the documentation says the argument materialization
will be called when converting an illegal block argument type, to a legal type
This seems contradict with what the code does, so I’m more confused here. Is this doc wrong or I understood things wrong? Please help, thanks.