Skip to content
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

Merged
merged 19 commits into from
Oct 13, 2020
Merged

[BYOC] Support control flow in annotate_target #6641

merged 19 commits into from
Oct 13, 2020

Conversation

codeislife99
Copy link
Contributor

@codeislife99 codeislife99 commented Oct 7, 2020

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.

@leandron
Copy link
Contributor

leandron commented Oct 7, 2020

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.

@junrushao
Copy link
Member

Hey Ritwik, nice to see you here :-)

Would you love to provide some context of this change? Also CC @comaniac @zhiics.

@codeislife99 codeislife99 marked this pull request as draft October 7, 2020 16:05
@comaniac comaniac self-assigned this Oct 7, 2020
@codeislife99 codeislife99 marked this pull request as ready for review October 9, 2020 20:32
@codeislife99
Copy link
Contributor Author

codeislife99 commented Oct 9, 2020

@leandron @junrushao1994 The PR is now ready for review. Please take a look.
cc: @comaniac @zhiics

@tqchen tqchen changed the base branch from master to main October 11, 2020 18:17
@anijain2305
Copy link
Contributor

@leandron @junrushao1994 The description is updated. PTAL.

Copy link
Contributor

@comaniac comaniac left a 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.

src/relay/transforms/annotate_target.cc Show resolved Hide resolved
src/relay/transforms/annotate_target.cc Outdated Show resolved Hide resolved
return std::move(new_expr);
}

Expr InsertCompilerEnd(const Expr& expr) {
Copy link
Contributor

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.

Copy link
Contributor Author

@codeislife99 codeislife99 Oct 12, 2020

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 ?

Copy link
Contributor

@comaniac comaniac Oct 12, 2020

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

Copy link
Contributor Author

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 comaniac changed the title Modify annotate_target [BYOC] Support control flow in annotate_target Oct 12, 2020
@codeislife99
Copy link
Contributor Author

codeislife99 commented Oct 12, 2020

@comaniac I addressed your comments. PTAL again. cc: @anijain2305

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@comaniac comaniac merged commit d5728bd into apache:main Oct 13, 2020
@comaniac
Copy link
Contributor

Thanks @codeislife99

@codeislife99 codeislife99 deleted the annotate_target branch October 13, 2020 04:21
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
* 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>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
* 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>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* 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>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
* 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>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants