[Mlir-commits] [mlir] [MLIR][Python] Add `GreedyRewriteDriverConfig` parameter to `apply_patterns_and_fold_greedily` (PR #174785)
Maksim Levental
llvmlistbot at llvm.org
Wed Jan 7 07:48:45 PST 2026
================
@@ -509,26 +509,42 @@ void populateRewriteSubmodule(nb::module_ &m) {
&PyFrozenRewritePatternSet::createFromCapsule);
m.def(
"apply_patterns_and_fold_greedily",
- [](PyModule &module, PyFrozenRewritePatternSet &set) {
+ [](PyModule &module, PyFrozenRewritePatternSet &set, nb::object config) {
+ if (config.is_none()) {
+ config = nb::cast(PyGreedyRewriteDriverConfig());
+ }
+
auto status = mlirApplyPatternsAndFoldGreedily(
- module.get(), set.get(), mlirGreedyRewriteDriverConfigCreate());
+ module.get(), set.get(),
+ nb::cast<PyGreedyRewriteDriverConfig &>(config).get());
if (mlirLogicalResultIsFailure(status))
throw std::runtime_error("pattern application failed to converge");
},
- "module"_a, "set"_a,
+ "module"_a, "set"_a, "config"_a = nb::none(),
----------------
makslevental wrote:
You can just do `std::optional` and it'll automatically turn into this same kind of thing (default will be `None`). Also you don't need to use `nb::sig` anymore after https://github.com/llvm/llvm-project/pull/171775 because now all the API types are the actual binded classes.
https://github.com/llvm/llvm-project/pull/174785
More information about the Mlir-commits
mailing list