[Unity] Fix FuseTIR when the same buffer is read multiple times with different access pattern#14603
Merged
tqchen merged 2 commits intoapache:unityfrom Apr 12, 2023
Merged
[Unity] Fix FuseTIR when the same buffer is read multiple times with different access pattern#14603tqchen merged 2 commits intoapache:unityfrom
tqchen merged 2 commits intoapache:unityfrom
Conversation
Collaborator
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
masahi
commented
Apr 12, 2023
| ret.push_back(region); | ||
| buffer_region_set[region->buffer.get()] = region->region; | ||
| } else { | ||
| ICHECK(structural_equal_(region->region, it->second)); |
Member
Author
There was a problem hiding this comment.
Sorry the diff is noisy due to the unrelated style updates, but this is the only important diff.
masahi
commented
Apr 12, 2023
| v_ax0, v_ax1, v_ax2, v_ax3 = T.axis.remap("SSSS", [ax0, ax1, ax2, ax3]) | ||
| T.reads( | ||
| rxplaceholder_1[v_ax0 - T.int64(1), v_ax1, v_ax2, v_ax3], | ||
| rxplaceholder[v_ax0, v_ax1, v_ax2, v_ax3], |
Member
Author
There was a problem hiding this comment.
Note that in this test case, rxplaceholder_1 and rxplaceholder refer to the same buffer inp_0. But they are used with different access patterns.
Hzfengsy
approved these changes
Apr 12, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the same buffer is read multiple times with different access patterns in a single expression, the check below fails
https://github.com/apache/tvm/blob/unity/src/relax/transform/fuse_tir.cc#L266
But this case should be allowed, for example in the following subgraph
inp_0is used twice in different read regions. See the test case for details. This subgraph arises if we runConvertLayouton SD UNet from web-stable diffusion.@Hzfengsy