From eeff431c9ce41ffd5ea81478ff11eb6ad6ce8de7 Mon Sep 17 00:00:00 2001 From: Mahesh Madhavan Date: Thu, 12 Feb 2026 13:10:14 -0800 Subject: [PATCH] Qualcomm AI Engine Direct - Fixes for custom op example - Fixed bug in custom_op example, with use_fp16 flag - Set LD_LIBRARY_PATH and ADSP_LIBRARY_PATH when executing on-device --- examples/qualcomm/custom_op/custom_ops_1.py | 28 +++++++++++++++------ examples/qualcomm/utils.py | 2 ++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/examples/qualcomm/custom_op/custom_ops_1.py b/examples/qualcomm/custom_op/custom_ops_1.py index 0962e44ee6c..5678ec6ad97 100644 --- a/examples/qualcomm/custom_op/custom_ops_1.py +++ b/examples/qualcomm/custom_op/custom_ops_1.py @@ -178,10 +178,6 @@ def main(args): # 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),) @@ -195,9 +191,14 @@ def main(args): 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, @@ -260,7 +261,13 @@ def main(args): 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) @@ -324,6 +331,13 @@ def main(args): default=False, ) + parser.add_argument( + "--debug", + help="Enable device logging", + action="store_true", + default=False, + ) + args = parser.parse_args() args.validate(args) diff --git a/examples/qualcomm/utils.py b/examples/qualcomm/utils.py index 09a87892c5f..04dbf6dae1c 100755 --- a/examples/qualcomm/utils.py +++ b/examples/qualcomm/utils.py @@ -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}",