From 26a8b5b260057cd525f30de5264a4ecb645fb1aa Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Mon, 6 Feb 2023 10:55:31 +0800 Subject: [PATCH] fix QuantWeightPass error in sub graph (#50203) --- .../static/quantization/quantization_pass.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/paddle/static/quantization/quantization_pass.py b/python/paddle/static/quantization/quantization_pass.py index c9094998df..b703866569 100644 --- a/python/paddle/static/quantization/quantization_pass.py +++ b/python/paddle/static/quantization/quantization_pass.py @@ -3226,11 +3226,15 @@ class QuantWeightPass: self._quantized_ops[x_node.name()] = quant_weight_node for next_op_node in out_node.outputs: - graph.update_input_link( - out_node, - self._quantized_ops[x_node.name()], - next_op_node, - ) + if ( + self._quantized_ops[x_node.name()].node + in graph.graph.nodes() + ): + graph.update_input_link( + out_node, + self._quantized_ops[x_node.name()], + next_op_node, + ) graph.safe_remove_nodes(_op) self._remove_unused_var_nodes(graph) -- GitLab