Skip to content

Commit 7cf2c05

Browse files
committed
add unit test for input's size is 1x1
1 parent b5c9209 commit 7cf2c05

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ def init_group(self):
210210
self.groups = 3
211211

212212

213+
class TestWithInput1x1Filter1x1(TestConv2dOp):
214+
def init_test_case(self):
215+
self.pad = [0, 0]
216+
self.stride = [1, 1]
217+
self.input_size = [2, 3, 1, 1] # NCHW
218+
assert np.mod(self.input_size[1], self.groups) == 0
219+
f_c = self.input_size[1] / self.groups
220+
self.filter_size = [6, f_c, 1, 1]
221+
222+
def init_group(self):
223+
self.groups = 3
224+
225+
213226
#----------------Conv2dCUDNN----------------
214227
class TestCUDNN(TestConv2dOp):
215228
def init_op_type(self):
@@ -241,6 +254,12 @@ def init_op_type(self):
241254
self.op_type = "conv2d"
242255

243256

257+
class TestCUDNNWithInput1x1Filter1x1(TestWithInput1x1Filter1x1):
258+
def init_op_type(self):
259+
self.use_cudnn = True
260+
self.op_type = "conv2d"
261+
262+
244263
class TestDepthwiseConv(TestConv2dOp):
245264
def init_test_case(self):
246265
self.pad = [1, 1]
@@ -265,7 +284,8 @@ def init_test_case(self):
265284
self.op_type = "depthwise_conv2d"
266285

267286

268-
# cudnn v5 does not support dilation conv.
287+
# Please Don't remove the following code.
288+
# Currently, CI use cudnn V5.0 which not support dilation conv.
269289
# class TestCUDNNWithDilation(TestWithDilation):
270290
# def init_op_type(self):
271291
# self.op_type = "conv_cudnn"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ def init_op_type(self):
200200
self.op_type = "conv2d_transpose"
201201

202202

203-
# #cudnn v5 does not support dilation conv.
203+
# Please Don't remove the following code.
204+
# Currently, CI use cudnn V5.0 which not support dilation conv.
204205
# class TestCUDNNWithDilation(TestWithDilation):
205206
# def init_test_case(self):
206207
# self.pad = [1, 1]

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@ def init_group(self):
200200
self.groups = 3
201201

202202

203+
class TestWithInput1x1Filter1x1(TestConv3dOp):
204+
def init_test_case(self):
205+
self.pad = [0, 0, 0]
206+
self.stride = [1, 1, 1]
207+
self.input_size = [2, 3, 1, 1, 1] # NCHW
208+
assert np.mod(self.input_size[1], self.groups) == 0
209+
f_c = self.input_size[1] / self.groups
210+
self.filter_size = [6, f_c, 1, 1, 1]
211+
212+
def init_dilation(self):
213+
self.dilations = [1, 1, 1]
214+
215+
def init_group(self):
216+
self.groups = 3
217+
218+
203219
class TestWithDilation(TestConv3dOp):
204220
def init_test_case(self):
205221
self.pad = [0, 0, 0]
@@ -240,6 +256,12 @@ def init_op_type(self):
240256
self.op_type = "conv3d"
241257

242258

259+
class TestWithInput1x1Filter1x1CUDNN(TestWithInput1x1Filter1x1):
260+
def init_op_type(self):
261+
self.use_cudnn = True
262+
self.op_type = "conv3d"
263+
264+
243265
# FIXME(typhoonzero): find a way to determine if
244266
# using cudnn > 6 in python
245267
# class TestWithDilationCUDNN(TestWithDilation):

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def init_op_type(self):
207207
self.op_type = "conv3d_transpose"
208208

209209

210-
# #cudnn v5 does not support dilation conv.
210+
# Please Don't remove the following code.
211+
# Currently, CI use cudnn V5.0 which not support dilation conv.
211212
# class TestCUDNNWithDilation(TestWithDilation):
212213
# def init_test_case(self):
213214
# self.pad = [1, 1, 1]

0 commit comments

Comments
 (0)