Skip to content

Conversation

@novak-vaclav
Copy link
Contributor

@novak-vaclav novak-vaclav commented Nov 19, 2025

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

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 19, 2025

🔗 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 (image):

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.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2025
@novak-vaclav
Copy link
Contributor Author

@pytorchbot label "release notes: nxp"

@pytorch-bot pytorch-bot bot added the release notes: nxp Changes to the NXP Neutron backend delegate label Nov 19, 2025
@novak-vaclav novak-vaclav marked this pull request as draft November 19, 2025 09:35
@novak-vaclav novak-vaclav marked this pull request as ready for review November 19, 2025 14:53
Copilot AI review requested due to automatic review settings November 25, 2025 13:42
Copy link
Contributor

Copilot AI left a 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 SliceTensorConverter to convert PyTorch slice operations to TFLite slice operations with dimension transpositions when needed
  • Adds SliceTensorPattern quantization 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.

@novak-vaclav
Copy link
Contributor Author

Thank you for the review, fixed found issues.
Please check the changes @MartinPavella

@novak-vaclav novak-vaclav requested a review from Copilot November 25, 2025 13:44
Copy link
Contributor

Copilot AI left a 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.

@novak-vaclav
Copy link
Contributor Author

Fixed issues from second round of code review. Thank you for the feedback.

Copilot AI review requested due to automatic review settings November 26, 2025 17:39
Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings December 1, 2025 09:19
Copy link
Contributor

Copilot AI left a 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.

Copy link
Collaborator

@MartinPavella MartinPavella left a 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.

@novak-vaclav
Copy link
Contributor Author

Latest tests passed 🥳

@MartinPavella
Copy link
Collaborator

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 main.

@MartinPavella
Copy link
Collaborator

Please update the branch to enable the tests.

@MartinPavella MartinPavella added the module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ label Dec 8, 2025
@novak-vaclav
Copy link
Contributor Author

@pytorchbot label "module: nxp"

Copilot AI review requested due to automatic review settings December 9, 2025 11:16
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +137 to +140
sliced_tensor_rank = input_shape[dim]

end = int(np.clip(end, 0, sliced_tensor_rank))
start = int(np.clip(start, 0, sliced_tensor_rank))
Copy link

Copilot AI Dec 9, 2025

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.

Suggested change
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))

Copilot uses AI. Check for mistakes.
@MartinPavella MartinPavella self-requested a review December 9, 2025 14:27
@MartinPavella
Copy link
Collaborator

We will need to get back to this once Neutron 25_12 is released. But for now, we can merge.

@MartinPavella MartinPavella merged commit 6cca6e6 into pytorch:main Dec 9, 2025
145 of 146 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants