From d419df4076e2aeaa347e5d6ebc9b2837952a11d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Sat, 2 Nov 2024 03:08:35 +0100 Subject: [PATCH] Fix too strict assert in onnx_quantizer.py (#22283) ### Description Partial answer to issue #19997. The example succeeds after this change. --- onnxruntime/python/tools/quantization/onnx_quantizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/quantization/onnx_quantizer.py b/onnxruntime/python/tools/quantization/onnx_quantizer.py index e1e4a4f724fdc..424f9b7e180a3 100644 --- a/onnxruntime/python/tools/quantization/onnx_quantizer.py +++ b/onnxruntime/python/tools/quantization/onnx_quantizer.py @@ -942,7 +942,7 @@ def _dequantize_value(self, value_name): self.model.model.producer_name == "onnx-quantizer" and scale_init is not None ): # axis is not specified so scale_init must be a scalar. - assert onnx.numpy_helper.to_array(scale_init).size == 1 + assert scale_init is None or onnx.numpy_helper.to_array(scale_init).size == 1 dqlinear_name = value_name + "_DequantizeLinear" dqlinear_node = self.model.find_node_by_name(dqlinear_name, self.new_nodes, self.model.graph())