[Mlir-commits] [mlir] [mlir][linalg] Extend `FuseElementwiseOps` pattern to work with named ops (PR #144922)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Nov 5 11:01:17 PST 2025
srcarroll wrote:
I was curious what kinds of changes downstream users would need to make in their stack. Really the only main one I'm familiar with that actually uses this pattern is IREE. I think this is a good representative example, but would be glad to hear from others of possible more complex use cases. In IREE, the pattern is used in 4 places; 3 of them use `fuseElementwiseOps` directly and one uses `populateElementwiseOpsFusionPatterns`.
1. https://github.com/iree-org/iree/blob/dca3747642d6d06280c5629106ff0bd2fe0bc4e1/compiler/src/iree/compiler/DispatchCreation/ElementwiseOpFusion.cpp#L176 . Just update `fuseElementwiseOpsControlFn` to only accept `GenericOp` if you want to keep current behavior. This is trivial
2. https://github.com/iree-org/iree/blob/dca3747642d6d06280c5629106ff0bd2fe0bc4e1/compiler/src/iree/compiler/Codegen/Common/RematerializeParallelOps.cpp#L65 . No change needed because the containing pattern is only on `GenericOp` anyway.
3. https://github.com/iree-org/iree/blob/dca3747642d6d06280c5629106ff0bd2fe0bc4e1/compiler/src/iree/compiler/Codegen/Common/DecomposeSoftmax.cpp#L56 . Again no change needed for same reason as (2)
4. https://github.com/iree-org/iree/blob/dca3747642d6d06280c5629106ff0bd2fe0bc4e1/compiler/src/iree/compiler/DispatchCreation/FuseMultiUseElementwiseProducer.cpp#L122 . This is less trivial than the others, so could miss something, but I think it's also a no change situation. The call to `fuseElementwiseOps` is contained in the `doMultiUseFusion` function. Although this function isn't specific to `GenericOp`, it is a one-off static function that is only used [here](https://github.com/iree-org/iree/blob/dca3747642d6d06280c5629106ff0bd2fe0bc4e1/compiler/src/iree/compiler/DispatchCreation/FuseMultiUseElementwiseProducer.cpp#L246). As far as I can tell, everything in `fusedOps` is a `GenericOp`.
So unless I'm wrong in my assessment here, doing the change proposed by @MaheshRavishankar would actual require more changes in IREE, albeit still trivial. I'm not saying this is reason alone to not do the change, but I think it is valuable data that provides more context to the discussion. Note: I have 0 investment in the IREE project, so I'm not cherry-picking, it's just the only relevant downstream example I can think of.
https://github.com/llvm/llvm-project/pull/144922
More information about the Mlir-commits
mailing list