Skip to content

NXP backend: Unify testing infrastructure.#19112

Open
MartinPavella wants to merge 6 commits intopytorch:mainfrom
nxp-upstream:nxg01483/EIEX-896-unify-lowering-and-testing-functions
Open

NXP backend: Unify testing infrastructure.#19112
MartinPavella wants to merge 6 commits intopytorch:mainfrom
nxp-upstream:nxg01483/EIEX-896-unify-lowering-and-testing-functions

Conversation

@MartinPavella
Copy link
Copy Markdown
Collaborator

@MartinPavella MartinPavella commented Apr 24, 2026

Summary

Unify infrastructure for tests comparing edge dialect <-> Neutron IR with tests comparing lowered edge programs <-> lowered Neutron delegated programs.

Test plan

Tested by all existing tests.

cc @robert-kalmar @JakeStevens @digantdesai

@MartinPavella MartinPavella self-assigned this Apr 24, 2026
@MartinPavella MartinPavella added the module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ label Apr 24, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 24, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19112

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 15 New Failures

As of commit 52cac91 with merge base 32a6cec (image):

NEW FAILURES - The following jobs have failed:

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 Apr 24, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@MartinPavella
Copy link
Copy Markdown
Collaborator Author

MartinPavella commented Apr 24, 2026

Corresponding internal PR is here.
The internal CI build is here.

Comment thread backends/nxp/tests/generic_tests/test_aot_example.py Outdated
@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-896-unify-lowering-and-testing-functions branch 2 times, most recently from b1d018f to c213c9f Compare April 27, 2026 06:02
@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-896-unify-lowering-and-testing-functions branch 2 times, most recently from 624eae4 to 61606df Compare April 27, 2026 08:27
@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-896-unify-lowering-and-testing-functions branch 2 times, most recently from 7171bff to 8f5cc1d Compare April 27, 2026 11:44
) -> EdgeProgramManager:
calibration_inputs = get_random_calibration_inputs(to_model_input_spec(input_spec))

example_input = calibration_inputs[0]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should also use
example_input = _get_example_input(input_spec)

case _:
raise ValueError(f"Unsupported dim_order: {spec.dim_order}")

sample_vector = rng.random(np.prod(shape), spec.type).reshape(shape)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

from executorch.backends.nxp.backend.ir.converter.conversion.translator import torch_type_to_numpy_type`

sample_vector = rng.random(np.prod(shape), torch_type_to_numpy_type(spec.dtype)).reshape(shape)

@dataclass
class ModelInputSpec:
shape: tuple[int, ...]
type: np.dtype = np.float32
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add separate numpy type, keep only torch type. Adding numpy type means duplicity and space for unequal numpy and torch types. It was pointed to me by some external dev I don't remember when I added it several months ago, so I removed it. I use conversion function
from executorch.backends.nxp.backend.ir.converter.conversion.translator import torch_type_to_numpy_type
in dataset_creator.py.
https://github.com/pytorch/executorch/pull/19112/changes#r3147341415

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for moving tests to generic dir.

raise ValueError(f"Unsupported dim_order: {spec.dim_order}")

sample_vector = rng.random(np.prod(shape), spec.type).reshape(shape)
sample_vector.tofile(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file_name = f"{str(spec_idx).zfill(2)}.bin" if len(input_spec) > 1 else f"{str(idx).zfill(4)}.bin"
sample_vector.tofile(os.path.join(sample_dir, file_name))

This is the fix data creation for single model input.

Comment thread backends/nxp/__init__.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those inits needed or were they added by IDE?

@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-896-unify-lowering-and-testing-functions branch from ea50847 to 352195d Compare April 27, 2026 13:16
Change type: ignore[import-not-found] to type: ignore[import] to match
MYPY's expected error code for these dynamic module imports.
@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-896-unify-lowering-and-testing-functions branch from 352195d to 52cac91 Compare April 27, 2026 13:51
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/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants