From 00244ea1439078f49d9aa284101ae0c566d476e2 Mon Sep 17 00:00:00 2001 From: mo-ja <60505697+mo-ja@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:36:15 +0900 Subject: [PATCH] fix quantization errors of ConvTranspose with per_channel=True (#19996) ### Description - update axis value for per_channel quantization of QDQConv - we should use `axis=1` for ConvTranspose operator. ### Motivation and Context - this PR fixes https://github.com/microsoft/onnxruntime/issues/19694, which I have opened --- onnxruntime/python/tools/quantization/operators/conv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/quantization/operators/conv.py b/onnxruntime/python/tools/quantization/operators/conv.py index 7054173450569..b053c65ad6f85 100644 --- a/onnxruntime/python/tools/quantization/operators/conv.py +++ b/onnxruntime/python/tools/quantization/operators/conv.py @@ -247,7 +247,8 @@ def quantize(self): self.quantizer.quantize_activation_tensor(node.output[0]) if self.quantizer.is_per_channel(): - self.quantizer.quantize_weight_tensor_per_channel(node.input[1], 0) + axis = 0 if node.op_type == "Conv" else 1 + self.quantizer.quantize_weight_tensor_per_channel(node.input[1], axis) else: self.quantizer.quantize_weight_tensor(node.input[1])