Skip to content

Commit 6ba2625

Browse files
lgone2000wangkuiyi
authored andcommitted
fix test_conv2d_op when compile without cuda (#9698)
1 parent bcb46f5 commit 6ba2625

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

python/paddle/fluid/tests/unittests/test_conv2d_op.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ def setUp(self):
9797
}
9898
self.outputs = {'Output': output}
9999

100+
def testcudnn(self):
101+
return core.is_compiled_with_cuda() and self.use_cudnn
102+
100103
def test_check_output(self):
101-
if self.use_cudnn:
104+
if self.testcudnn():
102105
place = core.CUDAPlace(0)
103106
self.check_output_with_place(place, atol=1e-5)
104107
else:
@@ -107,7 +110,7 @@ def test_check_output(self):
107110
def test_check_grad(self):
108111
if self.dtype == np.float16:
109112
return
110-
if self.use_cudnn:
113+
if self.testcudnn():
111114
place = core.CUDAPlace(0)
112115
self.check_grad_with_place(
113116
place,
@@ -121,7 +124,7 @@ def test_check_grad(self):
121124
def test_check_grad_no_filter(self):
122125
if self.dtype == np.float16:
123126
return
124-
if self.use_cudnn:
127+
if self.testcudnn():
125128
place = core.CUDAPlace(0)
126129
self.check_grad_with_place(
127130
place, ['Input'],
@@ -138,7 +141,7 @@ def test_check_grad_no_filter(self):
138141
def test_check_grad_no_input(self):
139142
if self.dtype == np.float16:
140143
return
141-
if self.use_cudnn:
144+
if self.testcudnn():
142145
place = core.CUDAPlace(0)
143146
self.check_grad_with_place(
144147
place, ['Filter'],

0 commit comments

Comments
 (0)