-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[TIR] Cleanup of MakePackedAPI #14989
Draft
Lunderberg
wants to merge
6
commits into
apache:main
Choose a base branch
from
Lunderberg:make_packed_api_cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+148
−75
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
This resolves an issue introduced by the combination of apache#14918 and apache#14945. The bug occurred for targets that do not require device-side codegen, but do require a `device_type` other than `kDLCPU`. It wasn't caught by CI, as the issue only occurred with the combination of both PRs. 1. apache#14918 updated `SplitHostDevice` to only modify the `"target"` attribute when a device-side function has been extracted. 2. For VTA, there is no device-side function, as everything is done through host-side API calls. 3. From (1) and (2), the VTA examples kept the target `T.target("ext_dev", host="llvm")` after the `SplitHostDevice` pass, instead of being updated to `T.target("llvm")`. 4. apache#14945 restricted CombineContextCall to only apply to host-side passes. 5. From (4) and (5), the `CombineContextCall` pass was no longer applied to the VTA context calls. This PR fixes `SplitHostDevice`, updating the target from `T.target("ext_dev", host="llvm")` to `T.target("llvm")`, even if no device sections have been extracted from the function.
This simplifies the logic used in MakePackedAPI, that it the last user of the host parameter in a function's target. After MakePackedAPI, every PrimFunc has a "target" attribute without a "host".
Prior to this commit, the `RequiresPackedAPI` function checked whether a function needed the packed func API. This was used both to generate a list of call-sites to update, and as part of the updates to `PrimFunc` signatures. However, the function that updates the `PrimFunc` signature could still return the original function unmodified, breaking internal method calls. This occurred for functions with a `kTarget` attribute without a host. This commit updates `MakePackedAPI` to first update all `PrimFunc` signatures that require the packed func API, then use the result to determine which call-sites must be updated. This resolves the discrepancy for host-less target annotations, and removes the possibility of similar discrepancies in the future.
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 |
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, the
RequiresPackedAPI
function checked whether a function needed the packed func API. This was used both to generate a list of call-sites to update, and as part of the updates toPrimFunc
signatures. However, the function that updates thePrimFunc
signature could still return the original function unmodified, breaking internal method calls. This occurred for functions with akTarget
attribute without a host.This commit updates
MakePackedAPI
to first update allPrimFunc
signatures that require the packed func API, then use the result to determine which call-sites must be updated. This resolves the discrepancy for host-less target annotations, and removes the possibility of similar discrepancies in the future.