Skip to content

Commit

Permalink
Fix QLinearConv promotion
Browse files Browse the repository at this point in the history
Currently, QDQ to QLinearConv promotion is happenning incorrectly for
per-axis quantization where axis != 0. QLinearConv can only support
per-output-channel quantization, which is equivalent to per-axis quantization
with axis=1.
The issue can be easily seen when running this model with optimization
enable (promoted to QLinearConv) and disabled (using QDQ). Both produce
different results.
  • Loading branch information
Vinit Azad committed Aug 12, 2024
1 parent c5592fd commit 88a985b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ bool ConvNodeGroupSelector::Check(const GraphViewer& graph_viewer,
return false;
}

// Only per-tensor or per-output channel (axis == 1) quantization is supported
const auto& dq_attrs = dq_nodes[1]->GetAttributes();
if (const auto a_iter = dq_attrs.find("axis");
a_iter == dq_attrs.end() || a_iter->second.i() != 1) {
return false;
}

return true;
}

Expand Down

0 comments on commit 88a985b

Please sign in to comment.