[Mlir-commits] [mlir] [mlir][linalg] Extend `FuseElementwiseOps` pattern to work with named ops (PR #144922)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Nov 9 20:15:09 PST 2025
================
@@ -554,23 +554,42 @@ FailureOr<DropUnitDimsResult> dropUnitDims(RewriterBase &rewriter,
GenericOp genericOp,
const ControlDropUnitDims &options);
-/// Fuse two `linalg.generic` operations that have a producer-consumer
+/// Base implementation for fusion of two linalg operations.
+/// Fuse two linalg operations that have a producer-consumer
/// relationship captured through `fusedOperand`. The method expects
/// that `areElementwiseOpsFusable` returns true for the given `fusedOperand`.
+/// The resulting fused operation is always a `linalg.generic`.
+/// TODO: Support fusing to named ops when possible. For many cases,
+/// `linalg.generic` is the only op that is capable of representing the fused
+/// operation. An example exception is fusing two `linalg.map` ops. The fused
+/// result can also be represented by `linalg.map`.
struct ElementwiseOpFusionResult {
Operation *fusedOp;
llvm::DenseMap<Value, Value> replacements;
};
+template <typename LinagOpTy>
FailureOr<ElementwiseOpFusionResult>
-fuseElementwiseOps(RewriterBase &rewriter, OpOperand *fusedOperand);
+fuseElementwiseLinalgOpsImpl(RewriterBase &rewriter, OpOperand *fusedOperand);
----------------
MaheshRavishankar wrote:
This doesnt need to be exposed (at least for now). Can make this static.
https://github.com/llvm/llvm-project/pull/144922
More information about the Mlir-commits
mailing list