提交 fa8bab9c 编写于 作者: F FDInSky 提交者: Zhang Ting

add fp64 check_grad for conv2d, conv3d (#21931)

* test=develop add fp64 check_grad for conv2d, conv3d
上级 cf7b3253
......@@ -44,6 +44,7 @@ class TestConv2dMKLDNNOp(TestConv2dOp):
self.data_format = "NCHW"
self.use_mkldnn = True
self._cpu_only = True
self.dtype = np.float32
def init_test_case(self):
self.pad = [0, 0]
......@@ -62,6 +63,7 @@ class TestConv2dMKLDNNOp(TestConv2dOp):
self.fuse_brelu_threshold = 6.0
self.fuse_residual_connection = False
self.input_residual_size = None
TestConv2dOp.setUp(self)
output = self.outputs['Output']
......@@ -179,6 +181,7 @@ class TestWithInput1x1Filter1x1(TestConv2dMKLDNNOp):
class TestConv2dOp_AsyPadding_MKLDNN(TestConv2dOp_v2):
def init_kernel_type(self):
self.use_mkldnn = True
self.dtype = np.float32
def init_paddings(self):
self.pad = [0, 0, 1, 2]
......
......@@ -15,7 +15,7 @@
from __future__ import print_function
import unittest
import numpy as np
from paddle.fluid.tests.unittests.test_conv3d_op import TestConv3dOp, TestCase1, TestWithGroup1, TestWithGroup2, TestWith1x1, TestWithInput1x1Filter1x1, TestConv3dOp_2
......@@ -23,42 +23,49 @@ class TestMKLDNN(TestConv3dOp):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestMKLDNNCase1(TestCase1):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestMKLDNNGroup1(TestWithGroup1):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestMKLDNNGroup2(TestWithGroup2):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestMKLDNNWith1x1(TestWith1x1):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestMKLDNNWithInput1x1Filter1x1(TestWithInput1x1Filter1x1):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestConv3dOp_AsyPadding_MKLDNN(TestConv3dOp):
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
def init_paddings(self):
self.pad = [1, 0, 1, 0, 0, 2]
......@@ -70,12 +77,22 @@ class TestConv3dOp_Same_MKLDNN(TestConv3dOp_AsyPadding_MKLDNN):
self.pad = [0, 0, 0]
self.padding_algorithm = "SAME"
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
class TestConv3dOp_Valid_MKLDNN(TestConv3dOp_AsyPadding_MKLDNN):
def init_paddings(self):
self.pad = [1, 1, 1]
self.padding_algorithm = "VALID"
def init_kernel_type(self):
self.use_mkldnn = True
self.data_format = "NCHW"
self.dtype = np.float32
if __name__ == '__main__':
unittest.main()
......@@ -298,7 +298,7 @@ class TestConv2dOp(OpTest):
self.use_mkldnn = False
self.fuse_relu_before_depthwise_conv = False
self.data_format = "AnyLayout"
self.dtype = np.float32
self.dtype = np.float64
self.init_kernel_type()
self.init_group()
self.init_dilation()
......@@ -723,7 +723,7 @@ class TestConv2dOp_v2(OpTest):
self.use_cuda = False
self.use_mkldnn = False
self.fuse_relu_before_depthwise_conv = False
self.dtype = np.float32
self.dtype = np.float64
self.init_kernel_type()
self.init_group()
self.init_dilation()
......
......@@ -234,7 +234,7 @@ class TestConv3dOp(OpTest):
self.use_cudnn = False
self.use_mkldnn = False
self.data_format = "AnyLayout"
self.dtype = np.float32
self.dtype = np.float64
self.init_kernel_type()
self.init_group()
self.init_dilation()
......@@ -525,7 +525,7 @@ class TestConv3dOp_2(OpTest):
self.use_cudnn = False
self.use_mkldnn = False
self.data_format = "NCDHW"
self.dtype = np.float32
self.dtype = np.float64
self.init_kernel_type()
self.init_group()
self.init_dilation()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册