Skip to content

Commit

Permalink
fix test_conv2d_op when compile without cuda (#9698)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgone2000 authored and wangkuiyi committed Apr 7, 2018
1 parent bcb46f5 commit 6ba2625
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/paddle/fluid/tests/unittests/test_conv2d_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ def setUp(self):
}
self.outputs = {'Output': output}

def testcudnn(self):
return core.is_compiled_with_cuda() and self.use_cudnn

def test_check_output(self):
if self.use_cudnn:
if self.testcudnn():
place = core.CUDAPlace(0)
self.check_output_with_place(place, atol=1e-5)
else:
Expand All @@ -107,7 +110,7 @@ def test_check_output(self):
def test_check_grad(self):
if self.dtype == np.float16:
return
if self.use_cudnn:
if self.testcudnn():
place = core.CUDAPlace(0)
self.check_grad_with_place(
place,
Expand All @@ -121,7 +124,7 @@ def test_check_grad(self):
def test_check_grad_no_filter(self):
if self.dtype == np.float16:
return
if self.use_cudnn:
if self.testcudnn():
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['Input'],
Expand All @@ -138,7 +141,7 @@ def test_check_grad_no_filter(self):
def test_check_grad_no_input(self):
if self.dtype == np.float16:
return
if self.use_cudnn:
if self.testcudnn():
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['Filter'],
Expand Down

0 comments on commit 6ba2625

Please sign in to comment.