[TVMScript][TIR] Clarify scope of BlockNode::iter_vars#12726
Merged
vinx13 merged 1 commit intoapache:mainfrom Sep 9, 2022
Merged
[TVMScript][TIR] Clarify scope of BlockNode::iter_vars#12726vinx13 merged 1 commit intoapache:mainfrom
vinx13 merged 1 commit intoapache:mainfrom
Conversation
Previously, it was ambiguous whether `BlockNode::iter_vars` were in-scope for `BlockRealizeNode::predicate`. `ConvertBlocksToOpaque` treated them as in-scope, and applied a mapping from `iter_vars` to `iter_values`. Similarly, TVMScript printing places `T.where` statements below the `T.axis` statements, where `T.axis` definitions are in scope. However, `BlockRealizeNode::SEqualReduce` and `BlockRealizeNode::SHashReduce` do not visit the block and `iter_vars` until after visiting the predicate, placing the `iter_vars` out of scope. This commit updates the printing of `T.where` to be above `T.axis`, and updates `ConvertBlocksToOpaque` to report an error if the predicate contains references to `BlockNode::iter_vars`. After this commit, these three usages all consistently treat `BlockNode::iter_vars` as out of scope for `BlockRealizeNode::predicate`.
Contributor
Author
vinx13
approved these changes
Sep 9, 2022
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 25, 2022
Previously, it was ambiguous whether `BlockNode::iter_vars` were in-scope for `BlockRealizeNode::predicate`. `ConvertBlocksToOpaque` treated them as in-scope, and applied a mapping from `iter_vars` to `iter_values`. Similarly, TVMScript printing places `T.where` statements below the `T.axis` statements, where `T.axis` definitions are in scope. However, `BlockRealizeNode::SEqualReduce` and `BlockRealizeNode::SHashReduce` do not visit the block and `iter_vars` until after visiting the predicate, placing the `iter_vars` out of scope. This commit updates the printing of `T.where` to be above `T.axis`, and updates `ConvertBlocksToOpaque` to report an error if the predicate contains references to `BlockNode::iter_vars`. After this commit, these three usages all consistently treat `BlockNode::iter_vars` as out of scope for `BlockRealizeNode::predicate`.
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.
Previously, it was ambiguous whether
BlockNode::iter_varswere in-scope forBlockRealizeNode::predicate.ConvertBlocksToOpaquetreated them as in-scope, and applied a mapping fromiter_varstoiter_values. Similarly, TVMScript printing placesT.wherestatements below theT.axisstatements, whereT.axisdefinitions are in scope. However,BlockRealizeNode::SEqualReduceandBlockRealizeNode::SHashReducedo not visit the block anditer_varsuntil after visiting the predicate, placing theiter_varsout of scope.This commit updates the printing of
T.whereto be aboveT.axis, and updatesConvertBlocksToOpaqueto report an error if the predicate contains references toBlockNode::iter_vars. After this commit, these three usages all consistently treatBlockNode::iter_varsas out of scope forBlockRealizeNode::predicate.cc @Hzfengsy @junrushao1994