-
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
[BYOC] Support control flow in annotate_target #6641
Conversation
Hi @codeislife99, thanks for the PR. Would you mind providing a bit more context on what this change is and why is it needed? Also, generally speaking, it would be good to have some test cases added when changes are introduced. That would help a lot, when reviewing your PR. |
@leandron @junrushao1994 The PR is now ready for review. Please take a look. |
@leandron @junrushao1994 The description is updated. PTAL. |
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.
The logic looks clear to me. Since this PR does not bring anything substantially new but just improve the annotation pass to support control flow related ops (e.g., If
), I think we can skip the RFC process.
return std::move(new_expr); | ||
} | ||
|
||
Expr InsertCompilerEnd(const Expr& expr) { |
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.
- Put this function together with
AnnotateArgs
. - Add formal function description.
- From its functionality, the name like
InsertCompilerEndAndPropogateTarget
would be more proper. - Use this function in
Expr Rewrite_(const FunctionNode* fn, const Expr& post)
to avoid redundant logic.
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.
Done. Although using this function in AnnotateArgs makes us do the same condition check twice which I think is unnecessary. For the time being I added it, but let me know your thoughts. Maybe I misinterpreted what you meant by Put this function together with AnnotateArgs
?
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.
Sorry for not being clear. For the last point, I meant you can use InertCompilerEndAndPropogateTarget
in https://github.com/apache/incubator-tvm/blob/main/src/relay/transforms/annotate_target.cc#L225 to replace the same logic. This point has nothing to do with AnnotateArgs
tho
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.
Ah I see , oh so thats already done now in the previous commit. I will remove it from AnnotateArgs
@comaniac I addressed your comments. PTAL again. cc: @anijain2305 |
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.
LGTM
Thanks @codeislife99 |
* Change annotate target * Annotate_target * Revert namespace changes * Add tests for if-else node * Add while_let testcase * No merging in ifelse * Remove scope builder * Add ops * Replace < with less * Linter * Pass Tests * Change back to static const * Cpplinter * address PR comments' * PR Comments * Clang-format check * PR Comments * PR Comments * Change back to Insert Ann in AnnotateARgs Co-authored-by: Ritwik Das <dasritwi@3c22fb14d7c6.ant.amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-3-223.us-west-2.compute.internal>
* Change annotate target * Annotate_target * Revert namespace changes * Add tests for if-else node * Add while_let testcase * No merging in ifelse * Remove scope builder * Add ops * Replace < with less * Linter * Pass Tests * Change back to static const * Cpplinter * address PR comments' * PR Comments * Clang-format check * PR Comments * PR Comments * Change back to Insert Ann in AnnotateARgs Co-authored-by: Ritwik Das <dasritwi@3c22fb14d7c6.ant.amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-3-223.us-west-2.compute.internal>
* Change annotate target * Annotate_target * Revert namespace changes * Add tests for if-else node * Add while_let testcase * No merging in ifelse * Remove scope builder * Add ops * Replace < with less * Linter * Pass Tests * Change back to static const * Cpplinter * address PR comments' * PR Comments * Clang-format check * PR Comments * PR Comments * Change back to Insert Ann in AnnotateARgs Co-authored-by: Ritwik Das <dasritwi@3c22fb14d7c6.ant.amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-3-223.us-west-2.compute.internal>
* Change annotate target * Annotate_target * Revert namespace changes * Add tests for if-else node * Add while_let testcase * No merging in ifelse * Remove scope builder * Add ops * Replace < with less * Linter * Pass Tests * Change back to static const * Cpplinter * address PR comments' * PR Comments * Clang-format check * PR Comments * PR Comments * Change back to Insert Ann in AnnotateARgs Co-authored-by: Ritwik Das <dasritwi@3c22fb14d7c6.ant.amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-3-223.us-west-2.compute.internal>
* Change annotate target * Annotate_target * Revert namespace changes * Add tests for if-else node * Add while_let testcase * No merging in ifelse * Remove scope builder * Add ops * Replace < with less * Linter * Pass Tests * Change back to static const * Cpplinter * address PR comments' * PR Comments * Clang-format check * PR Comments * PR Comments * Change back to Insert Ann in AnnotateARgs Co-authored-by: Ritwik Das <dasritwi@3c22fb14d7c6.ant.amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-3-223.us-west-2.compute.internal>
This PR adds changes to annotate_target to handle control flow(if-else nodes) and let nodes correctly.
Context: The Neo team was trying to compile TF MobileNet SSD model and since the model is dynamic we noticed that the if-else and let nodes are not getting correctly compiled. Therefore this PR addresses those fixes.