Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the duplicated QDQ attributes setup issue #18039

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Status DuplicateDQForOutputEdge(const graph_utils::GraphEdge& original_dq_output
MakeString("Added by ", kTransformerName),
dq_inputs,
{&new_dq_output_nodearg},
nullptr, // attributes
&original_dq_node.GetAttributes(),
original_dq_node.Domain());

// set up edges
Expand Down
20 changes: 20 additions & 0 deletions onnxruntime/test/optimizer/ensure_unique_dq_for_node_unit_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,24 @@ TEST(EnsureUniqueDQForNodeUnitTests, QDQWithMultiConsumerDQNodes) {
EXPECT_EQ(OpCount(op_count_before, "DequantizeLinear") + 4, OpCount(op_count_after, "DequantizeLinear"));
}

TEST(EnsureUniqueDQForNodeUnitTests, QDQWithMultiConsumerDQNodesPreservingAttributes) {
constexpr auto model_uri = ORT_TSTR("testdata/qdq_with_multi_consumer_q_dq_axis.onnx");

SessionOptions session_options{};
// test interaction with level 1 transformers
session_options.graph_optimization_level = TransformerLevel::Level1;

InferenceSessionWrapper session{session_options, GetEnvironment()};

ASSERT_STATUS_OK(session.Load(model_uri));

const auto op_count_before = CountOpsInGraph(session.GetGraph());

ASSERT_STATUS_OK(session.Initialize());

const auto op_count_after = CountOpsInGraph(session.GetGraph());

EXPECT_EQ(OpCount(op_count_before, "DequantizeLinear") + 8, OpCount(op_count_after, "DequantizeLinear"));
vera121 marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace onnxruntime::test
Binary file not shown.