-
Notifications
You must be signed in to change notification settings - Fork 961
NXP backend: Test avg_pool2d with new Neutron flow. #19147
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
Draft
MartinPavella
wants to merge
4
commits into
pytorch:main
Choose a base branch
from
nxp-upstream:nxg01483/EIEX-858-add-avg_pool2d-support-using-new-neutron-flow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
603dfe4
Unify `to_quantized_edge_program` and `to_quantized_executorch_progra…
MartinPavella eef4f6d
Move generic tests into a separate subdirectory.
MartinPavella c213c9f
Move files from `/tests_models` to `/tests`.
MartinPavella 0394b4d
NXP backend: Test `avg_pool2d` with new Neutron flow.
MartinPavella 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
Empty file.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Copyright 2025 NXP | ||
| # Copyright 2025-2026 NXP | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
@@ -21,6 +21,8 @@ | |
| from executorch.backends.nxp.backend.ir.tflite_generator.builtin_options import ( | ||
| average_pool_2d_options, | ||
| ) | ||
|
|
||
| from executorch.backends.nxp.backend.neutron_target_spec import NeutronTargetSpec | ||
| from torch.fx import Node | ||
| from torch.nn import Parameter | ||
|
|
||
|
|
@@ -53,6 +55,27 @@ def _is_supported_in_IR( | |
|
|
||
| return True | ||
|
|
||
| @staticmethod | ||
| def _is_supported_on_target( | ||
|
MartinPavella marked this conversation as resolved.
|
||
| node: Node, | ||
| neutron_target_spec: NeutronTargetSpec, | ||
| parameters_mapping: dict[str, Parameter], | ||
| custom_delegation_options: CustomDelegationOptions, | ||
| ) -> bool: | ||
| kernel = node.args[1] | ||
| stride = node.args[2] | ||
|
|
||
| if custom_delegation_options.use_new_flow_neutron_c: | ||
| # Requirements specified by the new Neutron flow documentation. | ||
|
|
||
| if any(k > 4096 for k in kernel): | ||
| return False | ||
|
|
||
| if any(s > 4096 for s in stride): | ||
| return False | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also check the input types as they are specified in docs. |
||
| return True | ||
|
|
||
| # noinspection PyMethodMayBeStatic | ||
| def _convert_2d_avg_pool( | ||
| self, kernel_size, stride, padding, t_op: tflite_model.Operator | ||
|
|
@@ -85,10 +108,19 @@ def _convert_2d_avg_pool( | |
|
|
||
| return ops.flatten() | ||
|
|
||
| # AvgPool2d Node format: (Tensor self, int[2] kernel_size, int[2] stride=[], int[2] padding=0, bool ceil_mode=False | ||
| # bool count_include_pad=True, int? divisor_override=None) | ||
| def convert(self, node: Node): | ||
| """Convert 'avg_pool2d' operator to TFLite 'AveragePool2D'.""" | ||
| """Convert 'avg_pool2d' operator to TFLite 'AveragePool2D'. | ||
| The ExecuTorch schema is: | ||
| aten.avg_pool2d( | ||
| Tensor self, | ||
| int[2] kernel_size, | ||
| int[2] stride=[], | ||
| int[2] padding=0, | ||
| bool ceil_mode=False | ||
| bool count_include_pad=True, | ||
| int? divisor_override=None | ||
| ) | ||
| """ | ||
| self.assert_convertible(node) | ||
|
|
||
| kernel_size = node.args[1] | ||
|
|
||
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
Empty file.
File renamed without changes.
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
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.
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.
Some comment would be good here.