|
|
|
@ -63,12 +63,13 @@ def conv2d_forward_naive(input, filter, group, conv_param):
|
|
|
|
|
|
|
|
|
|
class TestConv2dOp(OpTest):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
self.use_cudnn = False
|
|
|
|
|
self.use_mkldnn = False
|
|
|
|
|
self.init_op_type()
|
|
|
|
|
self.dtype = np.float32
|
|
|
|
|
self.init_kernel_type()
|
|
|
|
|
self.init_group()
|
|
|
|
|
self.init_dilation()
|
|
|
|
|
self.init_data_type()
|
|
|
|
|
self.init_test_case()
|
|
|
|
|
|
|
|
|
|
conv2d_param = {
|
|
|
|
@ -159,17 +160,14 @@ class TestConv2dOp(OpTest):
|
|
|
|
|
f_c = self.input_size[1] / self.groups
|
|
|
|
|
self.filter_size = [6, f_c, 3, 3]
|
|
|
|
|
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
self.dtype = np.float32
|
|
|
|
|
|
|
|
|
|
def init_dilation(self):
|
|
|
|
|
self.dilations = [1, 1]
|
|
|
|
|
|
|
|
|
|
def init_group(self):
|
|
|
|
|
self.groups = 1
|
|
|
|
|
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestWithPad(TestConv2dOp):
|
|
|
|
@ -241,13 +239,13 @@ class TestWithInput1x1Filter1x1(TestConv2dOp):
|
|
|
|
|
|
|
|
|
|
#----------------Conv2dCUDNN----------------
|
|
|
|
|
class TestCUDNN(TestConv2dOp):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNN(TestCUDNN):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNN(TestConv2dOp):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -258,13 +256,13 @@ class TestFP16CUDNN(TestCUDNN):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUDNNWithPad(TestWithPad):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNNWithPad(TestCUDNNWithPad):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNNWithPad(TestWithPad):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -275,13 +273,13 @@ class TestFP16CUDNNWithPad(TestCUDNNWithPad):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUDNNWithStride(TestWithStride):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNNWithStride(TestCUDNNWithStride):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNNWithStride(TestWithStride):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -292,13 +290,13 @@ class TestFP16CUDNNWithStride(TestCUDNNWithStride):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUDNNWithGroup(TestWithGroup):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNNWithGroup(TestCUDNNWithGroup):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNNWithGroup(TestWithGroup):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -309,13 +307,13 @@ class TestFP16CUDNNWithGroup(TestCUDNNWithGroup):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUDNNWith1x1(TestWith1x1):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNNWith1x1(TestCUDNNWith1x1):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNNWith1x1(TestWith1x1):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -326,13 +324,13 @@ class TestFP16CUDNNWith1x1(TestCUDNNWith1x1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCUDNNWithInput1x1Filter1x1(TestWithInput1x1Filter1x1):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16CUDNNWithInput1x1Filter1x1(TestCUDNNWithInput1x1Filter1x1):
|
|
|
|
|
def init_data_type(self):
|
|
|
|
|
class TestFP16CUDNNWithInput1x1Filter1x1(TestWithInput1x1Filter1x1):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_cudnn = True
|
|
|
|
|
self.dtype = np.float16
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -375,21 +373,18 @@ class TestDepthwiseConv2(TestConv2dOp):
|
|
|
|
|
|
|
|
|
|
#----------------Conv2dMKLDNN----------------
|
|
|
|
|
class TestMKLDNN(TestConv2dOp):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_mkldnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestMKLDNNWithPad(TestWithPad):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_mkldnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestMKLDNNWithStride(TestWithStride):
|
|
|
|
|
def init_op_type(self):
|
|
|
|
|
def init_kernel_type(self):
|
|
|
|
|
self.use_mkldnn = True
|
|
|
|
|
self.op_type = "conv2d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|