From c1b0f924b7edfce48b5f80dbbcac4a4ae44f6b4c Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Tue, 26 Oct 2021 15:36:19 -0700 Subject: [PATCH] quantization tool better support operator when subgraph is enabled (#9463) * Fix is_valid_quantize_weight recursive issue when enable subgraph. * some clear --- onnxruntime/python/tools/quantization/onnx_quantizer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/quantization/onnx_quantizer.py b/onnxruntime/python/tools/quantization/onnx_quantizer.py index 7fe8f7fd1e..034e023d8b 100644 --- a/onnxruntime/python/tools/quantization/onnx_quantizer.py +++ b/onnxruntime/python/tools/quantization/onnx_quantizer.py @@ -320,7 +320,11 @@ class ONNXQuantizer: def is_valid_quantize_weight(self, weight_name): weight = find_by_name(weight_name, self.model.initializer()) - return weight is not None and weight.data_type == onnx_proto.TensorProto.FLOAT + if weight is not None: + return weight.data_type == onnx_proto.TensorProto.FLOAT + if (not self.enable_subgraph_quantization) or (self.parent is None): + return False + return self.parent.is_valid_quantize_weight(weight_name) def _get_dynamic_input_quantization_params(self, input_name, nodes_list, qType): '''