[Relay] Plumb external codegen target via Target.current()#11432
Merged
AndrewZhaoLuo merged 3 commits intoapache:mainfrom Jun 1, 2022
Merged
[Relay] Plumb external codegen target via Target.current()#11432AndrewZhaoLuo merged 3 commits intoapache:mainfrom
AndrewZhaoLuo merged 3 commits intoapache:mainfrom
Conversation
Contributor
Author
|
Hi @Mousius I think you're probably the only other person who can review this one! |
c65b2c8 to
04085b0
Compare
9753881 to
90aca0d
Compare
jwfromm
approved these changes
May 26, 2022
Contributor
jwfromm
left a comment
There was a problem hiding this comment.
This is very cool work that seems well designed to me. The only thing I'd like to see is a little documentation that points out all the pieces needed to make it work. For now, just having something brief in the python tests might be enough to get interested readers started.
c3fe805 to
70310d8
Compare
…ternal codegen paths (See https://discuss.tvm.apache.org/t/byoc-supporting-cutlass-byoc-with-collage/12796/6 for context, which in turn is part of Collage (https://github.com/apache/tvm-rfcs/blob/main/rfcs/0062-collage.md). We want both old-style (via relay.ext.$toolchain) and new-style (via "RelayToTIR" Pass attribute on target kind) external codegen to be able to access the current 'external codegen' Target instance via Target.current(). - For old-style, plumb the true Target through TEComplier and push it on the context stack before calling relay.ext.$toolchain. - For new-style, pass the CompilationConfig to the RelayToTIRTargetHook pass, make the jump from "Compiler" attribute value to Target via the new CompilationConfig::FindPrimitiveTargetForKind method, and push on the stack before invoking the custom "RelayToTIR" pass. While working on this discovered RelayToTIRTargetHook was incompatible with the VM's compilation flow since RelayToTIRTargetHook assumes all "Compiler" attributed functions are inlined. Generalize it to support both inline and global function styles. Extend Target::IsExternalCodegen to recognize target kinds with "RelayToTIR" attributes as external. Update target hooks unit test to exercise new support for outline-style, picking up the current target, and compiling via the VM.
Can't repro tests/python/contrib/test_ethosu/cascader/test_scheduler.py::test_compute_cycles_annotation failure, flake?
70310d8 to
673c5ce
Compare
Contributor
Author
|
@tvm-bot merge |
Contributor
|
Cannot merge, did not find any approving reviews from users with write access on 673c5ce |
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.
(See https://discuss.tvm.apache.org/t/byoc-supporting-cutlass-byoc-with-collage/12796/6 for
context, which in turn is part of Collage (https://github.com/apache/tvm-rfcs/blob/main/rfcs/0062-collage.md).
We want both old-style (via relay.ext.$toolchain) and new-style (via "RelayToTIR" Pass
attribute on target kind) external codegen to be able to access the current 'external codegen'
Target instance via Target.current().
For old-style, plumb the true Target through TEComplier and push it on the context
stack before calling relay.ext.$toolchain.
For new-style, pass the CompilationConfig to the RelayToTIRTargetHook pass, make the jump from
"Compiler" attribute value to Target via the new CompilationConfig::FindPrimitiveTargetForKind
method, and push on the stack before invoking the custom "RelayToTIR" pass.
While working on this discovered RelayToTIRTargetHook was incompatible with the VM's compilation
flow since RelayToTIRTargetHook assumes all "Compiler" attributed functions are inlined. Generalize
it to support both inline and global function styles.
Extend Target::IsExternalCodegen to recognize target kinds with "RelayToTIR" attributes as
external.
Update target hooks unit test to exercise new support for outline-style, picking up the current target,
and compiling via the VM. Also update the example pass to illustrate some of the common gotcha's
when implementing a custom lowering-like pass.