-
Notifications
You must be signed in to change notification settings - Fork 752
[Backend Tester] Add Qualcomm tester and register flow #12739
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
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
f120e70
Update
GregoryComer 0fb85e6
Update
GregoryComer 4d8d844
Update
GregoryComer dc12b40
Update
GregoryComer ead0616
Update
GregoryComer 0f13676
Update
GregoryComer b0b01f2
Update
GregoryComer 8b9c9ef
Update
GregoryComer 06bf03a
Update
GregoryComer 2f8f49b
Update
GregoryComer 8ca7766
Update
GregoryComer bffb95f
Update
GregoryComer d21492b
Update
GregoryComer e2c4ea5
Update
GregoryComer 8230848
Update
GregoryComer 2a1f564
Update
GregoryComer b35e7b1
Update
GregoryComer 5c4c6ce
Update
GregoryComer 9397803
Update
GregoryComer 9dfeb5a
Update
GregoryComer ff5c4a5
Update
GregoryComer 42a5de5
Update
GregoryComer 402d8f5
Update
GregoryComer 34d3ab3
Update
GregoryComer 1105e04
Update
GregoryComer 482bd21
Update
GregoryComer ea548b7
Update
GregoryComer 4108f54
Update
GregoryComer 7ef236b
Update
GregoryComer 4a58c9d
Update
GregoryComer 3b866b4
Update
GregoryComer 5ba25cb
Update
GregoryComer 81dfb07
Update
GregoryComer 4d50265
Update
GregoryComer 5f66043
Update
GregoryComer 24e919d
Update
GregoryComer 523cc20
Update
GregoryComer 74c95fe
Update
GregoryComer 89757ce
Update
GregoryComer 423f79a
Update
GregoryComer 69f7f9c
Update
GregoryComer c0f6224
Update
GregoryComer 7a2fab5
Update
GregoryComer 033c231
Update
GregoryComer a9ed762
Update
GregoryComer 64b174a
Update
GregoryComer 27cd171
Update
GregoryComer 7bdd3e5
Update
GregoryComer b1254cd
Update
GregoryComer f2e2289
Update
GregoryComer e2df06e
Update
GregoryComer 4461bd8
Update
GregoryComer 7e97fd0
Update
GregoryComer 11a5a02
Update
GregoryComer 244b146
Update
GregoryComer 4ae840d
Update
GregoryComer 710ea49
Update
GregoryComer 2eb59fc
Update
GregoryComer dd09555
Update
GregoryComer f261355
Update
GregoryComer 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # 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 Any, List, Optional, Tuple | ||
|
|
||
| import executorch | ||
| import executorch.backends.test.harness.stages as BaseStages | ||
|
|
||
| import torch | ||
| from executorch.backends.qualcomm._passes.qnn_pass_manager import QnnPassManager | ||
| from executorch.backends.qualcomm.partition.qnn_partitioner import QnnPartitioner | ||
| from executorch.backends.qualcomm.utils.utils import ( | ||
| generate_htp_compiler_spec, | ||
| generate_qnn_executorch_compiler_spec, | ||
| get_soc_to_chipset_map, | ||
| ) | ||
| from executorch.backends.test.harness import Tester as TesterBase | ||
| from executorch.backends.test.harness.stages import StageType | ||
| from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower | ||
| from executorch.exir.backend.partitioner import Partitioner | ||
| from torch.export import ExportedProgram | ||
|
|
||
|
|
||
| class Partition(BaseStages.Partition): | ||
| def __init__(self, partitioner: Optional[Partitioner] = None): | ||
| super().__init__( | ||
| partitioner=partitioner or QnnPartitioner, | ||
| ) | ||
|
|
||
|
|
||
| class ToEdgeTransformAndLower(BaseStages.ToEdgeTransformAndLower): | ||
| def __init__( | ||
| self, | ||
| partitioners: Optional[List[Partitioner]] = None, | ||
| edge_compile_config: Optional[EdgeCompileConfig] = None, | ||
| soc_model: str = "SM8650", | ||
| ): | ||
| backend_options = generate_htp_compiler_spec(use_fp16=True) | ||
| self.chipset = get_soc_to_chipset_map()[soc_model] | ||
| self.compiler_specs = generate_qnn_executorch_compiler_spec( | ||
| soc_model=self.chipset, | ||
| backend_options=backend_options, | ||
| ) | ||
|
|
||
| super().__init__( | ||
| partitioners=partitioners or [QnnPartitioner(self.compiler_specs)], | ||
| edge_compile_config=edge_compile_config | ||
| or EdgeCompileConfig(_check_ir_validity=False), | ||
| default_partitioner_cls=QnnPartitioner, | ||
| ) | ||
|
|
||
| def run(self, artifact: ExportedProgram, inputs=None) -> None: | ||
| ep = QnnPassManager().transform_for_export_pipeline(artifact) | ||
| transform_passes = QnnPassManager().get_to_edge_transform_passes(ep) | ||
|
|
||
| self.edge_dialect_program = to_edge_transform_and_lower( | ||
| ep, | ||
| transform_passes=transform_passes, | ||
| partitioner=self.partitioners, | ||
| compile_config=self.edge_compile_conf, | ||
| ) | ||
|
|
||
|
|
||
| class QualcommTester(TesterBase): | ||
| def __init__( | ||
| self, | ||
| module: torch.nn.Module, | ||
| example_inputs: Tuple[torch.Tensor], | ||
| dynamic_shapes: Optional[Tuple[Any]] = None, | ||
| ): | ||
| # Specialize for Qualcomm | ||
| stage_classes = ( | ||
| executorch.backends.test.harness.Tester.default_stage_classes() | ||
| | { | ||
| StageType.PARTITION: Partition, | ||
| StageType.TO_EDGE_TRANSFORM_AND_LOWER: ToEdgeTransformAndLower, | ||
| } | ||
| ) | ||
|
|
||
| super().__init__( | ||
| module=module, | ||
| stage_classes=stage_classes, | ||
| example_inputs=example_inputs, | ||
| dynamic_shapes=dynamic_shapes, | ||
| ) |
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,17 @@ | ||
| from executorch.backends.qualcomm.tests.tester import QualcommTester | ||
| from executorch.backends.test.suite.flow import TestFlow | ||
|
|
||
|
|
||
| def _create_qualcomm_flow( | ||
| name: str, | ||
| quantize: bool = False, | ||
| ) -> TestFlow: | ||
| return TestFlow( | ||
| name, | ||
| backend="qualcomm", | ||
| tester_factory=QualcommTester, | ||
| quantize=quantize, | ||
| ) | ||
|
|
||
|
|
||
| QUALCOMM_TEST_FLOW = _create_qualcomm_flow("qualcomm") | ||
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.
Are we able to run some tests now?
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.
Meta-internal can run the backend tests on QNN. We'll need to finish setting up pybindings to run this in OSS. I started looking at this and there's some pybind11 bindings that are needed, which I plan to take a look at next sprint. Once that's set up, it should be runnable in OSS.