Skip to content

Commit b8b5e0f

Browse files
Qualcomm AI Engine Direct - Fix fp16 unit test (pytorch#22059)
### Summary Since nn.Module has no graph, the fp16 unit test failed with error "AttributeError: object has no attribute 'graph'". pytorch#21729 introduce the error. Per internal discussion, we don't want to extend the function to include everything. Considering the pass already ensure the hadamard transform op exist, we will revert the change to add expected_target. ### Test plan ``` pytest backends/qualcomm/tests/rework/htp/op/v68/test.py ```
1 parent cff6f4d commit b8b5e0f

2 files changed

Lines changed: 1 addition & 8 deletions

File tree

‎backends/qualcomm/tests/rework/conftest.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,10 @@ def export_and_verify(
476476
quantizer: QnnQuantizer,
477477
compile_specs: List[Any],
478478
metrics: Metrics,
479-
expected_targets: set = None,
480479
):
481480
with calibrate(module, [inputs], quantizer) as exported_module:
482-
nodes = {node.target for node in exported_module.graph.nodes}
483481
if quantizer is not None:
482+
nodes = {node.target for node in exported_module.graph.nodes}
484483
q_and_dq = {
485484
torch.ops.quantized_decomposed.quantize_per_tensor.default,
486485
torch.ops.quantized_decomposed.dequantize_per_tensor.default,
@@ -490,10 +489,6 @@ def export_and_verify(
490489
torch.ops.torchao.dequantize_affine.default,
491490
}
492491
assert nodes.intersection(q_and_dq), EXPECT_NOT_ANNOTATED
493-
if expected_targets is not None:
494-
assert (
495-
expected_targets <= nodes
496-
), f"expected {expected_targets - nodes} in exported graph"
497492

498493
delegated_prog = to_edge_transform_and_lower_to_qnn(
499494
module=exported_module,

‎backends/qualcomm/tests/rework/src/op.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,6 @@ def test(subtests, qnn_config, quantizer, compile_spec, expected):
22442244
"matmul": (torch.randn(1, dim),),
22452245
"conv": (torch.randn(1, dim, 4, 4),),
22462246
}
2247-
target = torch.ops.qnn_custom.hadamard_transform.default
22482247
for variant, inputs in cases.items():
22492248
with subtests.test(msg=f"variant:{variant}"):
22502249
with expected as metrics:
@@ -2255,7 +2254,6 @@ def test(subtests, qnn_config, quantizer, compile_spec, expected):
22552254
quantizer=quantizer,
22562255
compile_specs=compile_spec,
22572256
metrics=metrics,
2258-
expected_targets={target},
22592257
)
22602258

22612259

0 commit comments

Comments
 (0)