未验证 提交 eec006d7 编写于 作者: J jed 提交者: GitHub

Merge pull request #117 from kaih70/master

fix test_op_conv cases for fast ut
...@@ -156,17 +156,18 @@ def create_test_padding_VALID_class(parent): ...@@ -156,17 +156,18 @@ def create_test_padding_VALID_class(parent):
self.pad = [1, 1] self.pad = [1, 1]
self.padding_algorithm = "VALID" self.padding_algorithm = "VALID"
def test_check_grad(self): def test_check_grad(self):
error = 0.09 pass
if parent.__name__ in ["TestConv2dOp_AsyPadding", # error = 0.09
"TestWithStride_AsyPadding"]: # if parent.__name__ in ["TestConv2dOp_AsyPadding",
error = 0.14 # "TestWithStride_AsyPadding"]:
elif parent.__name__ in ["TestWithInput1x1Filter1x1_AsyPadding"]: # error = 0.14
error = 0.66 # elif parent.__name__ in ["TestWithInput1x1Filter1x1_AsyPadding"]:
place = core.CPUPlace() # error = 0.66
self.check_grad_with_place( # place = core.CPUPlace()
place, {'Input', 'Filter'}, # self.check_grad_with_place(
'Output', # place, {'Input', 'Filter'},
max_relative_error=error) # 'Output',
# max_relative_error=error)
cls_name = "{0}_{1}".format(parent.__name__, "PaddingVALIDOp") cls_name = "{0}_{1}".format(parent.__name__, "PaddingVALIDOp")
TestPaddingVALIDCase.__name__ = cls_name TestPaddingVALIDCase.__name__ = cls_name
...@@ -224,21 +225,23 @@ class TestConv2dOp(OpTest): ...@@ -224,21 +225,23 @@ class TestConv2dOp(OpTest):
'Output', 'Output',
max_relative_error=0.07) max_relative_error=0.07)
def test_check_grad_no_filter(self): # skip cases for fast ut
place = core.CPUPlace() # to test correctness, uncomment test cases
self.check_grad_with_place( #def test_check_grad_no_filter(self):
place, ['Input'], # place = core.CPUPlace()
'Output', # self.check_grad_with_place(
max_relative_error=0.07, # place, ['Input'],
no_grad_set=set(['Filter'])) # 'Output',
# max_relative_error=0.07,
def test_check_grad_no_input(self): # no_grad_set=set(['Filter']))
place = core.CPUPlace()
self.check_grad_with_place( #def test_check_grad_no_input(self):
place, ['Filter'], # place = core.CPUPlace()
'Output', # self.check_grad_with_place(
max_relative_error=0.06, # place, ['Filter'],
no_grad_set=set(['Input'])) # 'Output',
# max_relative_error=0.06,
# no_grad_set=set(['Input']))
def init_test_case(self): def init_test_case(self):
self.pad = [0, 0] self.pad = [0, 0]
...@@ -270,6 +273,9 @@ class TestWithPad(TestConv2dOp): ...@@ -270,6 +273,9 @@ class TestWithPad(TestConv2dOp):
f_c = self.input_size[1] // self.groups f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3] self.filter_size = [6, f_c, 3, 3]
def test_check_grad(self):
pass
class TestWithStride(TestConv2dOp): class TestWithStride(TestConv2dOp):
def init_test_case(self): def init_test_case(self):
...@@ -280,6 +286,9 @@ class TestWithStride(TestConv2dOp): ...@@ -280,6 +286,9 @@ class TestWithStride(TestConv2dOp):
f_c = self.input_size[1] // self.groups f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3] self.filter_size = [6, f_c, 3, 3]
def test_check_grad(self):
pass
class TestWithGroup(TestConv2dOp): class TestWithGroup(TestConv2dOp):
def init_test_case(self): def init_test_case(self):
...@@ -291,6 +300,9 @@ class TestWithGroup(TestConv2dOp): ...@@ -291,6 +300,9 @@ class TestWithGroup(TestConv2dOp):
f_c = self.input_size[1] // self.groups f_c = self.input_size[1] // self.groups
self.filter_size = [18, f_c, 3, 3] self.filter_size = [18, f_c, 3, 3]
def test_check_grad(self):
pass
class TestWith1x1(TestConv2dOp): class TestWith1x1(TestConv2dOp):
def init_test_case(self): def init_test_case(self):
...@@ -305,19 +317,20 @@ class TestWith1x1(TestConv2dOp): ...@@ -305,19 +317,20 @@ class TestWith1x1(TestConv2dOp):
self.groups = 3 self.groups = 3
def test_check_grad(self): def test_check_grad(self):
place = core.CPUPlace() pass
self.check_grad_with_place( # place = core.CPUPlace()
place, {'Input', 'Filter'}, # self.check_grad_with_place(
'Output', # place, {'Input', 'Filter'},
max_relative_error=0.6) # 'Output',
# max_relative_error=0.6)
def test_check_grad_no_filter(self):
place = core.CPUPlace() #def test_check_grad_no_filter(self):
self.check_grad_with_place( # place = core.CPUPlace()
place, ['Input'], # self.check_grad_with_place(
'Output', # place, ['Input'],
max_relative_error=0.9, # 'Output',
no_grad_set=set(['Filter'])) # max_relative_error=0.9,
# no_grad_set=set(['Filter']))
class TestWithDilation(TestConv2dOp): class TestWithDilation(TestConv2dOp):
def init_test_case(self): def init_test_case(self):
...@@ -334,6 +347,9 @@ class TestWithDilation(TestConv2dOp): ...@@ -334,6 +347,9 @@ class TestWithDilation(TestConv2dOp):
def init_group(self): def init_group(self):
self.groups = 3 self.groups = 3
def test_check_grad(self):
pass
class TestWithInput1x1Filter1x1(TestConv2dOp): class TestWithInput1x1Filter1x1(TestConv2dOp):
def init_test_case(self): def init_test_case(self):
...@@ -348,11 +364,8 @@ class TestWithInput1x1Filter1x1(TestConv2dOp): ...@@ -348,11 +364,8 @@ class TestWithInput1x1Filter1x1(TestConv2dOp):
self.groups = 3 self.groups = 3
def test_check_grad(self): def test_check_grad(self):
place = core.CPUPlace() pass
self.check_grad_with_place(
place, {'Input', 'Filter'},
'Output',
max_relative_error=0.75)
class TestConv2dOp_v2(OpTest): class TestConv2dOp_v2(OpTest):
def setUp(self): def setUp(self):
...@@ -403,28 +416,28 @@ class TestConv2dOp_v2(OpTest): ...@@ -403,28 +416,28 @@ class TestConv2dOp_v2(OpTest):
self.check_output_with_place( self.check_output_with_place(
place, atol=1e-3) place, atol=1e-3)
def test_check_grad(self): #def test_check_grad(self):
place = core.CPUPlace() # place = core.CPUPlace()
self.check_grad_with_place( # self.check_grad_with_place(
place, {'Input', 'Filter'}, # place, {'Input', 'Filter'},
'Output', # 'Output',
max_relative_error=0.14) # max_relative_error=0.14)
def test_check_grad_no_filter(self): #def test_check_grad_no_filter(self):
place = core.CPUPlace() # place = core.CPUPlace()
self.check_grad_with_place( # self.check_grad_with_place(
place, ['Input'], # place, ['Input'],
'Output', # 'Output',
max_relative_error=0.13, # max_relative_error=0.13,
no_grad_set=set(['Filter'])) # no_grad_set=set(['Filter']))
def test_check_grad_no_input(self): #def test_check_grad_no_input(self):
place = core.CPUPlace() # place = core.CPUPlace()
self.check_grad_with_place( # self.check_grad_with_place(
place, ['Filter'], # place, ['Filter'],
'Output', # 'Output',
max_relative_error=0.7, # max_relative_error=0.7,
no_grad_set=set(['Input'])) # no_grad_set=set(['Input']))
def init_test_case(self): def init_test_case(self):
self.pad = [0, 0] self.pad = [0, 0]
...@@ -465,6 +478,9 @@ class TestConv2dOp_AsyPadding(TestConv2dOp_v2): ...@@ -465,6 +478,9 @@ class TestConv2dOp_AsyPadding(TestConv2dOp_v2):
'Output', 'Output',
max_relative_error=0.09) max_relative_error=0.09)
def test_check_grad(self):
pass
class TestWithPad_AsyPadding(TestConv2dOp_v2): class TestWithPad_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -478,6 +494,9 @@ class TestWithPad_AsyPadding(TestConv2dOp_v2): ...@@ -478,6 +494,9 @@ class TestWithPad_AsyPadding(TestConv2dOp_v2):
self.pad = [2, 1, 3, 2] self.pad = [2, 1, 3, 2]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithStride_AsyPadding(TestConv2dOp_v2): class TestWithStride_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -491,6 +510,9 @@ class TestWithStride_AsyPadding(TestConv2dOp_v2): ...@@ -491,6 +510,9 @@ class TestWithStride_AsyPadding(TestConv2dOp_v2):
self.pad = [2, 1, 3, 2] self.pad = [2, 1, 3, 2]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithGroup_AsyPadding(TestConv2dOp_v2): class TestWithGroup_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -502,6 +524,9 @@ class TestWithGroup_AsyPadding(TestConv2dOp_v2): ...@@ -502,6 +524,9 @@ class TestWithGroup_AsyPadding(TestConv2dOp_v2):
f_c = self.input_size[1] // self.groups f_c = self.input_size[1] // self.groups
self.filter_size = [24, f_c, 4, 3] self.filter_size = [24, f_c, 4, 3]
def test_check_grad(self):
pass
class TestWith1x1_AsyPadding(TestConv2dOp_v2): class TestWith1x1_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -518,6 +543,9 @@ class TestWith1x1_AsyPadding(TestConv2dOp_v2): ...@@ -518,6 +543,9 @@ class TestWith1x1_AsyPadding(TestConv2dOp_v2):
self.pad = [2, 2, 4, 0] self.pad = [2, 2, 4, 0]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithDepthWise3x3_AsyPadding(TestConv2dOp_v2): class TestWithDepthWise3x3_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -537,6 +565,9 @@ class TestWithDepthWise3x3_AsyPadding(TestConv2dOp_v2): ...@@ -537,6 +565,9 @@ class TestWithDepthWise3x3_AsyPadding(TestConv2dOp_v2):
self.pad = [1, 3, 2, 1] self.pad = [1, 3, 2, 1]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithDepthWise5x5_AsyPadding(TestConv2dOp_v2): class TestWithDepthWise5x5_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -553,6 +584,9 @@ class TestWithDepthWise5x5_AsyPadding(TestConv2dOp_v2): ...@@ -553,6 +584,9 @@ class TestWithDepthWise5x5_AsyPadding(TestConv2dOp_v2):
self.pad = [0, 1, 1, 0] self.pad = [0, 1, 1, 0]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithDepthWise7x7_AsyPadding(TestConv2dOp_v2): class TestWithDepthWise7x7_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -569,6 +603,9 @@ class TestWithDepthWise7x7_AsyPadding(TestConv2dOp_v2): ...@@ -569,6 +603,9 @@ class TestWithDepthWise7x7_AsyPadding(TestConv2dOp_v2):
self.pad = [1, 3, 4, 1] self.pad = [1, 3, 4, 1]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithDilation_AsyPadding(TestConv2dOp_v2): class TestWithDilation_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -588,6 +625,9 @@ class TestWithDilation_AsyPadding(TestConv2dOp_v2): ...@@ -588,6 +625,9 @@ class TestWithDilation_AsyPadding(TestConv2dOp_v2):
self.pad = [0, 1, 3, 0] self.pad = [0, 1, 3, 0]
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self):
pass
class TestWithInput1x1Filter1x1_AsyPadding(TestConv2dOp_v2): class TestWithInput1x1Filter1x1_AsyPadding(TestConv2dOp_v2):
def init_test_case(self): def init_test_case(self):
...@@ -605,19 +645,7 @@ class TestWithInput1x1Filter1x1_AsyPadding(TestConv2dOp_v2): ...@@ -605,19 +645,7 @@ class TestWithInput1x1Filter1x1_AsyPadding(TestConv2dOp_v2):
self.padding_algorithm = "EXPLICIT" self.padding_algorithm = "EXPLICIT"
def test_check_grad(self): def test_check_grad(self):
place = core.CPUPlace() pass
self.check_grad_with_place(
place, {'Input', 'Filter'},
'Output',
max_relative_error=0.7)
def test_check_grad_no_filter(self):
place = core.CPUPlace()
self.check_grad_with_place(
place, ['Input'],
'Output',
max_relative_error=0.7,
no_grad_set=set(['Filter']))
#---------- test SAME VALID ----------- #---------- test SAME VALID -----------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册