[TVMScript] Allow val = buf[index] without type annotation#11060
Merged
vinx13 merged 2 commits intoapache:mainfrom Apr 21, 2022
Merged
[TVMScript] Allow val = buf[index] without type annotation#11060vinx13 merged 2 commits intoapache:mainfrom
val = buf[index] without type annotation#11060vinx13 merged 2 commits intoapache:mainfrom
Conversation
MasterJH5574
approved these changes
Apr 21, 2022
Other instances of `var = expr` were previously allowed without requiring a type annotation, by using the dtype of the expression as the dtype of `var`. This behavior didn't work for `buf[index]` expressions, which are internally represented as `BufferSlice` python objects, and only converted to `BufferLoad` primexprs when used as an expression. This commit adds a `dtype` property to `BufferSlice`, allowing `buf[index]` to be used in a let statement without a type annotation.
Automatically adding a type annotation to Var if it could be determined from the dtype let the unit test directly compare the annotated and unannotated versions of buffer load. Unfortunately, it also broke 54 unrelated tests, so that change is removed from this PR.
5986c79 to
a8fb90f
Compare
Contributor
Author
|
Certainly! Rebased, and CI is re-running. |
shtinsa
pushed a commit
to Deelvin/tvm
that referenced
this pull request
May 17, 2022
…11060) * [TVMScript] Allow `val = buf[index]` without type annotation Other instances of `var = expr` were previously allowed without requiring a type annotation, by using the dtype of the expression as the dtype of `var`. This behavior didn't work for `buf[index]` expressions, which are internally represented as `BufferSlice` python objects, and only converted to `BufferLoad` primexprs when used as an expression. This commit adds a `dtype` property to `BufferSlice`, allowing `buf[index]` to be used in a let statement without a type annotation. * Reverted a wider change Automatically adding a type annotation to Var if it could be determined from the dtype let the unit test directly compare the annotated and unannotated versions of buffer load. Unfortunately, it also broke 54 unrelated tests, so that change is removed from this PR.
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.
Other instances of
var = exprwere previously allowed without requiring a type annotation, by using the dtype of the expression as the dtype ofvar. This behavior didn't work forbuf[index]expressions, which are internally represented asBufferSlicepython objects, and only converted toBufferLoadprimexprs when used as an expression.This commit adds a
dtypeproperty toBufferSlice, allowingbuf[index]to be used in a let statement without a type annotation.