Redundant buffer allocations in LinalgExt/Linalg ops when there are constants in outs
What happened?
I found that there are redundant buffer allocation in LinalgExt ops. It also happens in normal Linalg ops. The main issue is that a constant op is taken in outs. While the constant op is read-only, the bufferization ends up with creating an additional buffer to store the temp values.
We actually have RemoveCstOutsDependency to handle the case, but it does not work anymore. The pattern expects the out to be a pure constant. However, we put the ConvertToDestionationPassingStyle after TileAndDistributePass, which makes the out be an extract_slice op on a constant. This stops the pattern and results in unnecessary buffer allocation.
https://github.com/iree-org/iree/blob/dbeec8eadabedb442659503bc0a76d87ce7c5069/compiler/src/iree/compiler/Codegen/Common/ConvertToDestinationPassingStylePass.cpp#L384-L417
We can swap the order of two passes. But I remember that there were issues about the order..
Steps to reproduce your issue
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
What component(s) does this issue relate to?
Compiler
Version information
No response
Additional context
No response