[Mlir-commits] [mlir] [MLIR][Python] Call `notifyOperationInserted` while constructing new op in rewrite patterns (PR #163694)
Maksim Levental
llvmlistbot at llvm.org
Thu Oct 16 19:24:43 PDT 2025
================
@@ -202,7 +207,15 @@ class PyRewritePatternSet {
PyMlirContext::forContext(mlirOperationGetContext(op));
nb::object opView = PyOperation::forOperation(ctx, op)->createOpView();
- nb::object res = f(opView, PyPatternRewriter(rewriter));
+ PyPatternRewriter pyRewriter(rewriter);
+ nb::object listener = nb::cast(pyRewriter.getListener());
+
+ listener.attr("__enter__")();
+ auto exit = llvm::make_scope_exit([listener] {
+ listener.attr("__exit__")(nb::none(), nb::none(), nb::none());
+ });
----------------
makslevental wrote:
basically i guess i'm saying the listener doesn't have to be on the `PatternRewriter` just because it's like that in cpp...
https://github.com/llvm/llvm-project/pull/163694
More information about the Mlir-commits
mailing list