-
Notifications
You must be signed in to change notification settings - Fork 527
Adding qualcomm recipes #10036
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
tarun292
wants to merge
1
commit into
gh/tarun292/6/base
Choose a base branch
from
gh/tarun292/6/head
base: gh/tarun292/6/base
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
Adding qualcomm recipes #10036
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@fbcode_macros//build_defs:python_library.bzl", "python_library") | ||
|
||
python_library( | ||
name = "recipes", | ||
srcs = ["recipes.py"], | ||
deps = [ | ||
"//caffe2:torch", | ||
"//executorch/exir:lib", | ||
"//executorch/backends/qualcomm/quantizer:quantizer", | ||
"//executorch/examples/qualcomm:utils" | ||
] | ||
) |
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,71 @@ | ||
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. | ||
|
||
# pyre-strict | ||
from typing import Optional | ||
|
||
from executorch import exir | ||
from executorch.backends.qualcomm.quantizer.quantizer import QuantDtype | ||
|
||
from executorch.examples.qualcomm.utils import make_quantizer | ||
from executorch.exir import EdgeCompileConfig, ExecutorchBackendConfig, ExportRecipe | ||
from executorch.exir.passes import MemoryPlanningPass | ||
from torch.ao.quantization.quantizer import Quantizer | ||
|
||
def get_qualcomm_htp_et_recipe( | ||
name: str, | ||
soc_model: str = "SM8650", | ||
qnn_version: str = "2.25", | ||
quant_dtype: Optional[QuantDtype] = None, | ||
shared_buffer=False, | ||
skip_node_id_set: set[int] = set(), | ||
skip_node_op_set: set[str] = set(), | ||
) -> ExportRecipe: | ||
from executorch.backends.qualcomm.partition.qnn_partitioner import QnnPartitioner | ||
from executorch.backends.qualcomm.serialization.qc_schema import QcomChipset | ||
|
||
from executorch.backends.qualcomm.utils.utils import ( | ||
_transform, | ||
generate_htp_compiler_spec, | ||
generate_qnn_executorch_compiler_spec, | ||
) | ||
|
||
if quant_dtype: | ||
qnn_quantizer: Quantizer = make_quantizer(quant_dtype=quant_dtype) | ||
else: | ||
qnn_quantizer = make_quantizer() | ||
|
||
qnn_partitioner = QnnPartitioner( | ||
generate_qnn_executorch_compiler_spec( | ||
soc_model=getattr(QcomChipset, soc_model), | ||
backend_options=generate_htp_compiler_spec( | ||
use_fp16=False if quant_dtype else True | ||
), | ||
), | ||
skip_node_id_set=skip_node_id_set, | ||
skip_node_op_set=skip_node_op_set, | ||
) | ||
|
||
executorch_config = ExecutorchBackendConfig( | ||
# For shared buffer, user must pass the memory address | ||
# which is allocated by RPC memory to executor runner. | ||
# Therefore, won't want to pre-allocate | ||
# by memory manager in runtime. | ||
memory_planning_pass=MemoryPlanningPass( | ||
alloc_graph_input=not shared_buffer, | ||
alloc_graph_output=not shared_buffer, | ||
), | ||
) | ||
|
||
return ExportRecipe( | ||
name, | ||
quantizer=qnn_quantizer, | ||
partitioners=[qnn_partitioner], | ||
pre_edge_transform_passes=_transform, | ||
edge_compile_config=EdgeCompileConfig( | ||
_check_ir_validity=False, | ||
_skip_dim_order=True, | ||
), | ||
edge_transform_passes=[], | ||
transform_check_ir_validity=True, | ||
executorch_backend_config=executorch_config, | ||
) |
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
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.
Have we run this recipe in some models and showed it works properly?