Move linalg.fill folding into linalg.generic pattern from canonicalization to elementwise op fusion
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp | ||
---|---|---|
2217–2218 | nit: adding a blank line before comments usually helps readability. | |
2236 | [optional] I'd prefer not having this comment. The below line already describes it. | |
2285–2286 | Can merge this into one line? | |
mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir | ||
1 | Why do we need canoincalize here? I found that they are copied from canonicalize.mlir. So I assume that there are at least two patterns kicked in to get the result IR. Can we split tests to test two patterns separately? |
mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir | ||
---|---|---|
1 | Yes, so the other pattern it needs is this one Coming back to the tests and the pattern I am moving here, without the deadarg removing pattern it will have dead args and fill ops with no consumers. I can account for that in the pattern matching checks. However, it is also important to check if the combination works as that is the end goal here. Perhaps one solution is to add a separate test file for checking this combination. What do you think? |
mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir | ||
---|---|---|
1 | In this case, we can put the output of this pattern to canonicalize.mlir and test it there. I don't have strong opinion about having canonicalize in this file or not. I was afraid that we're not testing what the pattern does. I was also afraid if the test is robust, i.e., if adding other patterns would break this. After reading patterns deeply, I think it's a fine change to me. | |
1 | I'll let you make the call. |
mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir | ||
---|---|---|
1 | Sounds good, I think we can leave the canonicalize in then. |
Minor change to not use canonicalize in lit test. Otherwise LGTM! THanks!
mlir/test/Dialect/Linalg/fusion-elementwise-ops.mlir | ||
---|---|---|
1 | I think MLIR convention is to not rely on canonicalize to clean up lit tests. Its pretty disruptive cause changes to canonicalize then hits many lit tests. So It is probably better to remove the canonicalize and test the pass by itself.... |
There was a bug that was found by @benvanik in the folding pattern where it would trigger infinitely if the fill already did not have a use in the generic op.
Fixing that in this revision. With this change also dead args get dropped automatically with the transform pattern because it calls canonicalization within the pass. The fact that this was not happening initially was due to this bug.
nit: adding a blank line before comments usually helps readability.