[Mlir-commits] [mlir] [mlir][transform] Add linalg.fold_reshape_ops_by_expansion transform op (PR #233732)
Adam Siemieniuk
llvmlistbot at llvm.org
Tue Oct 20 02:47:44 PDT 2026
================
@@ -276,6 +276,18 @@ void transform::ApplyEraseUnusedOperandsAndResultsPatternsOp::populatePatterns(
linalg::populateEraseUnusedOperandsAndResultsPatterns(patterns);
}
+void transform::ApplyFoldReshapeOpsByExpansionPatternsOp::populatePatterns(
+ RewritePatternSet &patterns) {
+ linalg::ControlFusionFn controlFn =
+ [foldSingleUseOnly = getFoldSingleUseOnly()](OpOperand *fusedOperand) {
+ if (!foldSingleUseOnly)
+ return true;
+ Operation *producer = fusedOperand->get().getDefiningOp();
+ return producer && producer->hasOneUse();
+ };
+ linalg::populateFoldReshapeOpsByExpansionPatterns(patterns, controlFn);
----------------
adam-smnk wrote:
I think it's reasonable to start with a selection of common/useful variants as you propose.
For a generic solution, I think we'd need to expose pattern APIs directly in python for full control.
https://github.com/llvm/llvm-project/pull/233732
More information about the Mlir-commits
mailing list