From 1ec744ea30fb19f40c4b0f6e137d24e1af1c4afd Mon Sep 17 00:00:00 2001 From: cccclai Date: Tue, 18 Nov 2025 17:10:05 -0800 Subject: [PATCH 1/2] Fix UnboundLocalError: local variable 'qnn_compile_spec_buffer' referenced before assignment As title, addressed issues from ``` FAILED exir/backend/test/test_debug_handle_map.py::TestBackendDebugHandle::test_lowered_the_whole_model - UnboundLocalError: local variable 'qnn_compile_spec_buffer' referenced before assignment Falsifying example: test_lowered_the_whole_model( unlift=False, self=, ) ``` --- backends/qualcomm/partition/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backends/qualcomm/partition/utils.py b/backends/qualcomm/partition/utils.py index 97e0b4bd109..8f0ab43147b 100644 --- a/backends/qualcomm/partition/utils.py +++ b/backends/qualcomm/partition/utils.py @@ -16,11 +16,19 @@ def generate_qnn_executorch_option( compiler_specs: List[CompileSpec], ) -> bytes: + qnn_compile_spec_buffer = None + for compiler_spec in compiler_specs: if compiler_spec.key == QCOM_QNN_COMPILE_SPEC: qnn_compile_spec_buffer = compiler_spec.value else: raise ValueError(f"unknown compiler spec key value: {compiler_spec.key}") + + if qnn_compile_spec_buffer is None: + raise ValueError( + f"QNN compile spec (key={QCOM_QNN_COMPILE_SPEC}) not found in compiler_specs" + ) + return qnn_compile_spec_buffer From c143f48575ddf2d293bc539e5fa2848d7ba1726f Mon Sep 17 00:00:00 2001 From: Chen Lai Date: Tue, 18 Nov 2025 20:08:35 -0800 Subject: [PATCH 2/2] fix lint --- backends/qualcomm/partition/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/qualcomm/partition/utils.py b/backends/qualcomm/partition/utils.py index 8f0ab43147b..7c45845f516 100644 --- a/backends/qualcomm/partition/utils.py +++ b/backends/qualcomm/partition/utils.py @@ -28,7 +28,7 @@ def generate_qnn_executorch_option( raise ValueError( f"QNN compile spec (key={QCOM_QNN_COMPILE_SPEC}) not found in compiler_specs" ) - + return qnn_compile_spec_buffer