[Mlir-commits] [mlir] [MLIR][Python] Add bindings for PDL native rewrite function registering (PR #159926)
Maksim Levental
llvmlistbot at llvm.org
Sat Sep 20 11:02:34 PDT 2025
================
@@ -88,10 +147,20 @@ void mlir::python::populateRewriteSubmodule(nb::module_ &m) {
PyPDLPatternModule(mlirPDLPatternModuleFromModule(module));
},
"module"_a, "Create a PDL module from the given module.")
- .def("freeze", [](PyPDLPatternModule &self) {
- return new PyFrozenRewritePatternSet(mlirFreezeRewritePattern(
- mlirRewritePatternSetFromPDLPatternModule(self.get())));
- });
+ .def(
+ "freeze",
+ [](PyPDLPatternModule &self) {
+ return new PyFrozenRewritePatternSet(mlirFreezeRewritePattern(
+ mlirRewritePatternSetFromPDLPatternModule(self.get())));
+ },
+ nb::keep_alive<0, 1>())
----------------
makslevental wrote:
hm i never thought about this before - this keeps the module alive while the set is alive. i guess we could use this instead of the bespoke `parentKeepAlive` stuff we have...
https://github.com/llvm/llvm-project/pull/159926
More information about the Mlir-commits
mailing list