[microNPU] Refactor Relay to TIR hook#10599
Merged
Merged
Conversation
manupak
requested changes
Mar 14, 2022
manupak
reviewed
Mar 14, 2022
e95d9f2 to
cf90859
Compare
manupak
requested changes
Mar 16, 2022
manupak
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the refactor. Overall it looks good.
Just two comments regarding the decorator name and I think we can avoid needing to declare to RelayToTIR() passes.
Refactors the Relay to TIR python hook for the NPU so that optimizations can be applied across the whole module and not just functions that will be offloaded to the NPU. A pass `OutlineCompilerFunctions` is introduced to outline NPU functions, which now happens before optimization passes are run (this previously happened after the prim_func had been created). In addition, optimization passes that should only run on NPU functions are now limited to running on outlined functions for the NPU (by checking the "Compiler" attribute). To help avoid code duplication, a helpful decorator `create_npu_function_pass` has been created for python passes that should only run on NPU functions. This refactor helps move a number of passes in the microNPU codegen to use an IRModule -> IRModule philosophy. Change-Id: Icdea9ba43da0157d5ee17529d2b23b761396d112
Change-Id: I3ca48738e096bb0f4dc362f0e9550317fc0d5afd
This commit renames `npu_pass` -> `create_npu_function_pass`. It also renames the `RelayToTIR` pass created in Python to `LowerToTIR`, along with moving it to compiler.py to make it clear that this pass is a wrapper around the `_lower_to_tir` function. In addition, to make it explicit that the `lower_to_tir` func->func pass should not be used directly it has been renamed to `_lower_to_tir` - it is being maintained since it is used in many tests. Change-Id: I3a0a06801f029aeaa4a51c2d86d8703bb0d7afbb
cf90859 to
92dee34
Compare
manupak
approved these changes
Mar 18, 2022
manupak
left a comment
Contributor
There was a problem hiding this comment.
LGTM!
@ekalda @NicolaLancellotti please take a look..
ekalda
approved these changes
Mar 18, 2022
ekalda
left a comment
Contributor
There was a problem hiding this comment.
Nice work, looks good to me! :)
Contributor
|
Nice! I ll merge when the CI is green |
Change-Id: I44c64de15fa8680cc89ce0440ffa6c9e0ec62a50
a12e806 to
94fd3cd
Compare
Contributor
|
Thanks @lhutton1 @NicolaLancellotti @ekalda |
pfk-beta
pushed a commit
to pfk-beta/tvm
that referenced
this pull request
Apr 11, 2022
* [microNPU] Refactor Relay to TIR hook Refactors the Relay to TIR python hook for the NPU so that optimizations can be applied across the whole module and not just functions that will be offloaded to the NPU. A pass `OutlineCompilerFunctions` is introduced to outline NPU functions, which now happens before optimization passes are run (this previously happened after the prim_func had been created). In addition, optimization passes that should only run on NPU functions are now limited to running on outlined functions for the NPU (by checking the "Compiler" attribute). To help avoid code duplication, a helpful decorator `create_npu_function_pass` has been created for python passes that should only run on NPU functions. This refactor helps move a number of passes in the microNPU codegen to use an IRModule -> IRModule philosophy. Change-Id: Icdea9ba43da0157d5ee17529d2b23b761396d112 * add mixed compilers to test Change-Id: I3ca48738e096bb0f4dc362f0e9550317fc0d5afd * Address comments including renaming both npu_pass and RelayToTIR This commit renames `npu_pass` -> `create_npu_function_pass`. It also renames the `RelayToTIR` pass created in Python to `LowerToTIR`, along with moving it to compiler.py to make it clear that this pass is a wrapper around the `_lower_to_tir` function. In addition, to make it explicit that the `lower_to_tir` func->func pass should not be used directly it has been renamed to `_lower_to_tir` - it is being maintained since it is used in many tests. Change-Id: I3a0a06801f029aeaa4a51c2d86d8703bb0d7afbb * address nit and small fix to example Change-Id: I44c64de15fa8680cc89ce0440ffa6c9e0ec62a50
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.
Refactors the Relay to TIR python hook for the NPU so that optimizations can be applied across the whole module and not just functions that will be offloaded to the NPU. A pass
OutlineCompilerFunctionsis introduced to outline NPU functions, which now happens before optimization passes are run (this previously happened after the prim_func had been created).In addition, optimization passes that should only run on NPU functions are now limited to running on outlined functions for the NPU (by checking the "Compiler" attribute). To help avoid code duplication, a helpful decorator
npu_passhas been created for python passes that should only run on NPU functions.This refactor helps move a number of passes in the microNPU codegen to use an IRModule -> IRModule philosophy.
cc @manupa-arm @ekalda @NicolaLancellotti @dchauhan-arm