[QNN EP] Add graph-structure tests for DQQ and CastLoneQ fusions - #539
Open
qti-chuteng wants to merge 2 commits into
Open
qti-chuteng wants to merge 2 commits into
qti-chuteng wants to merge 2 commits into
Conversation
Add JSON-graph verification tests for the two Q/DQ-to-Convert fusions that previously had accuracy-only coverage: - DQQFusion: a lone DequantizeLinear -> QuantizeLinear pair must collapse into a single QNN Convert. Covers uint8 and uint16 requantize at the graph output, plus a no-fusion case where the DQ has a second consumer. - CastLoneQFusion: a standalone Cast feeding a QuantizeLinear (with a non-DQ parent) must collapse into a single QNN Convert. Covers the uint8 happy path plus a no-fusion case where the Cast has no Q child. Both fusions emit QNN_OP_CONVERT, and standalone Quantize/Dequantize/Cast all have QNN op builders, so fusion is verified via the compiled-graph JSON (AssertOpInQnnGraph on "Convert"/"Cast") rather than EP assignment. The test harness mirrors dql_dq_fusion_test.cc and reuses the model topologies already proven in simple_op_test.cc and qnn_basic_test.cc.
qti-chuteng
requested review from
qti-ashwshan,
qti-jkilpatrick,
qti-kromero,
qti-yuduo,
tirupath-qti and
yath1
as code owners
June 16, 2026 09:35
|
qti-chuteng seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
| // The DQ feeding the final Q has a second consumer (the Add branch), so the | ||
| // DQ->Q pair is not a lone sequence and DQQFusion must be rejected. No Convert | ||
| // must appear in the compiled graph. | ||
| TEST_F(QnnHTPBackendTests, DQQFusion_ExtraConsumer_NoFusion) { |
Collaborator
There was a problem hiding this comment.
CI failed in this testcase.
| @@ -0,0 +1,211 @@ | |||
| // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | |||
Collaborator
There was a problem hiding this comment.
According to the description,
Both fusions previously had only accuracy / EP-assignment coverage; nothing asserted that the fused Convert actually appears in the compiled QNN graph.
Should existing testcases as well move into these new test files?
qti-chuteng
requested review from
qti-shubham and
yuhuchua-qti
as code owners
September 29, 2026 10:00
| @@ -0,0 +1,249 @@ | |||
| // Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | |||
Collaborator
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds graph-structure unit tests for the two Q/DQ-to-
Convertfusions in the QNN EP —DQQFusionandCastLoneQFusion. Both fusions previously had only accuracy / EP-assignment coverage; nothing asserted that the fusedConvertactually appears in the compiled QNN graph. These tests close that gap.No production code changes — test-only.
Why
Both fusions rewrite a small Q/DQ pattern into a single
QNN_OP_CONVERT:DQQFusion: a standaloneDequantizeLinear -> QuantizeLinear(same scale type, scalar constant qparams) collapses into oneConvert.CastLoneQFusion: a standaloneCastwhose parent is not aDequantizeLinearand whose only child is aQuantizeLinearcollapses into oneConvert.Standalone
Quantize/Dequantize/Castall have QNN op builders, so whether or not the fusion fires the nodes still land on the QNN EP (ExpectedEPNodeAssignment::All). EP assignment therefore cannot distinguish "fused" from "not fused" — the only reliable signal is the compiled-graph JSON. These tests dump the QNN graph (dump_json_qnn_graph) and assert on the op types viaAssertOpInQnnGraph.Coverage
onnxruntime/test/providers/qnn/qnn_node_group/dq_q_fusion_test.ccDQQFusion_U8_ConvertConvertcount 1DQQFusion_U16_ConvertConvertcount 1DQQFusion_ExtraConsumer_NoFusionConvertcount 0onnxruntime/test/providers/qnn/qnn_node_group/cast_lone_q_fusion_test.ccCastLoneQFusion_U8_ConvertCast -> Q→Convertcount 1,Castcount 0CastLoneQFusion_NoQChild_NoFusionCast -> Add(no Q child) →Convertcount 0,Castcount 1Implementation notes
ResetQnnGraphDir/HasQnnJsonGraph/GetHTPProviderOptions/RunFusionTest) mirrors the existingdql_dq_fusion_test.cc.simple_op_test.cc(BuildDQQConvertAtOutputTestCase, including thescale *= 1.01fnudge so the ORT QDQ optimizer does not fold theDQ -> Qpair away before the QNN EP sees it) andqnn_basic_test.cc(theCast -> Q -> DQ -> Addtopology).#if defined(__aarch64__) || defined(_M_ARM64) || defined(__linux__)) andSKIP_HTP_TEST_ON_ARCH_LESS_THAN_OR_EQUAL_TO(QNN_HTP_DEVICE_ARCH_V68)match sibling fusion tests.providers/qnn/qnn_node_group/*CMake glob — no CMake change needed.Testing
lintrunner— clean.--gtest_filter="QnnHTPBackendTests.DQQFusion*:QnnHTPBackendTests.CastLoneQFusion*"on an HTP-capable environment (arm64 device or x86 HTP emulator).