diff --git a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py index 790eff04c3648972a236fa6af1f8f90a9a3dc68f..5620bdbb3a4ec6311df3dada2f388b2409de5a64 100644 --- a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py +++ b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py @@ -568,11 +568,12 @@ class ImperativeQuantizeOutputs(object): 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) diff --git a/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py b/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py index 01b54f8f13a9f125c6b966469dce963bd28fa2ad..57a8abe69ec61537bfbf960bf69fb55ad6eff70c 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 @@ _op_real_in_out_name = { "flatten": [["X"], ["Out"]], "flatten2": [["X"], ["Out"]], "unsqueeze2": [["X"], ["Out"]], + "flatten_contiguous_range": [['X'], ["Out", "XShape"]], } _conv_ops = ['conv2d', 'depthwise_conv2d', 'conv2d_transpose']