Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/qualcomm/debugger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pip install qairt-visualizer
## Quick start
This command launches an interactive GUI interface to visualize the `optrace` and `QHAS` results.
```
python -m examples.qualcomm.util_scripts.qairt_visualizer_demo -H ${host} -s {device} -b build-android -a ${path_to_output_folder} --online_prepare
python -m examples.qualcomm.util_scripts.qairt_visualizer_demo -H ${host} -s {device} -m ${SOC_MODEL} -b build-android -a ${path_to_output_folder} --online_prepare
```
- If online prepare mode is `enabled`, the following artifacts will be generated:
- `model`.dlc
Expand Down
16 changes: 7 additions & 9 deletions backends/qualcomm/debugger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import tempfile
from pathlib import Path
from typing import Tuple
from typing import Sequence, Tuple

import executorch.backends.qualcomm.python.PyQnnManagerAdaptor as PyQnnManager
import pandas as pd
Expand Down Expand Up @@ -217,9 +217,6 @@ def __init__(
"backend_extensions": {
"config_file_path": "config.json",
},
"features": {
"qhas_json": True,
},
},
"config": {
"devices": [
Expand Down Expand Up @@ -316,9 +313,6 @@ def qnn_net_run(self, graph_name="forward.serialized"):
), f"Error: qnn-profiling-data_0.log not found in {self.tmp_dir}"

def qnn_profile_viewer(self, graph_name="forward_schematic", graph_idx=0):
self.config["backend_extension_config"]["backend_extensions"][
"shared_library_path"
] = "./libQnnHtpNetRunExtensions.so"
self.config["backend_extension_config"] = {"features": {"qhas_json": True}}
for file_name, data in self.config.items():
with open(f"{self.tmp_dir}/{file_name}.json", "w") as json_file:
Expand Down Expand Up @@ -398,7 +392,11 @@ def generate_optrace(


def generate_optrace(
artifact, soc_id: QcomChipset, adb, pte_path: str, inputs: Tuple[torch.Tensor]
artifact,
soc_id: QcomChipset,
adb,
pte_path: str,
inputs: Sequence[Tuple[torch.Tensor]],
):
"""
Generate optrace and QHAS (QNN HTP Analysis Summary) JSON files.
Expand All @@ -407,7 +405,7 @@ def generate_optrace(
artifact (str): Path to the artifact folder.
adb (SimpleADB): An object for communicating with Android device
pte_path (str): The path to the generated PTE file, including the file extension (e.g., model.pte).
inputs (Tuple[torch.Tensor]): The input tensors for the model.
inputs Sequence((Tuple[torch.Tensor])): The input tensors for the model.


Returns:
Expand Down
12 changes: 11 additions & 1 deletion backends/qualcomm/tests/test_qnn_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8765,7 +8765,17 @@ def test_debugger_generate_optrace(self):
for _, (optrace, qhas) in msg["binaries_trace"].items():
with open(optrace, "r") as optrace_file:
optrace_data = json.load(optrace_file)
for row in optrace_data:
# {
# header:
# {
# 'header_version': {'major': x, 'minor': y, 'patch': z},
# 'version': {'major': x, 'minor': y, 'patch': z},
# 'artifact_type': 'OP_TRACE'
# }
# traceEvents:
# {...}
# }
for row in optrace_data["traceEvents"]:
self.assertIn("pid", row)
with open(qhas, "r") as qhas_file:
qhas_data = json.load(qhas_file)
Expand Down
8 changes: 4 additions & 4 deletions examples/qualcomm/util_scripts/qairt_visualizer_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@

def main(args) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have tests for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out!

We already have a test covering this test here:
https://github.com/pytorch/executorch/blob/main/backends/qualcomm/tests/test_qnn_delegate.py#L8176
In one of the earlier changes, this test was already failing in internal CI, but that failure wasn’t noticed at that time.
It’s now passing and can be used as expected.

model = SimpleModel()
example_input = (torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28))
example_inputs = [(torch.ones(1, 32, 28, 28), torch.ones(1, 32, 28, 28))]

pte_filename = "qnn_simple_model"
os.makedirs(args.artifact, exist_ok=True)

# lower to QNN
build_executorch_binary(
model,
example_input,
example_inputs[0],
args.model,
f"{args.artifact}/{pte_filename}",
[example_input],
example_inputs,
quant_dtype=QuantDtype.use_8a8w,
online_prepare=args.online_prepare,
optrace=True,
Expand All @@ -56,7 +56,7 @@ def main(args) -> None:
get_soc_to_chipset_map()[args.model],
adb,
f"{args.artifact}/{pte_filename}.pte",
example_input,
example_inputs,
)

if args.ip and args.port != -1:
Expand Down
Loading