@@ -78,12 +78,13 @@ def avg_pool2D_forward_naive(x,
78
78
79
79
class TestPool2d_Op (OpTest ):
80
80
def setUp (self ):
81
+ self .op_type = "pool2d"
81
82
self .use_cudnn = False
82
83
self .use_mkldnn = False
83
84
self .dtype = np .float32
84
85
self .init_test_case ()
85
86
self .init_global_pool ()
86
- self .init_op_type ()
87
+ self .init_kernel_type ()
87
88
self .init_pool_type ()
88
89
self .init_ceil_mode ()
89
90
if self .global_pool :
@@ -131,8 +132,8 @@ def init_test_case(self):
131
132
self .strides = [1 , 1 ]
132
133
self .paddings = [0 , 0 ]
133
134
134
- def init_op_type (self ):
135
- self . op_type = "pool2d"
135
+ def init_kernel_type (self ):
136
+ pass
136
137
137
138
def init_pool_type (self ):
138
139
self .pool_type = "avg"
@@ -152,9 +153,6 @@ def init_test_case(self):
152
153
self .strides = [1 , 1 ]
153
154
self .paddings = [0 , 0 ]
154
155
155
- def init_op_type (self ):
156
- self .op_type = "pool2d"
157
-
158
156
def init_pool_type (self ):
159
157
self .pool_type = "avg"
160
158
self .pool2D_forward_naive = avg_pool2D_forward_naive
@@ -170,9 +168,6 @@ def init_test_case(self):
170
168
self .strides = [1 , 1 ]
171
169
self .paddings = [1 , 1 ]
172
170
173
- def init_op_type (self ):
174
- self .op_type = "pool2d"
175
-
176
171
def init_pool_type (self ):
177
172
self .pool_type = "avg"
178
173
self .pool2D_forward_naive = avg_pool2D_forward_naive
@@ -182,43 +177,32 @@ def init_global_pool(self):
182
177
183
178
184
179
class TestCase3 (TestPool2d_Op ):
185
- def init_op_type (self ):
186
- self .op_type = "pool2d"
187
-
188
180
def init_pool_type (self ):
189
181
self .pool_type = "max"
190
182
self .pool2D_forward_naive = max_pool2D_forward_naive
191
183
192
184
193
185
class TestCase4 (TestCase1 ):
194
- def init_op_type (self ):
195
- self .op_type = "pool2d"
196
-
197
186
def init_pool_type (self ):
198
187
self .pool_type = "max"
199
188
self .pool2D_forward_naive = max_pool2D_forward_naive
200
189
201
190
202
191
class TestCase5 (TestCase2 ):
203
- def init_op_type (self ):
204
- self .op_type = "pool2d"
205
-
206
192
def init_pool_type (self ):
207
193
self .pool_type = "max"
208
194
self .pool2D_forward_naive = max_pool2D_forward_naive
209
195
210
196
211
197
#--------------------test pool2d--------------------
212
198
class TestCUDNNCase1 (TestPool2d_Op ):
213
- def init_op_type (self ):
199
+ def init_kernel_type (self ):
214
200
self .use_cudnn = True
215
- self .op_type = "pool2d"
216
201
217
202
218
203
class TestFP16CUDNNCase1 (TestPool2d_Op ):
219
- def init_op_type (self ):
204
+ def init_kernel_type (self ):
220
205
self .use_cudnn = True
221
- self .op_type = "pool2d"
222
206
self .dtype = np .float16
223
207
224
208
def test_check_output (self ):
@@ -229,15 +213,13 @@ def test_check_output(self):
229
213
230
214
231
215
class TestCUDNNCase2 (TestCase1 ):
232
- def init_op_type (self ):
216
+ def init_kernel_type (self ):
233
217
self .use_cudnn = True
234
- self .op_type = "pool2d"
235
218
236
219
237
220
class TestFP16CUDNNCase2 (TestCase1 ):
238
- def init_op_type (self ):
221
+ def init_kernel_type (self ):
239
222
self .use_cudnn = True
240
- self .op_type = "pool2d"
241
223
self .dtype = np .float16
242
224
243
225
def test_check_output (self ):
@@ -248,15 +230,13 @@ def test_check_output(self):
248
230
249
231
250
232
class TestCUDNNCase3 (TestCase2 ):
251
- def init_op_type (self ):
233
+ def init_kernel_type (self ):
252
234
self .use_cudnn = True
253
- self .op_type = "pool2d"
254
235
255
236
256
237
class TestFP16CUDNNCase3 (TestCase2 ):
257
- def init_op_type (self ):
238
+ def init_kernel_type (self ):
258
239
self .use_cudnn = True
259
- self .op_type = "pool2d"
260
240
self .dtype = np .float16
261
241
262
242
def test_check_output (self ):
@@ -267,15 +247,13 @@ def test_check_output(self):
267
247
268
248
269
249
class TestCUDNNCase4 (TestCase3 ):
270
- def init_op_type (self ):
250
+ def init_kernel_type (self ):
271
251
self .use_cudnn = True
272
- self .op_type = "pool2d"
273
252
274
253
275
254
class TestFP16CUDNNCase4 (TestCase3 ):
276
- def init_op_type (self ):
255
+ def init_kernel_type (self ):
277
256
self .use_cudnn = True
278
- self .op_type = "pool2d"
279
257
self .dtype = np .float16
280
258
281
259
def test_check_output (self ):
@@ -286,15 +264,13 @@ def test_check_output(self):
286
264
287
265
288
266
class TestCUDNNCase5 (TestCase4 ):
289
- def init_op_type (self ):
267
+ def init_kernel_type (self ):
290
268
self .use_cudnn = True
291
- self .op_type = "pool2d"
292
269
293
270
294
271
class TestFP16CUDNNCase5 (TestCase4 ):
295
- def init_op_type (self ):
272
+ def init_kernel_type (self ):
296
273
self .use_cudnn = True
297
- self .op_type = "pool2d"
298
274
self .dtype = np .float16
299
275
300
276
def test_check_output (self ):
@@ -305,15 +281,13 @@ def test_check_output(self):
305
281
306
282
307
283
class TestCUDNNCase6 (TestCase5 ):
308
- def init_op_type (self ):
284
+ def init_kernel_type (self ):
309
285
self .use_cudnn = True
310
- self .op_type = "pool2d"
311
286
312
287
313
288
class TestFP16CUDNNCase6 (TestCase5 ):
314
- def init_op_type (self ):
289
+ def init_kernel_type (self ):
315
290
self .use_cudnn = True
316
- self .op_type = "pool2d"
317
291
self .dtype = np .float16
318
292
319
293
def test_check_output (self ):
@@ -345,39 +319,33 @@ def init_ceil_mode(self):
345
319
346
320
#--------------------test pool2d MKLDNN--------------------
347
321
class TestMKLDNNCase1 (TestPool2d_Op ):
348
- def init_op_type (self ):
322
+ def init_kernel_type (self ):
349
323
self .use_mkldnn = True
350
- self .op_type = "pool2d"
351
324
352
325
353
326
class TestMKLDNNCase2 (TestCase1 ):
354
- def init_op_type (self ):
327
+ def init_kernel_type (self ):
355
328
self .use_mkldnn = True
356
- self .op_type = "pool2d"
357
329
358
330
359
331
class TestMKLDNNCase3 (TestCase2 ):
360
- def init_op_type (self ):
332
+ def init_kernel_type (self ):
361
333
self .use_mkldnn = True
362
- self .op_type = "pool2d"
363
334
364
335
365
336
class TestMKLDNNCase4 (TestCase3 ):
366
- def init_op_type (self ):
337
+ def init_kernel_type (self ):
367
338
self .use_mkldnn = True
368
- self .op_type = "pool2d"
369
339
370
340
371
341
class TestMKLDNNCase5 (TestCase4 ):
372
- def init_op_type (self ):
342
+ def init_kernel_type (self ):
373
343
self .use_mkldnn = True
374
- self .op_type = "pool2d"
375
344
376
345
377
346
class TestMKLDNNCase6 (TestCase5 ):
378
- def init_op_type (self ):
347
+ def init_kernel_type (self ):
379
348
self .use_mkldnn = True
380
- self .op_type = "pool2d"
381
349
382
350
383
351
if __name__ == '__main__' :
0 commit comments