-
Notifications
You must be signed in to change notification settings - Fork 755
NXP backend: added aten.mul support #15971
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
Merged
MartinPavella
merged 15 commits into
pytorch:main
from
nxp-upstream:feature/EIEX-539-add-aten-mul-operator
Dec 9, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
101b5fd
wip
novak-vaclav ec37f23
wip
novak-vaclav 537fb52
wip
novak-vaclav 6bc302f
wip
novak-vaclav e07fde1
Merge branch 'main' into feature/EIEX-539-add-aten-mul-operator
novak-vaclav 2c169d8
wip
novak-vaclav a2c1129
Merge branch 'main' into feature/EIEX-539-add-aten-mul-operator
novak-vaclav dc08c6a
wip
novak-vaclav 0945db5
Update backends/nxp/quantizer/patterns.py
novak-vaclav 8caaef6
Update backends/nxp/quantizer/patterns.py
novak-vaclav 08cbd87
Update backends/nxp/quantizer/patterns.py
novak-vaclav 296c66a
Update backends/nxp/backend/ir/converter/node_converters/ops_converte…
novak-vaclav 6027abc
wip
novak-vaclav 64ce509
Merge branch 'main' into feature/EIEX-539-add-aten-mul-operator
novak-vaclav b25bcdd
Update backends/nxp/tests/ir/converter/node_converter/test_mul_tensor…
novak-vaclav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
61 changes: 61 additions & 0 deletions
61
backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Copyright 2025 NXP | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| from executorch.backends.nxp.backend.ir.converter.conversion.common import ( | ||
| node_uses_shape_broadcasting, | ||
| ) | ||
| from executorch.backends.nxp.backend.ir.converter.node_converter import ( | ||
| CustomDelegationOptions, | ||
| NodeConverter, | ||
| ) | ||
| from executorch.backends.nxp.backend.ir.tflite_generator.builtin_options import ( | ||
| mul_options, | ||
| ) | ||
| from executorch.backends.nxp.backend.neutron_target_spec import NeutronTargetSpec | ||
| from torch.fx import Node | ||
| from torch.nn import Parameter | ||
|
|
||
|
|
||
| class MulTensorConverter(NodeConverter): | ||
| @staticmethod | ||
| def _is_supported_on_target( | ||
| node: Node, | ||
| neutron_target_spec: NeutronTargetSpec, | ||
| parameters_mapping: dict[str, Parameter], | ||
| custom_delegation_options: CustomDelegationOptions, | ||
| ) -> bool: | ||
| if node_uses_shape_broadcasting(node): | ||
| # Shape broadcasting may require the addition of `Transpose` ops during conversion. | ||
| return False | ||
|
|
||
| node_shape = node.meta["val"].shape | ||
|
|
||
| # Check that at least one dimension is divisible by number of MACS | ||
| # or all dimensions are equal to one | ||
| # Otherwise Neutron cannot convert it | ||
| dim_divisible = any(s % 8 == 0 for s in node_shape) or all( | ||
| s == 1 for s in node_shape | ||
| ) | ||
| return dim_divisible | ||
|
|
||
| @staticmethod | ||
| def _is_supported_in_IR( | ||
| node: Node, | ||
| parameters_mapping: dict[str, Parameter], | ||
| custom_delegation_options: CustomDelegationOptions, | ||
| ) -> bool: | ||
| if len(node.args) != 2: | ||
| return False | ||
|
|
||
| return True | ||
|
|
||
| # mul.Tensor Node format: (Tensor self, Tensor other, *) | ||
| def convert(self, node: Node): | ||
| """Convert 'mul_tensor' operator to NeutronIR 'Mul'.""" | ||
| self.assert_convertible(node) | ||
| t_op = self._create_tflite_op_with_io_tensors(node) | ||
| t_op.builtin_options = mul_options.Mul() | ||
|
|
||
| self.builder.append_operators([t_op]) | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.