From 496de7f33457b7fc67f100fad8eb9c0c32033c48 Mon Sep 17 00:00:00 2001 From: yangjianfengo1 <125249383+yangjianfengo1@users.noreply.github.com> Date: Mon, 7 Aug 2023 13:28:35 +0800 Subject: [PATCH] Increase absolute error of test_group_norm_op (#55992) * inplace tol * code style --- test/legacy_test/test_group_norm_op.py | 32 ++++---------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/test/legacy_test/test_group_norm_op.py b/test/legacy_test/test_group_norm_op.py index 108d51416be..bc9a4b0432a 100644 --- a/test/legacy_test/test_group_norm_op.py +++ b/test/legacy_test/test_group_norm_op.py @@ -357,37 +357,15 @@ class TestGroupNormFP16Op_With_NHWC(TestGroupNormFP16OP): self.attrs['epsilon'] = 0.5 self.shape = (1, 100, 4, 4) self.dtype = np.float16 - input = np.sin( - np.arange( - self.shape[0] * self.shape[1] * self.shape[2] * self.shape[3] - ) - ) - input = np.transpose(input.reshape(self.shape), (0, 2, 3, 1)).astype( - self.dtype - ) - scale = np.sin(np.arange(self.shape[1])).astype(self.dtype) - bias = np.sin(np.arange(self.shape[1])).astype(self.dtype) - output, mean, var = group_norm_naive( - input, - scale, - bias, - self.attrs['epsilon'], - self.attrs['groups'], - self.data_format, - ) - - self.inputs = { - 'X': OpTest.np_dtype_to_fluid_dtype(input), - 'Scale': OpTest.np_dtype_to_fluid_dtype(scale), - 'Bias': OpTest.np_dtype_to_fluid_dtype(bias), - } - self.outputs = {'Y': output, 'Mean': mean, 'Variance': var} - self.attrs['data_layout'] = self.data_format def test_check_output(self): rtol = 2e-3 + atol = 2e-3 + inplace_atol = 2e-3 place = core.CUDAPlace(0) - self.check_output_with_place(place, rtol=rtol) + self.check_output_with_place( + place, rtol=rtol, atol=atol, inplace_atol=inplace_atol + ) class TestGroupNormBF16Op_With_NHWC(TestGroupNormBF16Op): -- GitLab