Skip to content
Open
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
28 changes: 21 additions & 7 deletions examples/qualcomm/custom_op/custom_ops_1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) Qualcomm Innovation Center, Inc.
# All rights reserved
#
Expand Down Expand Up @@ -178,10 +178,6 @@
# ensure the working directory exist.
os.makedirs(args.artifact, exist_ok=True)

quant_dtype = QuantDtype.use_8a8w
if args.use_fp16:
quant_dtype = None

instance = Model()
pte_filename = "custom_qnn"
sample_input = (torch.ones(1, 32, 28, 28),)
Expand All @@ -195,9 +191,14 @@
soc_info.htp_info.htp_arch,
args.build_op_package,
)
quantizer = make_quantizer(
quant_dtype=quant_dtype, custom_annotations=(annotate_custom,)
)

quant_dtype = QuantDtype.use_8a8w
if args.use_fp16:
quantizer = None
else:
quantizer = make_quantizer(
quant_dtype=quant_dtype, custom_annotations=(annotate_custom,)
)

build_executorch_binary(
instance,
Expand Down Expand Up @@ -260,7 +261,13 @@
target=args.target,
)
adb.push(inputs=sample_input, files=op_package_paths)
if args.debug:
adb.execute(custom_runner_cmd="logcat -c")
adb.execute(custom_runner_cmd=f"echo 0x1f > {workspace}/qnn_executor_runner.farf")

adb.execute()
if args.debug:
adb.execute(custom_runner_cmd=f"logcat -d -v time >{workspace}/outputs/debug_logs.txt")
adb.pull(host_output_path=args.artifact)

x86_golden = instance(*sample_input)
Expand Down Expand Up @@ -324,6 +331,13 @@
default=False,
)

parser.add_argument(
"--debug",
help="Enable device logging",
action="store_true",
default=False,
)

args = parser.parse_args()
args.validate(args)

Expand Down
2 changes: 2 additions & 0 deletions examples/qualcomm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def execute(
)
qnn_executor_runner_cmds = " ".join(
[
f"export LD_LIBRARY_PATH={self.workspace} &&",
f"export ADSP_LIBRARY_PATH={self.workspace} &&",
f"cd {self.workspace} &&",
"chmod +x ./qnn_executor_runner &&",
f"./qnn_executor_runner {qnn_executor_runner_args}",
Expand Down
Loading