[TIR] Handle callees on same target, different codegen#14988
Merged
masahi merged 2 commits intoapache:mainfrom Jun 4, 2023
Merged
[TIR] Handle callees on same target, different codegen#14988masahi merged 2 commits intoapache:mainfrom
masahi merged 2 commits intoapache:mainfrom
Conversation
Collaborator
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
Contributor
Author
masahi
reviewed
Jun 2, 2023
| Optional<Target> current_target_; | ||
| std::unordered_map<const GlobalVarNode*, KernelInfo> device_info_map_; | ||
| std::unordered_set<const GlobalVarNode*> device_kernel_launch_; | ||
| std::unordered_set<const GlobalVarNode*> extern_method_call_; |
Member
There was a problem hiding this comment.
method -> func? Since we don't use that term.
Contributor
Author
There was a problem hiding this comment.
Good point, and renamed extern_method_call_ to extern_function_call_.
Prior to this commit, any caller that uses a different `Target` than
its callee is lowered to a device-kernel launch. However, if the
caller and callee are on the same device, despite using a different
target (e.g. `Target("llvm")` and `Target("c")` both use `kDLCPU`),
then the kernel launch is unnecessary.
This commit updates `LowerDeviceKernelLaunch` to produce a kernel
launch only when the callee is on another device, and to produce
`T.call_extern` for callees on the same device.
0f74875 to
922df81
Compare
Contributor
Author
junrushao
pushed a commit
to junrushao/tvm
that referenced
this pull request
Jun 22, 2023
* [TIR] Handle callees on same target, different codegen
Prior to this commit, any caller that uses a different `Target` than
its callee is lowered to a device-kernel launch. However, if the
caller and callee are on the same device, despite using a different
target (e.g. `Target("llvm")` and `Target("c")` both use `kDLCPU`),
then the kernel launch is unnecessary.
This commit updates `LowerDeviceKernelLaunch` to produce a kernel
launch only when the callee is on another device, and to produce
`T.call_extern` for callees on the same device.
* Rename "extern_method_call_" to "extern_function_call_"
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.
Prior to this commit, any caller that uses a different
Targetthan its callee is lowered to a device-kernel launch. However, if the caller and callee are on the same device, despite using a different target (e.g.Target("llvm")andTarget("c")both usekDLCPU), then the kernel launch is unnecessary.This commit updates
LowerDeviceKernelLaunchto produce a kernel launch only when the callee is on another device, and to produceT.call_externfor callees on the same device.