[Mlir-commits] [mlir] [mlir][py] invalidate nested operations when parent is deleted (PR #93339)

Stella Laurenzo llvmlistbot at llvm.org
Fri May 24 14:43:34 PDT 2024


stellaraccident wrote:

It makes them more like attributes and types where we return a python wrapper backed by an operation* that has a lifetime for however long you hold the wrapper. It is up to the user to not delete IR structure that have live references in their code, and there is no secret map of dangling pointers.

We had discussed also adding some kind of arena context manager that would hold all PyOperations allocated in its scope and allow you to invalidate them (or invalidate at scope exit).

There really isn't a better way in the context of what MLIR is. If we went back to something super heavy handed, that would probably push me to maintain out of tree bindings optimized for efficiency of IR construction and constrained traversal, similar to the lite LLVM python bindings that are used for production cases where efficiency matters. 

I was going to patch the excision patch into some projects and see how bad it is. I think the potential for dangling pointers that are induced by the bindings itself is the worst world and we need to exit that.

https://github.com/llvm/llvm-project/pull/93339


More information about the Mlir-commits mailing list