-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CODEGEN] Fix code generation bugs for C/CUDA & Improve VerifyGPUCode pass #6041
Merged
Conversation
This file contains 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
merrymercy
force-pushed
the
pr-fix-cuda-codegen
branch
2 times, most recently
from
July 13, 2020 04:54
993c6fe
to
a877f3d
Compare
merrymercy
force-pushed
the
pr-fix-cuda-codegen
branch
from
July 13, 2020 04:59
a877f3d
to
d056e4c
Compare
merrymercy
changed the title
[CODEGEN] Fix code generation bugs for cuda & Improve VerifyGPUCode pass
[CODEGEN] Fix code generation bugs for C/CUDA & Improve VerifyGPUCode pass
Jul 13, 2020
jcf94
reviewed
Jul 13, 2020
@@ -720,14 +720,15 @@ void CodeGenC::VisitStmt_(const StoreNode* op) { | |||
} else { | |||
CHECK(is_one(op->predicate)) << "Predicated store is not supported"; | |||
arith::PVar<PrimExpr> base; | |||
|
|||
// The assignment below introduces side-effect, and the resulting value cannot | |||
// be reused across multiple expression, thus a new scope is needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Do we need to add some UTs to cover these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test case added
merrymercy
force-pushed
the
pr-fix-cuda-codegen
branch
from
July 13, 2020 08:25
a1f95a7
to
b62dd77
Compare
tqchen
approved these changes
Jul 13, 2020
trevor-m
pushed a commit
to trevor-m/tvm
that referenced
this pull request
Jul 14, 2020
trevor-m
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Jul 14, 2020
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.
tir.reinterpret
If we call
tir.reinterpret
on an rvalue, the existing strategy will generate the wrong code. Because we cannot get the address of an rvalue. To fix this, we need to store the rvalue into a temporary variable and get the address of this temporary variable.This bug is the same as the bug in [CODEGEN] update codegen for vector operation #711. In the old PR, I only added a new SSA scope for the "else" branch. But in the "then" branch, it has the same problem. So I moved the addition of a new SSA scope to the top-level to cover both "then" and "else" branch.
Besides checking the LoadNode, we should also check the StoreNode.
cc @weberlo @tqchen @jcf94