提交 6ba26257 编写于 作者: L lgone2000 提交者: Yi Wang

fix test_conv2d_op when compile without cuda (#9698)

上级 bcb46f55
...@@ -97,8 +97,11 @@ class TestConv2dOp(OpTest): ...@@ -97,8 +97,11 @@ class TestConv2dOp(OpTest):
} }
self.outputs = {'Output': output} self.outputs = {'Output': output}
def testcudnn(self):
return core.is_compiled_with_cuda() and self.use_cudnn
def test_check_output(self): def test_check_output(self):
if self.use_cudnn: if self.testcudnn():
place = core.CUDAPlace(0) place = core.CUDAPlace(0)
self.check_output_with_place(place, atol=1e-5) self.check_output_with_place(place, atol=1e-5)
else: else:
...@@ -107,7 +110,7 @@ class TestConv2dOp(OpTest): ...@@ -107,7 +110,7 @@ class TestConv2dOp(OpTest):
def test_check_grad(self): def test_check_grad(self):
if self.dtype == np.float16: if self.dtype == np.float16:
return return
if self.use_cudnn: if self.testcudnn():
place = core.CUDAPlace(0) place = core.CUDAPlace(0)
self.check_grad_with_place( self.check_grad_with_place(
place, place,
...@@ -121,7 +124,7 @@ class TestConv2dOp(OpTest): ...@@ -121,7 +124,7 @@ class TestConv2dOp(OpTest):
def test_check_grad_no_filter(self): def test_check_grad_no_filter(self):
if self.dtype == np.float16: if self.dtype == np.float16:
return return
if self.use_cudnn: if self.testcudnn():
place = core.CUDAPlace(0) place = core.CUDAPlace(0)
self.check_grad_with_place( self.check_grad_with_place(
place, ['Input'], place, ['Input'],
...@@ -138,7 +141,7 @@ class TestConv2dOp(OpTest): ...@@ -138,7 +141,7 @@ class TestConv2dOp(OpTest):
def test_check_grad_no_input(self): def test_check_grad_no_input(self):
if self.dtype == np.float16: if self.dtype == np.float16:
return return
if self.use_cudnn: if self.testcudnn():
place = core.CUDAPlace(0) place = core.CUDAPlace(0)
self.check_grad_with_place( self.check_grad_with_place(
place, ['Filter'], place, ['Filter'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册