[Mlir-commits] [mlir] [mlir][linalg] Extend `FuseElementwiseOps` pattern to work with named ops (PR #144922)
Javed Absar
llvmlistbot at llvm.org
Sun Oct 19 04:12:23 PDT 2025
================
@@ -215,16 +216,33 @@ bool mlir::linalg::areElementwiseOpsFusable(OpOperand *fusedOperand) {
/// Generate the region of the fused tensor operation. The region of the fused
/// op must be empty.
static void generateFusedElementwiseOpRegion(
- RewriterBase &rewriter, GenericOp fusedOp,
+ RewriterBase &rewriter, LinalgOp fusedOp,
AffineMap consumerToProducerLoopsMap, OpOperand *fusedOperand,
unsigned nloops, llvm::SmallDenseSet<int> &preservedProducerResults) {
- auto producer = cast<GenericOp>(fusedOperand->get().getDefiningOp());
- auto consumer = cast<GenericOp>(fusedOperand->getOwner());
+ auto producer = cast<LinalgOp>(fusedOperand->get().getDefiningOp());
+ auto consumer = cast<LinalgOp>(fusedOperand->getOwner());
// Build the region of the fused op.
+
+ // Since some ops, like `linalg.map`, do not have block arguments for init
----------------
javedabsar1 wrote:
> I agree that it needs to be updated, or even better if we deprecate it in favour of `linalg.elementwise` as `linalg.map` is same semantically with `linalg.elementwise`, in fact `linalg.elementwise` seems more general, IIRC.
`linalg.map` is more than `linalg.elementwise` . linalg.map e.g. this is valid linalg.map and not mappable to elementwise
```mlir
%mapped = linalg.map outs(%1 : tensor<?xindex>)
() {
%2 = linalg.index 0 : index
%dim = memref.dim %0, %2 : memref<*xf32>
linalg.yield %dim : index
}
```
https://github.com/llvm/llvm-project/pull/144922
More information about the Mlir-commits
mailing list