[TIR][Schedule] Scoped CacheRead/Write producing compact region#15236
Merged
tqchen merged 1 commit intoapache:mainfrom Jul 6, 2023
Merged
[TIR][Schedule] Scoped CacheRead/Write producing compact region#15236tqchen merged 1 commit intoapache:mainfrom
tqchen merged 1 commit intoapache:mainfrom
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 |
MasterJH5574
commented
Jul 5, 2023
| * that their extent's product have a factor of `innerpart_factor`. The first part is loops at | ||
| * [0, partition_pos); the second part is loops at [partition_pos, n) and we will have | ||
| * `innerpart_factor` | \prod_{l=partition_pos}^{n-1} l.extent | ||
| * `innerpart_factor` | prod_{l=partition_pos}^{n-1} l.extent |
Contributor
Author
There was a problem hiding this comment.
Updating this since Clang will warn
1 warning generated.
In file included from /home/ruihangl/tvm/src/tir/schedule/primitive/for_kind.cc:19:
In file included from /home/ruihangl/tvm/src/tir/schedule/primitive/../utils.h:49:
/home/ruihangl/tvm/src/tir/schedule/primitive/.././primitive.h:108:26: warning: unknown command tag name [-Wdocumentation-unknown-command]
* `innerpart_factor` | \prod_{l=partition_pos}^{n-1} l.extent
^~~~~~
junrushao
reviewed
Jul 5, 2023
junrushao
approved these changes
Jul 5, 2023
Member
junrushao
left a comment
There was a problem hiding this comment.
Overall LGTM! Likely it won't break anything as scopes don't happen a lot in existing TIR/MS pipeline
3ce17c3 to
6c35f3f
Compare
This PR enhances CacheRead/Write so that when a cache operation is performed under an inner block, the generated cache buffer will have the shape as compact as possible, by region consumption analysis. The motivation of this change comes from the needs of dynamic shape TIR scheduling, in which case we may isolate a "static shape" internal block using blockize, and do further scheduling inside the internal block. For such cases, the current CacheRead/Write inside the static-shape block will still produce dynamic-shape cache buffers, which is not ideal for analysis and subsequent scheduling. One thing that worths noting is that, to ensure the IR correctness after inserting the cache block, we will only compact the cache buffer when all the consumer blocks of the read buffer (for CacheRead) or the write buffer (for CacheWrite) are children blocks of the cache block insertion location. Otherwise we will insist allocating the full-size cache buffer. Co-authored-by: Bohan Hou <spectrometerh@gmail.com>
6c35f3f to
1d432c5
Compare
junrushao
pushed a commit
to junrushao/tvm
that referenced
this pull request
Jul 15, 2023
…he#15236) This PR enhances CacheRead/Write so that when a cache operation is performed under an inner block, the generated cache buffer will have the shape as compact as possible, by region consumption analysis. The motivation of this change comes from the needs of dynamic shape TIR scheduling, in which case we may isolate a "static shape" internal block using blockize, and do further scheduling inside the internal block. For such cases, the current CacheRead/Write inside the static-shape block will still produce dynamic-shape cache buffers, which is not ideal for analysis and subsequent scheduling. One thing that worths noting is that, to ensure the IR correctness after inserting the cache block, we will only compact the cache buffer when all the consumer blocks of the read buffer (for CacheRead) or the write buffer (for CacheWrite) are children blocks of the cache block insertion location. Otherwise we will insist allocating the full-size cache buffer. Co-authored-by: Bohan Hou <spectrometerh@gmail.com>
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.
This PR enhances CacheRead/Write so that when a cache operation is performed under an inner block, the generated cache buffer will have the shape as compact as possible, by region consumption analysis.
The motivation of this change comes from the needs of dynamic shape TIR scheduling, in which case we may isolate a "static shape" internal block using blockize, and do further scheduling inside the internal block. For such cases, the current CacheRead/Write inside the static-shape block will still produce dynamic-shape cache buffers, which is not ideal for analysis and subsequent scheduling.
One thing that worths noting is that, to ensure the IR correctness after inserting the cache block, we will only compact the cache buffer when all the consumer blocks of the read buffer (for CacheRead) or the write buffer (for CacheWrite) are children blocks of the cache block insertion location. Otherwise we will insist allocating the full-size cache buffer.
Co-authored-by: Bohan Hou spectrometerh@gmail.com