[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
================
@@ -331,18 +333,19 @@ static void generateFusedElementwiseOpRegion(
YieldOp::create(rewriter, fusedOp.getLoc(), fusedYieldValues);
// Sanity checks.
- assert(fusedBlock->getNumArguments() == fusedOp.getNumOperands() &&
+ assert(fusedBlock->getNumArguments() == fusedOp->getNumOperands() &&
"Ill-formed GenericOp region");
}
+template <typename LinagOpTy>
FailureOr<mlir::linalg::ElementwiseOpFusionResult>
-mlir::linalg::fuseElementwiseOps(RewriterBase &rewriter,
- OpOperand *fusedOperand) {
- assert(areElementwiseOpsFusable(fusedOperand) &&
- "expected elementwise operation pre-conditions to pass");
+mlir::linalg::fuseElementwiseLinalgOpsImpl(RewriterBase &rewriter,
+ OpOperand *fusedOperand) {
+ if (!areElementwiseOpsFusable(fusedOperand))
+ return failure();
auto producerResult = cast<OpResult>(fusedOperand->get());
- auto producer = cast<GenericOp>(producerResult.getOwner());
- auto consumer = cast<GenericOp>(fusedOperand->getOwner());
+ auto producer = cast<LinagOpTy>(producerResult.getOwner());
----------------
MaheshRavishankar wrote:
Nit. Typo. This should be `LinalgOpTy`.
https://github.com/llvm/llvm-project/pull/144922
More information about the Mlir-commits
mailing list