-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[microNPU] Refactor Relay to TIR hook #10599
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An early comment -- I ll do a full pass later.
e95d9f2
to
cf90859
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ekalda @NicolaLancellotti please take a look..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, looks good to me! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Nice! I ll merge when the CI is green |
Change-Id: I44c64de15fa8680cc89ce0440ffa6c9e0ec62a50
a12e806
to
94fd3cd
Compare
Thanks @lhutton1 @NicolaLancellotti @ekalda |
* [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
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
npu_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.
cc @manupa-arm @ekalda @NicolaLancellotti @dchauhan-arm