Skip to content

Commit b97cd7b

Browse files
authored
Qualcomm AI Engine Direct - Custom op example fixes (#18024)
1 parent bde7360 commit b97cd7b

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

backends/qualcomm/tests/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ def validate_intermediate_tensor():
519519
adb.extra_cmds += (
520520
f" --performance_output_path {self.inference_speed_output_path}"
521521
)
522+
adb.execute(custom_runner_cmd=f"rm -rf {adb.output_folder}")
522523
adb.execute(method_index=method_index, output_callback=output_callback)
523524
adb.pull(host_output_path=tmp_dir, callback=post_process)
524525
self._assert_outputs_equal(outputs, ref_outputs)

examples/qualcomm/custom_op/custom_ops_1.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ def main(args):
177177
# ensure the working directory exist.
178178
os.makedirs(args.artifact, exist_ok=True)
179179

180-
quant_dtype = QuantDtype.use_8a8w
181-
if args.use_fp16:
182-
quant_dtype = None
183-
184180
instance = Model()
185181
pte_filename = "custom_qnn"
186182
sample_input = (torch.ones(1, 32, 28, 28),)
@@ -194,12 +190,17 @@ def main(args):
194190
soc_info.htp_info.htp_arch,
195191
args.build_op_package,
196192
)
197-
quantizer = make_quantizer(
198-
quant_dtype=quant_dtype,
199-
custom_annotations=(annotate_custom,),
200-
backend=get_backend_type(args.backend),
201-
soc_model=args.model,
202-
)
193+
194+
quant_dtype = QuantDtype.use_8a8w
195+
if args.use_fp16:
196+
quantizer = None
197+
else:
198+
quantizer = make_quantizer(
199+
quant_dtype=quant_dtype,
200+
custom_annotations=(annotate_custom,),
201+
backend=get_backend_type(args.backend),
202+
soc_model=args.model,
203+
)
203204

204205
build_executorch_binary(
205206
instance,
@@ -262,7 +263,17 @@ def main(args):
262263
target=args.target,
263264
)
264265
adb.push(inputs=sample_input, files=op_package_paths)
266+
if args.debug:
267+
adb.execute(custom_runner_cmd="logcat -c")
268+
adb.execute(
269+
custom_runner_cmd=f"echo 0x1f > {workspace}/qnn_executor_runner.farf"
270+
)
271+
265272
adb.execute()
273+
if args.debug:
274+
adb.execute(
275+
custom_runner_cmd=f"logcat -d -v time >{workspace}/outputs/debug_logs.txt"
276+
)
266277
adb.pull(host_output_path=args.artifact)
267278

268279
x86_golden = instance(*sample_input)
@@ -326,6 +337,13 @@ def main(args):
326337
default=False,
327338
)
328339

340+
parser.add_argument(
341+
"--debug",
342+
help="Enable device logging",
343+
action="store_true",
344+
default=False,
345+
)
346+
329347
args = parser.parse_args()
330348
args.validate(args)
331349

examples/qualcomm/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ def execute(
266266
method_index=0,
267267
output_callback: Optional[Callable[[str], None]] = None,
268268
):
269-
self._adb(["shell", f"rm -rf {self.output_folder}"])
270269
self._adb(["shell", f"mkdir -p {self.output_folder}"])
271270
# run the delegation
272271
if custom_runner_cmd is None:

0 commit comments

Comments
 (0)