[Mlir-commits] [mlir] [mlir][linalg] Extend `FuseElementwiseOps` pattern to work with named ops (PR #144922)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 31 13:37:14 PDT 2025


srcarroll wrote:

> Another question: If we just assume `LinalgOp`, then wouldn't that also match `matmul`, `contract`, `softmax` and other non-ew operations? Or do we have an explicit check for EW maps?
> 
> Would be good to _prove_ that with some negative tests (at least one for `contract` and one for `softmax`).

Good question. The name of this pattern is misleading. It already works for non elementwise ops. You can see in tests that they have fusion for contraction ops in `linalg.generic` form. See https://github.com/llvm/llvm-project/blob/c620d074a3bded54072db8a3bef14430accd007b/mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir. In my opinion, if it's allowed for the generic form it should also be allowed for the named form.  This pattern has it's own rules for whether it fuses operations or not. If `matmul` obeys that rule, then it should be fused. If that's undesirable, then the pattern logic should change, but that's not really an issue specific to enabling the pattern to any `LinalgOp`.

https://github.com/llvm/llvm-project/pull/144922


More information about the Mlir-commits mailing list