From df472cbfbdf0ff47f1051639fe0216178638e6ab Mon Sep 17 00:00:00 2001 From: Jonny Shipton Date: Mon, 30 Sep 2019 22:57:00 +0100 Subject: [PATCH] quantise: Don't error when initializer graph input is missing (#1872) ONNX IR version 4 and above do not require graph initializers to have corresponding graph inputs. --- onnxruntime/python/tools/quantization/quantize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/onnxruntime/python/tools/quantization/quantize.py b/onnxruntime/python/tools/quantization/quantize.py index 952ae2f12c..ce09c8e18f 100644 --- a/onnxruntime/python/tools/quantization/quantize.py +++ b/onnxruntime/python/tools/quantization/quantize.py @@ -309,9 +309,10 @@ class ONNXQuantizer: # Removing input weight to a convolution try: weight_input = next(val for val in self.model.graph.input if val.name == weight.name) + self.model.graph.input.remove(weight_input) except StopIteration: - raise ValueError('invalid weight name {} found in the graph '.format(weight.name)) - self.model.graph.input.remove(weight_input) + if self.model.ir_version < 4: + raise ValueError('invalid weight name {} found in the graph (not a graph input) '.format(weight.name)) def _update_graph(self, weight):