Skip to content

Commit dcbc428

Browse files
committed
conv2d tests: stop testing on CUDA when use_cudnn=False. Especially when use_mkldnn=True.
1 parent d74bb6a commit dcbc428

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def test_check_output(self):
106106
if self.testcudnn():
107107
place = core.CUDAPlace(0)
108108
self.check_output_with_place(place, atol=1e-5)
109-
else:
110-
self.check_output()
109+
place = core.CPUPlace()
110+
self.check_output_with_place(place, atol=1e-5)
111111

112112
def test_check_grad(self):
113113
if self.dtype == np.float16:
@@ -119,9 +119,9 @@ def test_check_grad(self):
119119
set(['Input', 'Filter']),
120120
'Output',
121121
max_relative_error=0.02)
122-
else:
123-
self.check_grad(
124-
set(['Input', 'Filter']), 'Output', max_relative_error=0.02)
122+
place = core.CPUPlace()
123+
self.check_grad_with_place(
124+
place, set(['Input', 'Filter']), 'Output', max_relative_error=0.02)
125125

126126
def test_check_grad_no_filter(self):
127127
if self.dtype == np.float16:
@@ -133,12 +133,12 @@ def test_check_grad_no_filter(self):
133133
'Output',
134134
max_relative_error=0.02,
135135
no_grad_set=set(['Filter']))
136-
else:
137-
self.check_grad(
138-
['Input'],
139-
'Output',
140-
max_relative_error=0.02,
141-
no_grad_set=set(['Filter']))
136+
place = core.CPUPlace()
137+
self.check_grad_with_place(
138+
place, ['Input'],
139+
'Output',
140+
max_relative_error=0.02,
141+
no_grad_set=set(['Filter']))
142142

143143
def test_check_grad_no_input(self):
144144
if self.dtype == np.float16:
@@ -150,12 +150,12 @@ def test_check_grad_no_input(self):
150150
'Output',
151151
max_relative_error=0.02,
152152
no_grad_set=set(['Input']))
153-
else:
154-
self.check_grad(
155-
['Filter'],
156-
'Output',
157-
max_relative_error=0.02,
158-
no_grad_set=set(['Input']))
153+
place = core.CPUPlace()
154+
self.check_grad_with_place(
155+
place, ['Filter'],
156+
'Output',
157+
max_relative_error=0.02,
158+
no_grad_set=set(['Input']))
159159

160160
def init_test_case(self):
161161
self.pad = [0, 0]

0 commit comments

Comments
 (0)