-
Notifications
You must be signed in to change notification settings - Fork 695
Arm backend: Make NSS unit tests public #14891
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
Open
Michiel-Olieslagers
wants to merge
2
commits into
pytorch:main
Choose a base branch
from
Michiel-Olieslagers:change-1091845
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,138 @@ | ||
| # Copyright 2025 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| from typing import Tuple | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from executorch.backends.arm.test import common | ||
| from executorch.backends.arm.test.tester.test_pipeline import ( | ||
| EthosU55PipelineINT, | ||
| EthosU85PipelineINT, | ||
| TosaPipelineFP, | ||
| TosaPipelineINT, | ||
| VgfPipeline, | ||
| ) | ||
|
|
||
| from huggingface_hub import hf_hub_download | ||
|
|
||
| from ng_model_gym.usecases.nss.model.model_blocks import AutoEncoderV1 | ||
|
|
||
| input_t = Tuple[torch.Tensor] # Input x | ||
|
|
||
|
|
||
| class NSS(torch.nn.Module): | ||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self.auto_encoder = AutoEncoderV1() | ||
|
|
||
|
|
||
| def nss() -> AutoEncoderV1: | ||
| """Get an instance of NSS with weights loaded.""" | ||
|
|
||
| weights = hf_hub_download( | ||
| repo_id="Arm/neural-super-sampling", filename="nss_v0.1.0_fp32.pt" | ||
| ) | ||
|
|
||
| nss_model = NSS() | ||
| nss_model.load_state_dict( | ||
| torch.load(weights, map_location=torch.device("cpu"), weights_only=True), | ||
| strict=False, | ||
| ) | ||
| return nss_model.auto_encoder | ||
|
|
||
|
|
||
| def example_inputs(): | ||
| return (torch.randn((1, 12, 544, 960)),) | ||
|
|
||
|
|
||
| def test_nss_tosa_FP(): | ||
| pipeline = TosaPipelineFP[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_op=[], | ||
| exir_op=[], | ||
| use_to_edge_transform_and_lower=True, | ||
| ) | ||
| pipeline.add_stage_after("export", pipeline.tester.dump_operator_distribution) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| def test_nss_tosa_INT(): | ||
| pipeline = TosaPipelineINT[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_op=[], | ||
| exir_op=[], | ||
| use_to_edge_transform_and_lower=True, | ||
| ) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="No support for aten_upsample_nearest2d_vec on U55") | ||
| @common.XfailIfNoCorstone300 | ||
| def test_nss_u55_INT(): | ||
| pipeline = EthosU55PipelineINT[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_ops=[], | ||
| exir_ops=[], | ||
| run_on_fvp=True, | ||
| use_to_edge_transform_and_lower=True, | ||
| ) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| @pytest.mark.skip( | ||
| reason="Fails at input memory allocation for input shape: [1, 12, 544, 960]" | ||
| ) | ||
| @common.XfailIfNoCorstone320 | ||
| def test_nss_u85_INT(): | ||
| pipeline = EthosU85PipelineINT[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_ops=[], | ||
| exir_ops=[], | ||
| run_on_fvp=True, | ||
| use_to_edge_transform_and_lower=True, | ||
| ) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| @pytest.mark.xfail( | ||
| reason="[MLETORCH-1430]: Double types are not supported in buffers in MSL" | ||
| ) | ||
| @common.SkipIfNoModelConverter | ||
| def test_nss_vgf_FP(): | ||
| pipeline = VgfPipeline[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_op=[], | ||
| exir_op=[], | ||
| tosa_version="TOSA-1.0+FP", | ||
| use_to_edge_transform_and_lower=True, | ||
| run_on_vulkan_runtime=True, | ||
| ) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| @common.SkipIfNoModelConverter | ||
| def test_nss_vgf_INT(): | ||
| pipeline = VgfPipeline[input_t]( | ||
| nss().eval(), | ||
| example_inputs(), | ||
| aten_op=[], | ||
| exir_op=[], | ||
| tosa_version="TOSA-1.0+INT", | ||
| symmetric_io_quantization=True, | ||
| use_to_edge_transform_and_lower=True, | ||
| run_on_vulkan_runtime=True, | ||
| ) | ||
| pipeline.run() | ||
|
|
||
|
|
||
| ModelUnderTest = nss().eval() | ||
| ModelInputs = example_inputs() |
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.
do you want to pin it to a tag or sha?