From 5211282dd61e928407f16cbfac41c315d9f1692d Mon Sep 17 00:00:00 2001 From: zhangbo9674 <82555433+zhangbo9674@users.noreply.github.com> Date: Sun, 24 Apr 2022 14:17:25 +0800 Subject: [PATCH] refine optest logic for bfloat16 (#42151) (#42165) --- python/paddle/fluid/tests/unittests/op_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index cfe0d4e32e..738ed90b12 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1506,6 +1506,12 @@ class OpTest(unittest.TestCase): return imperative_actual, imperative_actual_t def convert_uint16_to_float_ifneed(self, actual_np, expect_np): + if actual_np.dtype == np.uint16 and expect_np.dtype in [ + np.float32, np.float64 + ]: + self.rtol = 1.e-2 + else: + self.rtol = 1.e-5 if self.op_test.is_bfloat16_op(): if actual_np.dtype == np.uint16: actual_np = convert_uint16_to_float(actual_np) -- GitLab