[Mlir-commits] [mlir] [MLIR][Python] Support canonicalization hooks for Python-defined ops (PR #224806)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Sep 25 21:33:36 PDT 2026
================
@@ -2547,6 +2549,37 @@ void PyOpAdaptor::bind(nb::module_ &m) {
"Returns the attributes of the adaptor.");
}
+void PyDynamicOpDefinition::setGetCanonicalizationPatternsFn(
+ const nb::callable &fn) {
+ fn.inc_ref();
----------------
PragmaTwice wrote:
i don't think we can assume that it is a class method. it can be a temporary function or a lambda. you can check `mlir/python/mlir/dialects/ext.py`, where we use a temporary function as a callback. so we `inc_ref` here and `dec_ref` when the `DynamicOpDefinition` object destructs.
https://github.com/llvm/llvm-project/pull/224806
More information about the Mlir-commits
mailing list