Open discussion on MLIR bindings

Yep. I see it now. I just assumed that _CAPIPtr was implicitly added. I was going crazy looking around in npcomp for an example which used Operations. Now I know why. Should’ve been a red flag.

I only need Operation at the moment so I’ll attempt to put a patch together tonight. Out of curiosity, which are the ones where ownership is a concern? PyRegion and PyBlock?

For the lurkers and posterity, :gear: D99927 [MLIR] [Python] Add capsule methods for pybind11 to PyOperation (llvm.org) added the necessary support for PyOperation.

It’s aliiiiiive! [ESI] Add wrap function to Python API by teqdruid · Pull Request #893 · llvm/circt (github.com)

Thanks for all the help @stellaraccident !

Nicely done! I’m glad this is working for you all…

I’m coming back to this topic after spending some time doing Python-specific things for the short term. We had previously discussed generically serializing something like YAML or JSON for the host language to consume and use to enhance bindings. Is anyone currently looking into this? @GeorgeL I remember you mentioned you might be resuming your investigations here, did that bear any fruit?

I didn’t have any success with YAML, but I did set up a playground in MLIRSwift for dumping a small subset of TableGen data as JSON: https://github.com/circt/MLIRSwift/blob/main/Tools/MLIRSwiftTableGen/MLIRSwiftTableGen.cpp

I haven’t been pushing much more on this, but it would be nice to have a friendlier format list all operations and specify things like is there a known number of return values, can the return types be inferred, etc.

Nice, I am taking a look at that. I will spend some time pushing on this.