diff --git a/python/paddle/fluid/contrib/quantize/quantize_transpiler.py b/python/paddle/fluid/contrib/quantize/quantize_transpiler.py index 4b4b81d2de6d5de1052140daa3090d9042ef4c3c..3967652d324190dd5395b845c65d464588b4d310 100644 --- a/python/paddle/fluid/contrib/quantize/quantize_transpiler.py +++ b/python/paddle/fluid/contrib/quantize/quantize_transpiler.py @@ -388,7 +388,8 @@ class QuantizeTranspiler(object): args += op.input_arg_names args += op.output_arg_names args = list(set(args)) - for var in block.vars.keys(): + var_names = block.vars.keys() + for var in var_names: if var not in args: block._remove_var(var) diff --git a/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py b/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py index 5bb6c4e47d8c1663447ebd25d93cccaf142faee1..4187ef0202c0e048ae2809e2fbd63b1c548d9712 100644 --- a/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py +++ b/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py @@ -245,7 +245,7 @@ class TestQuantizeTranspiler(unittest.TestCase): self.assertAlmostEqual(test_loss1, test_loss2, delta=1e-3) self.assertTrue( np.allclose( - f_v1, f_v2, rtol=1e-04, atol=1e-05), + f_v1, f_v2, rtol=1e-03, atol=1e-03), "There is diff: " + str(f_v1) + "\n" + str(f_v2)) w_freeze = np.array(fluid.global_scope().find_var('conv2d_1.w_0') .get_tensor())