提交 eab124ba 编写于 作者: G GaoWei8 提交者: Tao Luo

fix accuracy parameters of op tests (#21813)

test=develop
上级 642b3356
...@@ -45,8 +45,7 @@ class TestAddPositionEncodingTensorOp(OpTest): ...@@ -45,8 +45,7 @@ class TestAddPositionEncodingTensorOp(OpTest):
""" """
check the correctness of grad check the correctness of grad
""" """
self.check_grad( self.check_grad(['X'], 'Out', check_dygraph=False)
['X'], 'Out', max_relative_error=0.005, check_dygraph=False)
def init_input_output(self): def init_input_output(self):
""" """
...@@ -100,8 +99,7 @@ class TestAddPositionEncodingLoDTensorOp(OpTest): ...@@ -100,8 +99,7 @@ class TestAddPositionEncodingLoDTensorOp(OpTest):
""" """
check the correctness of grad check the correctness of grad
""" """
self.check_grad( self.check_grad(['X'], 'Out', check_dygraph=False)
['X'], 'Out', max_relative_error=0.005, check_dygraph=False)
def init_input_output(self): def init_input_output(self):
""" """
......
...@@ -56,11 +56,7 @@ class TestAffineGridOp(OpTest): ...@@ -56,11 +56,7 @@ class TestAffineGridOp(OpTest):
self.check_output() self.check_output()
def test_check_grad_normal(self): def test_check_grad_normal(self):
self.check_grad( self.check_grad(['Theta'], 'Output', no_grad_set=['OutputShape'])
['Theta'],
'Output',
no_grad_set=['OutputShape'],
max_relative_error=0.006)
def initTestCase(self): def initTestCase(self):
self.theta_shape = (17, 2, 3) self.theta_shape = (17, 2, 3)
......
...@@ -40,8 +40,7 @@ class TestClipOp(OpTest): ...@@ -40,8 +40,7 @@ class TestClipOp(OpTest):
self.check_output() self.check_output()
def test_check_grad_normal(self): def test_check_grad_normal(self):
self.check_grad( self.check_grad(['X'], 'Out')
['X'], 'Out', max_relative_error=self.max_relative_error)
def initTestCase(self): def initTestCase(self):
self.shape = (4, 4) self.shape = (4, 4)
......
...@@ -50,10 +50,7 @@ class TestElementwiseAddOp(OpTest): ...@@ -50,10 +50,7 @@ class TestElementwiseAddOp(OpTest):
if self.dtype == np.float16: if self.dtype == np.float16:
return return
self.check_grad( self.check_grad(
['X', 'Y'], ['X', 'Y'], 'Out', check_dygraph=(self.use_mkldnn == False))
'Out',
max_relative_error=0.005,
check_dygraph=(self.use_mkldnn == False))
def test_check_grad_ingore_x(self): def test_check_grad_ingore_x(self):
# TODO(wangzhongpu): support mkldnn op in dygraph mode # TODO(wangzhongpu): support mkldnn op in dygraph mode
...@@ -62,7 +59,6 @@ class TestElementwiseAddOp(OpTest): ...@@ -62,7 +59,6 @@ class TestElementwiseAddOp(OpTest):
self.check_grad( self.check_grad(
['Y'], ['Y'],
'Out', 'Out',
max_relative_error=0.005,
no_grad_set=set("X"), no_grad_set=set("X"),
check_dygraph=(self.use_mkldnn == False)) check_dygraph=(self.use_mkldnn == False))
...@@ -73,7 +69,6 @@ class TestElementwiseAddOp(OpTest): ...@@ -73,7 +69,6 @@ class TestElementwiseAddOp(OpTest):
self.check_grad( self.check_grad(
['X'], ['X'],
'Out', 'Out',
max_relative_error=0.005,
no_grad_set=set('Y'), no_grad_set=set('Y'),
check_dygraph=(self.use_mkldnn == False)) check_dygraph=(self.use_mkldnn == False))
......
...@@ -105,15 +105,13 @@ class TestGroupNormOp(OpTest): ...@@ -105,15 +105,13 @@ class TestGroupNormOp(OpTest):
return return
place = core.CPUPlace() place = core.CPUPlace()
self.check_grad_with_place( self.check_grad_with_place(place, set(['X', 'Scale', 'Bias']), 'Y')
place, set(['X', 'Scale', 'Bias']), 'Y', max_relative_error=0.01)
if core.is_compiled_with_cuda(): if core.is_compiled_with_cuda():
place = core.CUDAPlace(0) place = core.CUDAPlace(0)
self.check_grad_with_place( self.check_grad_with_place(
place, place,
set(['X', 'Scale', 'Bias']), set(['X', 'Scale', 'Bias']),
'Y', 'Y', )
max_relative_error=0.005)
def init_test_case(self): def init_test_case(self):
pass pass
......
...@@ -52,8 +52,7 @@ class TestKLDivLossOp(OpTest): ...@@ -52,8 +52,7 @@ class TestKLDivLossOp(OpTest):
self.check_output() self.check_output()
def test_check_grad(self): def test_check_grad(self):
self.check_grad( self.check_grad(['X'], 'Loss', no_grad_set=set(["Target"]))
['X'], 'Loss', no_grad_set=set(["Target"]), max_relative_error=0.06)
def initTestCase(self): def initTestCase(self):
self.x_shape = (4, 5, 5) self.x_shape = (4, 5, 5)
......
...@@ -36,8 +36,7 @@ class TestL1NormOp(OpTest): ...@@ -36,8 +36,7 @@ class TestL1NormOp(OpTest):
self.check_output() self.check_output()
def test_check_grad(self): def test_check_grad(self):
self.check_grad( self.check_grad(['X'], 'Out')
['X'], 'Out', max_relative_error=self.max_relative_error)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -183,7 +183,6 @@ class TestCUDNNLstmOp(OpTest): ...@@ -183,7 +183,6 @@ class TestCUDNNLstmOp(OpTest):
self.check_grad_with_place( self.check_grad_with_place(
place, place,
set(['Input', 'W', 'InitH', 'InitC']), ['Out', 'last_h', 'last_c'], set(['Input', 'W', 'InitH', 'InitC']), ['Out', 'last_h', 'last_c'],
max_relative_error=0.02,
check_dygraph=False) check_dygraph=False)
......
...@@ -74,8 +74,7 @@ class TestMatchMatrixTensorOp(OpTest): ...@@ -74,8 +74,7 @@ class TestMatchMatrixTensorOp(OpTest):
self.check_output(check_compile_vs_runtime=True, check_dygraph=False) self.check_output(check_compile_vs_runtime=True, check_dygraph=False)
def test_check_grad(self): def test_check_grad(self):
self.check_grad( self.check_grad(['X', 'Y'], 'Out', check_dygraph=False)
['X', 'Y'], 'Out', max_relative_error=0.005, check_dygraph=False)
class TestMatchMatrixTensorOpCase1(TestMatchMatrixTensorOp): class TestMatchMatrixTensorOpCase1(TestMatchMatrixTensorOp):
......
...@@ -96,8 +96,7 @@ class TestSpectralNormOp(TestSpectralNormOpNoGrad): ...@@ -96,8 +96,7 @@ class TestSpectralNormOp(TestSpectralNormOpNoGrad):
self.check_grad( self.check_grad(
['Weight'], ['Weight'],
'Out', 'Out',
no_grad_set=set(["U", "V"]), no_grad_set=set(["U", "V"]), )
max_relative_error=0.1)
def initTestCase(self): def initTestCase(self):
self.weight_shape = (10, 12) self.weight_shape = (10, 12)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册