Skip to content

Conversation

@zhiics
Copy link
Member

@zhiics zhiics commented Feb 24, 2020

This PR adds inlining pass to Relay. It can help external codegen where we may want to outline the sub-functions (subgraphs) to the module level to prevent the from being optimized by relay passes. These functions can then be inlined and offloaded to external codegen tools as discussed in #4864

This transformation is also important to the Relay VM as inlining may reduce the calling overhead. We currently only greedily inline the functions that are marked inline whenever it is abled to be inlined. There is no profitability analysis available for now.

This PR is dependent on the call graph PR #4922

@zhiics zhiics force-pushed the inline_pass branch 3 times, most recently from a01ef84 to 1418249 Compare February 26, 2020 18:20
@zhiics
Copy link
Member Author

zhiics commented Feb 26, 2020

@masahi
Copy link
Member

masahi commented Feb 27, 2020

@zhiics can you rebase?

@zhiics
Copy link
Member Author

zhiics commented Feb 27, 2020

@masahi Done. Thanks.

@masahi
Copy link
Member

masahi commented Feb 28, 2020

@zhiics not sure if this is one of an intended use cases, but I think adding a test case for inlining a composite function would be a useful addition. (This is not a request but soft suggestion, feel free to ignore).

@zhiics
Copy link
Member Author

zhiics commented Feb 28, 2020

@masahi We have annotated functions with external compilers, no difference with composite if we need to add it. I don’t think we need to add it in this pr

@masahi
Copy link
Member

masahi commented Feb 29, 2020

Does this pass have any relation with InlinePrimitives pass? Do they have different use cases?
https://github.com/apache/incubator-tvm/blob/6798ba80d288e7c6132b30606b3cb70812579fe8/src/relay/backend/vm/inline_primitives.cc#L149-L160

@zhiics
Copy link
Member Author

zhiics commented Feb 29, 2020

@masahi inlineprimitives works on each function scope to inline the function lifted by anf. This pass handles functions at the global scope.

Copy link
Member

@masahi masahi left a comment

Choose a reason for hiding this comment

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

This is a cool use of the new call graph infra, LGTM.

@anijain2305 anijain2305 merged commit 0fb4836 into apache:master Mar 2, 2020
@anijain2305
Copy link
Contributor

Thanks @masahi @zhiics This is merged

@zhiics zhiics deleted the inline_pass branch March 2, 2020 22:40
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 16, 2020
* add inline pass

* IsInline -> IsMarkedInlined

* fix comment
zhiics added a commit to neo-ai/tvm that referenced this pull request Apr 17, 2020
* add inline pass

* IsInline -> IsMarkedInlined

* fix comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants