I’m facing the problem of binding my custom type to python.Specifically, I have three questions:
1. MLIR python binding documentation tells me that I can use include/mlir/Bindings/Python/PybindAdaptors.h to help me bind my type to python. However, this file provids various type_casters and mlir_*_subclasses. How can I use these classes and casters to bind types, by inheriting mlir_type_subclass or other ways?
2. How should I manage my CMakeLists.txt? My current CMakeLists.txt is written in imitation of mlir python/CMakeLists.txt, and where should I add binding source files(and header files)?
3. If I successfully bind my types, where should I visit my type in python? In mlir.ir.Types.MyType or mlir.ir.MyType or other packages?
There is upstream usage of
mlir_type_subclass, e.g., in https://github.com/llvm/llvm-project/blob/f5cb9cb59d7c9c6ac3d5c41c677f68c9b75d34a3/mlir/lib/Bindings/Python/DialectPDL.cpp#L30. You can follow that as an example.
It works! Thanks a lot!