This pattern does not work well with bufferization because it destroys tensor SSA use-def chains.
Depends On D129354
Differential D129355
[mlir][linalg] Remove RemoveOutsDependency pattern springerm on Jul 8 2022, 2:54 AM. Authored by
Details
This pattern does not work well with bufferization because it destroys tensor SSA use-def chains. Depends On D129354
Diff Detail
Event TimelineComment Actions This should not affect bufferization. It breaks unnecessary dependency. Can you elaborate more about the failure case here. Comment Actions Bufferization analyzes tensor use-def chains to decide what should bufferize in-place. A linalg.generic may have a certain tensor as an out operand even if it is not used in the computation. This may be on purpose to ensure that a certain buffer is used for in-place bufferization. This pattern would replace such as an out tensor with an init_tensor, thus breaking the use-def chain. Removing this patterns breaks an IREE test case, that's why I put it on "changes planned" for the moment. In what way does IREE depend on this pattern? I stumbled upon this pattern when looking at the sparse compiler pipeline, where it causes an issue with bufferization. Comment Actions I think you are implicitly expecting every program to be in destination passing style. I realize that this is what bufferization needs, but this is not the form of the program to start with during compilation of full programs (unless the destination passing style is lifted all the way into user code which no framework does today). So stepping out of the destination passing style requirements, adding a dependence between an op to another then makes it hard to disambiguate what is a real dependence vs what is a dependence that is introduced by bufferization requirements. For things that want to do producer-consumer fusion (like these patterns), its much easier to have to deal with real dependence as opposed to dependence due to bufferization. Having said that though, it does seem that this particular pattern breaks programs that are already in destination passing style.... If you remove this pattern, there is something else needed in the fusion patterns that would be needed to avoid fusing across these dependences.... At the very least for your use case you can create a separate populate* method that doesnt have this pattern. |