From 7e17575f2b60ac8cc82e57d4a9f9b14bc193fdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20S=C5=82uszniak?= Date: Wed, 21 Oct 2026 10:31:52 +0200 Subject: [PATCH] Qualcomm AI Engine Direct - Test a constant-only I64toI32 cast partition stays on CPU #24222 drops HTP partitions without runtime inputs. Cover the case of an int64 buffer whose I64toI32 cast is left without a delegated consumer. --- backends/qualcomm/tests/test_passes.py | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/backends/qualcomm/tests/test_passes.py b/backends/qualcomm/tests/test_passes.py index 58ce89a6e30..72fd4119443 100644 --- a/backends/qualcomm/tests/test_passes.py +++ b/backends/qualcomm/tests/test_passes.py @@ -1141,6 +1141,40 @@ def test_rejected_conv_keeps_its_weight_dequantize_on_cpu(self): QuantDtype.use_fp16a8w, use_fp16=True, emit=False ) + def test_constant_only_partition_stays_on_cpu(self): + """An int64 buffer gets an int32 cast from I64toI32. When the buffer's consumer is + not delegated, that cast alone would form a partition with no graph input, which + QNN cannot compile ("No graph inputs present"). + """ + + class Lookup(torch.nn.Module): + def __init__(self): + super().__init__() + self.register_buffer("table", torch.arange(10) % 3) + + def forward(self, x): + values, indices = x.topk(4) + return values + self.table[indices].float() + + sample_input = (torch.randn(10),) + compiler_specs = generate_qnn_executorch_compiler_spec( + soc_model=QcomChipset.SM8650, + backend_options=generate_htp_compiler_spec(use_fp16=True), + ) + try: + edge = to_edge_transform_and_lower_to_qnn( + Lookup(), + sample_input, + compiler_specs, + skip_node_op_set={"aten.index.Tensor", "aten.topk.default"}, + ) + except RuntimeError as e: + if "QNN" in str(e) or "qnn" in str(e): + self.skipTest(f"QNN SDK not available: {e}") + raise + + edge.to_executorch() + def test_lowering_accepts_exported_program_without_reexport(self): """to_edge_transform_and_lower_to_qnn must lower a caller-supplied ExportedProgram as captured, never re-exporting it.