-
Notifications
You must be signed in to change notification settings - Fork 712
Cortex_m backend: Add quantizer + avoid linear decomp #15459
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
Conversation
Changes to_edge_and_transform to to_edge which supports the preserver_ops arg of the EdgeCompileConfig to avoid decomposing of the linear op. This significantly simplifies lowering the linear operator as it does not have to be re-fused. Adds a cortex_m quantizer, with the intention to be general enough to be used for a general MCU. It is implemented as a ComposableQuantizer using multiple instances of a new OperatorConfigQuantizer class. This gives a number of abstraction levels for configuration - McuQuantizer - ComposableQuantizer - OperatorConfig - QuantizerConfig - QuantizationSpec The new quantizer also adds a transform_for_annotation pass pipeline which allows to fix scalar + tensor operations. Old test_quantize_op_fusion_pass test is removed since it is not relevant anymore after the add implementation has been redone. Change-Id: Ic1d5b48623a14d220cb1ba472948db6a1406e0b7 Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15459
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 364159b with merge base a11d555 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
|
|
||
| from executorch.backends.arm._passes import ScalarsToAttributePass |
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.
Do you plan to add "EdgeCompileConfig(preserve_ops...." step in CortexMPassManager to avoid decomposition ?
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.
Or "Do you plan to implement a CortexMPartitioner with ops_to_not_decompose() method to work with to_edge_transform_and_lower(), similar to how the Cadence backend handles operation preservation?"
executorch/backends/cadence/aot/compiler.py
Lines 275 to 277 in 007ccc6
| _core_aten_ops_exception_list=TO_EDGE_OP_EXCEPTION_LIST | |
| + (core_aten_exceptions or []), | |
| preserve_ops=TO_EDGE_PRESERVE_OPS, |
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.
I am rather neutral towards how the list of ops to not preserve should be implemented, do you have a preference? From what I noticed preserve_ops in EdgeCompileConfig does not do anything in to_edge_transfrom_and_lower however, only in to_edge.
Changes to_edge_and_transform to to_edge which supports the preserver_ops arg of the EdgeCompileConfig to avoid decomposing of the linear op. This significantly simplifies lowering the linear operator as it does not have to be re-fused. Adds a cortex_m quantizer, with the intention to be general enough to be used for a general MCU. It is implemented as a ComposableQuantizer using multiple instances of a new OperatorConfigQuantizer class. This gives a number of abstraction levels for configuration - McuQuantizer - ComposableQuantizer - OperatorConfig - QuantizerConfig - QuantizationSpec The new quantizer also adds a transform_for_annotation pass pipeline which allows to fix scalar + tensor operations. Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Changes to_edge_and_transform to to_edge which supports the preserver_ops arg of the EdgeCompileConfig to avoid decomposing of the linear op. This significantly simplifies lowering the linear operator as it does not have to be re-fused.
Adds a cortex_m quantizer, with the intention to be general enough to be used for a general MCU. It is implemented as a ComposableQuantizer using multiple instances of a new OperatorConfigQuantizer class. This gives a number of abstraction levels for configuration
The new quantizer also adds a transform_for_annotation pass pipeline which allows to fix scalar + tensor operations.
cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai