From 5f1c9f24f37807f8dc6ccf84ead2857d7d286ac7 Mon Sep 17 00:00:00 2001 From: XGZhang11 <46363693+XGZhang11@users.noreply.github.com> Date: Thu, 2 Sep 2021 11:49:11 +0000 Subject: [PATCH 1/2] quant: fix a export bug --- .../paddle/fluid/contrib/slim/quantization/quantization_pass.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py b/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py index 01b54f8f13a9f1..57a8abe69ec615 100644 --- a/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py +++ b/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py @@ -134,6 +134,7 @@ "flatten": [["X"], ["Out"]], "flatten2": [["X"], ["Out"]], "unsqueeze2": [["X"], ["Out"]], + "flatten_contiguous_range": [['X'], ["Out", "XShape"]], } _conv_ops = ['conv2d', 'depthwise_conv2d', 'conv2d_transpose'] From 032bf1028326f21602ea837cecee368759d10e70 Mon Sep 17 00:00:00 2001 From: XGZhang11 <46363693+XGZhang11@users.noreply.github.com> Date: Thu, 2 Sep 2021 12:20:01 +0000 Subject: [PATCH 2/2] fix a bug --- .../fluid/contrib/slim/quantization/imperative/qat.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py index 6208b43c9e9e48..c9694767bde817 100644 --- a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py +++ b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py @@ -566,11 +566,12 @@ def _gather_output_scale(): out_scale = utils.fp_numpy_to_naive(out_scale) if previous_op.type != "feed": - argname, index = utils._get_output_name_index(previous_op, - in_var_name) - previous_op._set_attr(argname + str(index) + "_threshold", - out_scale) - previous_op._set_attr("out_threshold", out_scale) + res = utils._get_output_name_index(previous_op, in_var_name) + if res is not None: + argname, index = res + previous_op._set_attr( + argname + str(index) + "_threshold", out_scale) + previous_op._set_attr("out_threshold", out_scale) for next_op in next_ops: next_op._rename_input(out_var_name, in_var_name)