-
Notifications
You must be signed in to change notification settings - Fork 754
NXP backend: added aten.slice support #15889
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
NXP backend: added aten.slice support #15889
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15889
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit aaeddc1 with merge base 670bc11 ( UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: nxp" |
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Show resolved
Hide resolved
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
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.
Pull request overview
This PR adds support for the aten.slice operator to the NXP backend, enabling tensor slicing operations to be delegated to the Neutron hardware accelerator.
Key changes:
- Implements
SliceTensorConverterto convert PyTorch slice operations to TFLite slice operations with dimension transpositions when needed - Adds
SliceTensorPatternquantization pattern for the slice operator - Registers the converter in both partitioner and edge program converter
- Includes comprehensive test coverage for various slicing scenarios
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
backends/nxp/tests/models.py |
Adds SliceTensorModule and SliceTensorConvModule test models |
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py |
Comprehensive test suite for slice tensor conversion with various configurations |
backends/nxp/quantizer/patterns.py |
Defines SliceTensorPattern quantization pattern |
backends/nxp/quantizer/neutron_quantizer.py |
Registers the slice tensor pattern with the quantizer |
backends/nxp/neutron_partitioner.py |
Maps slice_copy.Tensor operation to SliceTensorConverter |
backends/nxp/backend/neutron_converter_manager.py |
Excludes HoistSliceAboveTranspose graph pass |
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py |
Core implementation of slice tensor conversion logic |
backends/nxp/backend/ir/converter/node_converters/ops_converters/__init__.py |
Exports SliceTensorConverter |
backends/nxp/backend/edge_program_converter.py |
Registers slice converter in edge program converter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
|
Thank you for the review, fixed found issues. |
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
backends/nxp/backend/ir/converter/node_converters/ops_converters/__init__.py
Show resolved
Hide resolved
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Outdated
Show resolved
Hide resolved
|
Fixed issues from second round of code review. Thank you for the feedback. |
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Show resolved
Hide resolved
backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py
Show resolved
Hide resolved
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Show resolved
Hide resolved
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py
Show resolved
Hide resolved
MartinPavella
left a comment
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.
Once the tests start working (and pass), we can merge.
|
Latest tests passed 🥳 |
Only 3 checks were run. Meta has currently disabled their CI due to some firewall changes. We will have to wait for them to fix it. In the meantime, feel free to keep this branch up-to-date with |
|
Please update the branch to enable the tests. |
|
@pytorchbot label "module: nxp" |
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sliced_tensor_rank = input_shape[dim] | ||
|
|
||
| end = int(np.clip(end, 0, sliced_tensor_rank)) | ||
| start = int(np.clip(start, 0, sliced_tensor_rank)) |
Copilot
AI
Dec 9, 2025
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.
The variable name sliced_tensor_rank is misleading. It stores the size of the dimension being sliced (input_shape[dim]), not the rank of the tensor. Consider renaming to sliced_dim_size or dim_size for clarity.
| sliced_tensor_rank = input_shape[dim] | |
| end = int(np.clip(end, 0, sliced_tensor_rank)) | |
| start = int(np.clip(start, 0, sliced_tensor_rank)) | |
| sliced_dim_size = input_shape[dim] | |
| end = int(np.clip(end, 0, sliced_dim_size)) | |
| start = int(np.clip(start, 0, sliced_dim_size)) |
|
We will need to get back to this once Neutron 25_12 is released. But for now, we can merge. |
Summary
adds support for aten.slice operator
Test plan
tests can be manually run using
pytest -c /dev/null backends/nxp/tests/cc @robert-kalmar @JakeStevens @digantdesai