1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8
9 #include <gtest/gtest.h>
10
11 #include "max-pooling-operator-tester.h"
12
13 #include <xnnpack/params.h>
14
15
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_1xM_pool)16 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_1xM_pool) {
17 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
18 for (size_t channels = 1; channels <= 100; channels += 15) {
19 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
20 MaxPoolingOperatorTester()
21 .batch_size(1)
22 .input_height(2)
23 .input_width(pool_size + 2)
24 .pooling_height(1)
25 .pooling_width(pool_size)
26 .channels(channels)
27 .TestU8();
28 }
29 }
30 }
31
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_1xM_pool_with_padding)32 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_1xM_pool_with_padding) {
33 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
34 for (size_t channels = 1; channels <= 100; channels += 15) {
35 for (size_t pool_size = 3; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
36 for (size_t padding_left = 0; padding_left <= 1; padding_left++) {
37 for (size_t padding_right = 0; padding_right <= 1; padding_right++) {
38 MaxPoolingOperatorTester()
39 .batch_size(1)
40 .input_height(2)
41 .input_width(pool_size + 2)
42 .padding_left(padding_left)
43 .padding_right(padding_right)
44 .pooling_height(1)
45 .pooling_width(pool_size)
46 .channels(channels)
47 .TestU8();
48 }
49 }
50 }
51 }
52 }
53
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_1xM_pool_with_stride)54 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_1xM_pool_with_stride) {
55 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
56 for (size_t channels = 1; channels <= 100; channels += 15) {
57 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
58 MaxPoolingOperatorTester()
59 .batch_size(1)
60 .input_height(2)
61 .input_width(pool_size + 4)
62 .pooling_height(1)
63 .pooling_width(pool_size)
64 .stride_width(2)
65 .channels(channels)
66 .TestU8();
67 }
68 }
69 }
70
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_1xM_pool_with_dilation)71 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_1xM_pool_with_dilation) {
72 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
73 for (size_t channels = 1; channels <= 100; channels += 15) {
74 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
75 MaxPoolingOperatorTester()
76 .batch_size(1)
77 .input_height(2)
78 .input_width(2 * pool_size + 1)
79 .pooling_height(1)
80 .pooling_width(pool_size)
81 .dilation_width(2)
82 .channels(channels)
83 .TestU8();
84 }
85 }
86 }
87
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_Mx1_pool)88 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_Mx1_pool) {
89 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
90 for (size_t channels = 1; channels <= 100; channels += 15) {
91 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
92 MaxPoolingOperatorTester()
93 .batch_size(1)
94 .input_height(pool_size + 1)
95 .input_width(3)
96 .pooling_height(pool_size)
97 .pooling_width(1)
98 .channels(channels)
99 .TestU8();
100 }
101 }
102 }
103
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_Mx1_pool_with_padding)104 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_Mx1_pool_with_padding) {
105 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
106 for (size_t channels = 1; channels <= 100; channels += 15) {
107 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
108 for (size_t padding_top = 0; padding_top <= 1; padding_top++) {
109 for (size_t padding_bottom = 0; padding_bottom <= 1; padding_bottom++) {
110 MaxPoolingOperatorTester()
111 .batch_size(1)
112 .input_height(pool_size + 1)
113 .input_width(3)
114 .padding_top(padding_top)
115 .padding_bottom(padding_bottom)
116 .pooling_height(pool_size)
117 .pooling_width(1)
118 .channels(channels)
119 .TestU8();
120 }
121 }
122 }
123 }
124 }
125
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_Mx1_pool_with_stride)126 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_Mx1_pool_with_stride) {
127 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
128 for (size_t channels = 1; channels <= 100; channels += 15) {
129 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
130 MaxPoolingOperatorTester()
131 .batch_size(1)
132 .input_height(pool_size + 3)
133 .input_width(3)
134 .pooling_height(pool_size)
135 .pooling_width(1)
136 .stride_height(2)
137 .channels(channels)
138 .TestU8();
139 }
140 }
141 }
142
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_Mx1_pool_with_dilation)143 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_Mx1_pool_with_dilation) {
144 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
145 for (size_t channels = 1; channels <= 100; channels += 15) {
146 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
147 MaxPoolingOperatorTester()
148 .batch_size(1)
149 .input_height(2 * pool_size)
150 .input_width(3)
151 .pooling_height(pool_size)
152 .pooling_width(1)
153 .dilation_height(2)
154 .channels(channels)
155 .TestU8();
156 }
157 }
158 }
159
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_pool_with_input_stride)160 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_pool_with_input_stride) {
161 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
162 for (size_t channels = 1; channels <= 100; channels += 15) {
163 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
164 MaxPoolingOperatorTester()
165 .batch_size(1)
166 .input_height(pool_size + 1)
167 .input_width(3)
168 .pooling_height(pool_size)
169 .pooling_width(1)
170 .channels(channels)
171 .input_pixel_stride(5 * channels)
172 .TestU8();
173 MaxPoolingOperatorTester()
174 .batch_size(1)
175 .input_height(2)
176 .input_width(pool_size + 2)
177 .pooling_height(1)
178 .pooling_width(pool_size)
179 .channels(channels)
180 .input_pixel_stride(5 * channels)
181 .TestU8();
182 }
183 }
184 }
185
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_pool_with_output_stride)186 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_pool_with_output_stride) {
187 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
188 for (size_t channels = 1; channels <= 100; channels += 15) {
189 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
190 MaxPoolingOperatorTester()
191 .batch_size(1)
192 .input_height(pool_size + 1)
193 .input_width(3)
194 .pooling_height(pool_size)
195 .pooling_width(1)
196 .channels(channels)
197 .output_pixel_stride(5 * channels)
198 .TestU8();
199 MaxPoolingOperatorTester()
200 .batch_size(1)
201 .input_height(2)
202 .input_width(pool_size + 2)
203 .pooling_height(1)
204 .pooling_width(pool_size)
205 .channels(channels)
206 .output_pixel_stride(5 * channels)
207 .TestU8();
208 }
209 }
210 }
211
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_pool_with_qmin)212 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_pool_with_qmin) {
213 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
214 for (size_t channels = 1; channels <= 100; channels += 15) {
215 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
216 MaxPoolingOperatorTester()
217 .batch_size(1)
218 .input_height(pool_size + 1)
219 .input_width(3)
220 .pooling_height(pool_size)
221 .pooling_width(1)
222 .channels(channels)
223 .qmin(192)
224 .TestU8();
225 MaxPoolingOperatorTester()
226 .batch_size(1)
227 .input_height(2)
228 .input_width(pool_size + 2)
229 .pooling_height(1)
230 .pooling_width(pool_size)
231 .channels(channels)
232 .qmin(192)
233 .TestU8();
234 }
235 }
236 }
237
TEST(MAX_POOLING_NHWC_U8,unit_batch_small_pool_with_qmax)238 TEST(MAX_POOLING_NHWC_U8, unit_batch_small_pool_with_qmax) {
239 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
240 for (size_t channels = 1; channels <= 100; channels += 15) {
241 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
242 MaxPoolingOperatorTester()
243 .batch_size(1)
244 .input_height(pool_size + 1)
245 .input_width(3)
246 .pooling_height(pool_size)
247 .pooling_width(1)
248 .channels(channels)
249 .qmax(192)
250 .TestU8();
251 MaxPoolingOperatorTester()
252 .batch_size(1)
253 .input_height(2)
254 .input_width(pool_size + 2)
255 .pooling_height(1)
256 .pooling_width(pool_size)
257 .channels(channels)
258 .qmax(192)
259 .TestU8();
260 }
261 }
262 }
263
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_1xM_pool)264 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_1xM_pool) {
265 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
266 for (size_t channels = 1; channels <= 100; channels += 15) {
267 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
268 MaxPoolingOperatorTester()
269 .batch_size(1)
270 .input_height(2)
271 .input_width(pool_size + 2)
272 .pooling_height(1)
273 .pooling_width(pool_size)
274 .channels(channels)
275 .TestU8();
276 }
277 }
278 }
279
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_1xM_pool_with_padding)280 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_1xM_pool_with_padding) {
281 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
282 for (size_t channels = 1; channels <= 100; channels += 15) {
283 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
284 for (size_t padding_left = 0; padding_left <= 1; padding_left++) {
285 for (size_t padding_right = 0; padding_right <= 1; padding_right++) {
286 MaxPoolingOperatorTester()
287 .batch_size(1)
288 .input_height(2)
289 .input_width(pool_size + 2)
290 .padding_left(padding_left)
291 .padding_right(padding_right)
292 .pooling_height(1)
293 .pooling_width(pool_size)
294 .channels(channels)
295 .TestU8();
296 }
297 }
298 }
299 }
300 }
301
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_1xM_pool_with_stride)302 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_1xM_pool_with_stride) {
303 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
304 for (size_t channels = 1; channels <= 100; channels += 15) {
305 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
306 MaxPoolingOperatorTester()
307 .batch_size(1)
308 .input_height(2)
309 .input_width(pool_size + 4)
310 .pooling_height(1)
311 .pooling_width(pool_size)
312 .stride_width(2)
313 .channels(channels)
314 .TestU8();
315 }
316 }
317 }
318
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_1xM_pool_with_dilation)319 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_1xM_pool_with_dilation) {
320 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
321 for (size_t channels = 1; channels <= 100; channels += 15) {
322 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
323 MaxPoolingOperatorTester()
324 .batch_size(1)
325 .input_height(2)
326 .input_width(2 * pool_size + 1)
327 .pooling_height(1)
328 .pooling_width(pool_size)
329 .dilation_width(2)
330 .channels(channels)
331 .TestU8();
332 }
333 }
334 }
335
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_Mx1_pool)336 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_Mx1_pool) {
337 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
338 for (size_t channels = 1; channels <= 100; channels += 15) {
339 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
340 MaxPoolingOperatorTester()
341 .batch_size(1)
342 .input_height(pool_size + 1)
343 .input_width(3)
344 .pooling_height(pool_size)
345 .pooling_width(1)
346 .channels(channels)
347 .TestU8();
348 }
349 }
350 }
351
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_Mx1_pool_with_padding)352 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_Mx1_pool_with_padding) {
353 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
354 for (size_t channels = 1; channels <= 100; channels += 15) {
355 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
356 for (size_t padding_top = 0; padding_top <= 1; padding_top++) {
357 for (size_t padding_bottom = 0; padding_bottom <= 1; padding_bottom++) {
358 MaxPoolingOperatorTester()
359 .batch_size(1)
360 .input_height(pool_size + 1)
361 .input_width(3)
362 .padding_top(padding_top)
363 .padding_bottom(padding_bottom)
364 .pooling_height(pool_size)
365 .pooling_width(1)
366 .channels(channels)
367 .TestU8();
368 }
369 }
370 }
371 }
372 }
373
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_Mx1_pool_with_stride)374 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_Mx1_pool_with_stride) {
375 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
376 for (size_t channels = 1; channels <= 100; channels += 15) {
377 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
378 MaxPoolingOperatorTester()
379 .batch_size(1)
380 .input_height(pool_size + 3)
381 .input_width(3)
382 .pooling_height(pool_size)
383 .pooling_width(1)
384 .stride_height(2)
385 .channels(channels)
386 .TestU8();
387 }
388 }
389 }
390
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_Mx1_pool_with_dilation)391 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_Mx1_pool_with_dilation) {
392 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
393 for (size_t channels = 1; channels <= 100; channels += 15) {
394 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
395 MaxPoolingOperatorTester()
396 .batch_size(1)
397 .input_height(2 * pool_size)
398 .input_width(3)
399 .pooling_height(pool_size)
400 .pooling_width(1)
401 .dilation_height(2)
402 .channels(channels)
403 .TestU8();
404 }
405 }
406 }
407
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_pool_with_input_stride)408 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_pool_with_input_stride) {
409 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
410 for (size_t channels = 1; channels <= 100; channels += 15) {
411 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
412 MaxPoolingOperatorTester()
413 .batch_size(1)
414 .input_height(pool_size + 1)
415 .input_width(3)
416 .pooling_height(pool_size)
417 .pooling_width(1)
418 .channels(channels)
419 .input_pixel_stride(5 * channels)
420 .TestU8();
421 MaxPoolingOperatorTester()
422 .batch_size(1)
423 .input_height(2)
424 .input_width(pool_size + 2)
425 .pooling_height(1)
426 .pooling_width(pool_size)
427 .channels(channels)
428 .input_pixel_stride(5 * channels)
429 .TestU8();
430 }
431 }
432 }
433
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_pool_with_output_stride)434 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_pool_with_output_stride) {
435 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
436 for (size_t channels = 1; channels <= 100; channels += 15) {
437 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
438 MaxPoolingOperatorTester()
439 .batch_size(1)
440 .input_height(pool_size + 1)
441 .input_width(3)
442 .pooling_height(pool_size)
443 .pooling_width(1)
444 .channels(channels)
445 .output_pixel_stride(5 * channels)
446 .TestU8();
447 MaxPoolingOperatorTester()
448 .batch_size(1)
449 .input_height(2)
450 .input_width(pool_size + 2)
451 .pooling_height(1)
452 .pooling_width(pool_size)
453 .channels(channels)
454 .output_pixel_stride(5 * channels)
455 .TestU8();
456 }
457 }
458 }
459
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_pool_with_qmin)460 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_pool_with_qmin) {
461 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
462 for (size_t channels = 1; channels <= 100; channels += 15) {
463 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
464 MaxPoolingOperatorTester()
465 .batch_size(1)
466 .input_height(pool_size + 1)
467 .input_width(3)
468 .pooling_height(pool_size)
469 .pooling_width(1)
470 .channels(channels)
471 .qmin(192)
472 .TestU8();
473 MaxPoolingOperatorTester()
474 .batch_size(1)
475 .input_height(2)
476 .input_width(pool_size + 2)
477 .pooling_height(1)
478 .pooling_width(pool_size)
479 .channels(channels)
480 .qmin(192)
481 .TestU8();
482 }
483 }
484 }
485
TEST(MAX_POOLING_NHWC_U8,unit_batch_large_pool_with_qmax)486 TEST(MAX_POOLING_NHWC_U8, unit_batch_large_pool_with_qmax) {
487 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
488 for (size_t channels = 1; channels <= 100; channels += 15) {
489 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
490 MaxPoolingOperatorTester()
491 .batch_size(1)
492 .input_height(pool_size + 1)
493 .input_width(3)
494 .pooling_height(pool_size)
495 .pooling_width(1)
496 .channels(channels)
497 .qmax(192)
498 .TestU8();
499 MaxPoolingOperatorTester()
500 .batch_size(1)
501 .input_height(2)
502 .input_width(pool_size + 2)
503 .pooling_height(1)
504 .pooling_width(pool_size)
505 .channels(channels)
506 .qmax(192)
507 .TestU8();
508 }
509 }
510 }
511
TEST(MAX_POOLING_NHWC_U8,small_batch_small_pool)512 TEST(MAX_POOLING_NHWC_U8, small_batch_small_pool) {
513 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
514 for (size_t channels = 1; channels <= 100; channels += 15) {
515 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
516 MaxPoolingOperatorTester()
517 .batch_size(3)
518 .input_height(pool_size + 1)
519 .input_width(3)
520 .pooling_height(pool_size)
521 .pooling_width(1)
522 .channels(channels)
523 .TestU8();
524 MaxPoolingOperatorTester()
525 .batch_size(3)
526 .input_height(2)
527 .input_width(pool_size + 2)
528 .pooling_height(1)
529 .pooling_width(pool_size)
530 .channels(channels)
531 .TestU8();
532 }
533 }
534 }
535
TEST(MAX_POOLING_NHWC_U8,small_batch_small_pool_with_input_stride)536 TEST(MAX_POOLING_NHWC_U8, small_batch_small_pool_with_input_stride) {
537 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
538 for (size_t channels = 1; channels <= 100; channels += 15) {
539 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
540 MaxPoolingOperatorTester()
541 .batch_size(3)
542 .input_height(pool_size + 1)
543 .input_width(3)
544 .pooling_height(pool_size)
545 .pooling_width(1)
546 .channels(channels)
547 .input_pixel_stride(5 * channels)
548 .TestU8();
549 MaxPoolingOperatorTester()
550 .batch_size(3)
551 .input_height(2)
552 .input_width(pool_size + 2)
553 .pooling_height(1)
554 .pooling_width(pool_size)
555 .channels(channels)
556 .input_pixel_stride(5 * channels)
557 .TestU8();
558 }
559 }
560 }
561
TEST(MAX_POOLING_NHWC_U8,small_batch_small_pool_with_output_stride)562 TEST(MAX_POOLING_NHWC_U8, small_batch_small_pool_with_output_stride) {
563 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
564 for (size_t channels = 1; channels <= 100; channels += 15) {
565 for (size_t pool_size = 2; pool_size <= xnn_params.u8.maxpool.mr; pool_size++) {
566 MaxPoolingOperatorTester()
567 .batch_size(3)
568 .input_height(pool_size + 1)
569 .input_width(3)
570 .pooling_height(pool_size)
571 .pooling_width(1)
572 .channels(channels)
573 .output_pixel_stride(5 * channels)
574 .TestU8();
575 MaxPoolingOperatorTester()
576 .batch_size(3)
577 .input_height(2)
578 .input_width(pool_size + 2)
579 .pooling_height(1)
580 .pooling_width(pool_size)
581 .channels(channels)
582 .output_pixel_stride(5 * channels)
583 .TestU8();
584 }
585 }
586 }
587
TEST(MAX_POOLING_NHWC_U8,small_batch_large_pool)588 TEST(MAX_POOLING_NHWC_U8, small_batch_large_pool) {
589 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
590 for (size_t channels = 1; channels <= 100; channels += 15) {
591 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
592 MaxPoolingOperatorTester()
593 .batch_size(3)
594 .input_height(pool_size + 1)
595 .input_width(3)
596 .pooling_height(pool_size)
597 .pooling_width(1)
598 .channels(channels)
599 .TestU8();
600 MaxPoolingOperatorTester()
601 .batch_size(3)
602 .input_height(2)
603 .input_width(pool_size + 2)
604 .pooling_height(1)
605 .pooling_width(pool_size)
606 .channels(channels)
607 .TestU8();
608 }
609 }
610 }
611
TEST(MAX_POOLING_NHWC_U8,small_batch_large_pool_with_input_stride)612 TEST(MAX_POOLING_NHWC_U8, small_batch_large_pool_with_input_stride) {
613 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
614 for (size_t channels = 1; channels <= 100; channels += 15) {
615 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
616 MaxPoolingOperatorTester()
617 .batch_size(3)
618 .input_height(pool_size + 1)
619 .input_width(3)
620 .pooling_height(pool_size)
621 .pooling_width(1)
622 .channels(channels)
623 .input_pixel_stride(5 * channels)
624 .TestU8();
625 MaxPoolingOperatorTester()
626 .batch_size(3)
627 .input_height(2)
628 .input_width(pool_size + 2)
629 .pooling_height(1)
630 .pooling_width(pool_size)
631 .channels(channels)
632 .input_pixel_stride(5 * channels)
633 .TestU8();
634 }
635 }
636 }
637
TEST(MAX_POOLING_NHWC_U8,small_batch_large_pool_with_output_stride)638 TEST(MAX_POOLING_NHWC_U8, small_batch_large_pool_with_output_stride) {
639 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
640 for (size_t channels = 1; channels <= 100; channels += 15) {
641 for (size_t pool_size = xnn_params.u8.maxpool.mr + 1; pool_size <= xnn_params.u8.maxpool.mr + xnn_params.u8.maxpool.qr; pool_size++) {
642 MaxPoolingOperatorTester()
643 .batch_size(3)
644 .input_height(pool_size + 1)
645 .input_width(3)
646 .pooling_height(pool_size)
647 .pooling_width(1)
648 .channels(channels)
649 .output_pixel_stride(5 * channels)
650 .TestU8();
651 MaxPoolingOperatorTester()
652 .batch_size(3)
653 .input_height(2)
654 .input_width(pool_size + 2)
655 .pooling_height(1)
656 .pooling_width(pool_size)
657 .channels(channels)
658 .output_pixel_stride(5 * channels)
659 .TestU8();
660 }
661 }
662 }
663
TEST(MAX_POOLING_NHWC_U8,setup_increasing_batch)664 TEST(MAX_POOLING_NHWC_U8, setup_increasing_batch) {
665 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
666 MaxPoolingOperatorTester()
667 .batch_size(3)
668 .next_batch_size(5)
669 .input_height(8)
670 .input_width(8)
671 .pooling_height(5)
672 .pooling_width(3)
673 .channels(24)
674 .TestSetupU8();
675 }
676
TEST(MAX_POOLING_NHWC_U8,setup_decreasing_batch)677 TEST(MAX_POOLING_NHWC_U8, setup_decreasing_batch) {
678 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
679 MaxPoolingOperatorTester()
680 .batch_size(5)
681 .next_batch_size(3)
682 .input_height(8)
683 .input_width(8)
684 .pooling_height(5)
685 .pooling_width(3)
686 .channels(24)
687 .TestSetupU8();
688 }
689
TEST(MAX_POOLING_NHWC_U8,setup_changing_height)690 TEST(MAX_POOLING_NHWC_U8, setup_changing_height) {
691 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
692 MaxPoolingOperatorTester()
693 .batch_size(3)
694 .input_height(8)
695 .input_width(8)
696 .next_input_height(9)
697 .pooling_height(5)
698 .pooling_width(3)
699 .channels(24)
700 .TestSetupU8();
701 MaxPoolingOperatorTester()
702 .batch_size(3)
703 .input_height(8)
704 .input_width(8)
705 .next_input_height(7)
706 .pooling_height(5)
707 .pooling_width(3)
708 .channels(24)
709 .TestSetupU8();
710 }
711
TEST(MAX_POOLING_NHWC_U8,setup_changing_width)712 TEST(MAX_POOLING_NHWC_U8, setup_changing_width) {
713 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
714 MaxPoolingOperatorTester()
715 .batch_size(3)
716 .input_height(8)
717 .input_width(8)
718 .next_input_width(9)
719 .pooling_height(5)
720 .pooling_width(3)
721 .channels(24)
722 .TestSetupU8();
723 MaxPoolingOperatorTester()
724 .batch_size(3)
725 .input_height(8)
726 .input_width(8)
727 .next_input_width(7)
728 .pooling_height(5)
729 .pooling_width(3)
730 .channels(24)
731 .TestSetupU8();
732 }
733
TEST(MAX_POOLING_NHWC_U8,setup_swap_height_and_width)734 TEST(MAX_POOLING_NHWC_U8, setup_swap_height_and_width) {
735 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
736 MaxPoolingOperatorTester()
737 .batch_size(3)
738 .input_height(9)
739 .input_width(8)
740 .next_input_height(8)
741 .next_input_width(9)
742 .pooling_height(5)
743 .pooling_width(3)
744 .channels(24)
745 .TestSetupU8();
746 }
747
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_1xM_pool)748 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_1xM_pool) {
749 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
750 for (size_t channels = 1; channels <= 100; channels += 15) {
751 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
752 MaxPoolingOperatorTester()
753 .batch_size(1)
754 .input_height(2)
755 .input_width(pool_size + 2)
756 .pooling_height(1)
757 .pooling_width(pool_size)
758 .channels(channels)
759 .TestF32();
760 }
761 }
762 }
763
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_1xM_pool_with_padding)764 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_1xM_pool_with_padding) {
765 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
766 for (size_t channels = 1; channels <= 100; channels += 15) {
767 for (size_t pool_size = 3; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
768 for (size_t padding_left = 0; padding_left <= 1; padding_left++) {
769 for (size_t padding_right = 0; padding_right <= 1; padding_right++) {
770 MaxPoolingOperatorTester()
771 .batch_size(1)
772 .input_height(2)
773 .input_width(pool_size + 2)
774 .padding_left(padding_left)
775 .padding_right(padding_right)
776 .pooling_height(1)
777 .pooling_width(pool_size)
778 .channels(channels)
779 .TestF32();
780 }
781 }
782 }
783 }
784 }
785
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_1xM_pool_with_stride)786 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_1xM_pool_with_stride) {
787 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
788 for (size_t channels = 1; channels <= 100; channels += 15) {
789 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
790 MaxPoolingOperatorTester()
791 .batch_size(1)
792 .input_height(2)
793 .input_width(pool_size + 4)
794 .pooling_height(1)
795 .pooling_width(pool_size)
796 .stride_width(2)
797 .channels(channels)
798 .TestF32();
799 }
800 }
801 }
802
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_1xM_pool_with_dilation)803 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_1xM_pool_with_dilation) {
804 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
805 for (size_t channels = 1; channels <= 100; channels += 15) {
806 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
807 MaxPoolingOperatorTester()
808 .batch_size(1)
809 .input_height(2)
810 .input_width(2 * pool_size + 1)
811 .pooling_height(1)
812 .pooling_width(pool_size)
813 .dilation_width(2)
814 .channels(channels)
815 .TestF32();
816 }
817 }
818 }
819
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_Mx1_pool)820 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_Mx1_pool) {
821 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
822 for (size_t channels = 1; channels <= 100; channels += 15) {
823 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
824 MaxPoolingOperatorTester()
825 .batch_size(1)
826 .input_height(pool_size + 1)
827 .input_width(3)
828 .pooling_height(pool_size)
829 .pooling_width(1)
830 .channels(channels)
831 .TestF32();
832 }
833 }
834 }
835
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_Mx1_pool_with_padding)836 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_Mx1_pool_with_padding) {
837 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
838 for (size_t channels = 1; channels <= 100; channels += 15) {
839 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
840 for (size_t padding_top = 0; padding_top <= 1; padding_top++) {
841 for (size_t padding_bottom = 0; padding_bottom <= 1; padding_bottom++) {
842 MaxPoolingOperatorTester()
843 .batch_size(1)
844 .input_height(pool_size + 1)
845 .input_width(3)
846 .padding_top(padding_top)
847 .padding_bottom(padding_bottom)
848 .pooling_height(pool_size)
849 .pooling_width(1)
850 .channels(channels)
851 .TestF32();
852 }
853 }
854 }
855 }
856 }
857
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_Mx1_pool_with_stride)858 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_Mx1_pool_with_stride) {
859 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
860 for (size_t channels = 1; channels <= 100; channels += 15) {
861 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
862 MaxPoolingOperatorTester()
863 .batch_size(1)
864 .input_height(pool_size + 3)
865 .input_width(3)
866 .pooling_height(pool_size)
867 .pooling_width(1)
868 .stride_height(2)
869 .channels(channels)
870 .TestF32();
871 }
872 }
873 }
874
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_Mx1_pool_with_dilation)875 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_Mx1_pool_with_dilation) {
876 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
877 for (size_t channels = 1; channels <= 100; channels += 15) {
878 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
879 MaxPoolingOperatorTester()
880 .batch_size(1)
881 .input_height(2 * pool_size)
882 .input_width(3)
883 .pooling_height(pool_size)
884 .pooling_width(1)
885 .dilation_height(2)
886 .channels(channels)
887 .TestF32();
888 }
889 }
890 }
891
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_pool_with_input_stride)892 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_pool_with_input_stride) {
893 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
894 for (size_t channels = 1; channels <= 100; channels += 15) {
895 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
896 MaxPoolingOperatorTester()
897 .batch_size(1)
898 .input_height(pool_size + 1)
899 .input_width(3)
900 .pooling_height(pool_size)
901 .pooling_width(1)
902 .channels(channels)
903 .input_pixel_stride(5 * channels)
904 .TestF32();
905 MaxPoolingOperatorTester()
906 .batch_size(1)
907 .input_height(2)
908 .input_width(pool_size + 2)
909 .pooling_height(1)
910 .pooling_width(pool_size)
911 .channels(channels)
912 .input_pixel_stride(5 * channels)
913 .TestF32();
914 }
915 }
916 }
917
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_pool_with_output_stride)918 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_pool_with_output_stride) {
919 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
920 for (size_t channels = 1; channels <= 100; channels += 15) {
921 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
922 MaxPoolingOperatorTester()
923 .batch_size(1)
924 .input_height(pool_size + 1)
925 .input_width(3)
926 .pooling_height(pool_size)
927 .pooling_width(1)
928 .channels(channels)
929 .output_pixel_stride(5 * channels)
930 .TestF32();
931 MaxPoolingOperatorTester()
932 .batch_size(1)
933 .input_height(2)
934 .input_width(pool_size + 2)
935 .pooling_height(1)
936 .pooling_width(pool_size)
937 .channels(channels)
938 .output_pixel_stride(5 * channels)
939 .TestF32();
940 }
941 }
942 }
943
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_pool_with_qmin)944 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_pool_with_qmin) {
945 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
946 for (size_t channels = 1; channels <= 100; channels += 15) {
947 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
948 MaxPoolingOperatorTester()
949 .batch_size(1)
950 .input_height(pool_size + 1)
951 .input_width(3)
952 .pooling_height(pool_size)
953 .pooling_width(1)
954 .channels(channels)
955 .qmin(192)
956 .TestF32();
957 MaxPoolingOperatorTester()
958 .batch_size(1)
959 .input_height(2)
960 .input_width(pool_size + 2)
961 .pooling_height(1)
962 .pooling_width(pool_size)
963 .channels(channels)
964 .qmin(192)
965 .TestF32();
966 }
967 }
968 }
969
TEST(MAX_POOLING_NHWC_F32,unit_batch_small_pool_with_qmax)970 TEST(MAX_POOLING_NHWC_F32, unit_batch_small_pool_with_qmax) {
971 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
972 for (size_t channels = 1; channels <= 100; channels += 15) {
973 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
974 MaxPoolingOperatorTester()
975 .batch_size(1)
976 .input_height(pool_size + 1)
977 .input_width(3)
978 .pooling_height(pool_size)
979 .pooling_width(1)
980 .channels(channels)
981 .qmax(192)
982 .TestF32();
983 MaxPoolingOperatorTester()
984 .batch_size(1)
985 .input_height(2)
986 .input_width(pool_size + 2)
987 .pooling_height(1)
988 .pooling_width(pool_size)
989 .channels(channels)
990 .qmax(192)
991 .TestF32();
992 }
993 }
994 }
995
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_1xM_pool)996 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_1xM_pool) {
997 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
998 for (size_t channels = 1; channels <= 100; channels += 15) {
999 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1000 MaxPoolingOperatorTester()
1001 .batch_size(1)
1002 .input_height(2)
1003 .input_width(pool_size + 2)
1004 .pooling_height(1)
1005 .pooling_width(pool_size)
1006 .channels(channels)
1007 .TestF32();
1008 }
1009 }
1010 }
1011
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_1xM_pool_with_padding)1012 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_1xM_pool_with_padding) {
1013 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1014 for (size_t channels = 1; channels <= 100; channels += 15) {
1015 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1016 for (size_t padding_left = 0; padding_left <= 1; padding_left++) {
1017 for (size_t padding_right = 0; padding_right <= 1; padding_right++) {
1018 MaxPoolingOperatorTester()
1019 .batch_size(1)
1020 .input_height(2)
1021 .input_width(pool_size + 2)
1022 .padding_left(padding_left)
1023 .padding_right(padding_right)
1024 .pooling_height(1)
1025 .pooling_width(pool_size)
1026 .channels(channels)
1027 .TestF32();
1028 }
1029 }
1030 }
1031 }
1032 }
1033
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_1xM_pool_with_stride)1034 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_1xM_pool_with_stride) {
1035 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1036 for (size_t channels = 1; channels <= 100; channels += 15) {
1037 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1038 MaxPoolingOperatorTester()
1039 .batch_size(1)
1040 .input_height(2)
1041 .input_width(pool_size + 4)
1042 .pooling_height(1)
1043 .pooling_width(pool_size)
1044 .stride_width(2)
1045 .channels(channels)
1046 .TestF32();
1047 }
1048 }
1049 }
1050
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_1xM_pool_with_dilation)1051 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_1xM_pool_with_dilation) {
1052 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1053 for (size_t channels = 1; channels <= 100; channels += 15) {
1054 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1055 MaxPoolingOperatorTester()
1056 .batch_size(1)
1057 .input_height(2)
1058 .input_width(2 * pool_size + 1)
1059 .pooling_height(1)
1060 .pooling_width(pool_size)
1061 .dilation_width(2)
1062 .channels(channels)
1063 .TestF32();
1064 }
1065 }
1066 }
1067
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_Mx1_pool)1068 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_Mx1_pool) {
1069 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1070 for (size_t channels = 1; channels <= 100; channels += 15) {
1071 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1072 MaxPoolingOperatorTester()
1073 .batch_size(1)
1074 .input_height(pool_size + 1)
1075 .input_width(3)
1076 .pooling_height(pool_size)
1077 .pooling_width(1)
1078 .channels(channels)
1079 .TestF32();
1080 }
1081 }
1082 }
1083
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_Mx1_pool_with_padding)1084 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_Mx1_pool_with_padding) {
1085 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1086 for (size_t channels = 1; channels <= 100; channels += 15) {
1087 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1088 for (size_t padding_top = 0; padding_top <= 1; padding_top++) {
1089 for (size_t padding_bottom = 0; padding_bottom <= 1; padding_bottom++) {
1090 MaxPoolingOperatorTester()
1091 .batch_size(1)
1092 .input_height(pool_size + 1)
1093 .input_width(3)
1094 .padding_top(padding_top)
1095 .padding_bottom(padding_bottom)
1096 .pooling_height(pool_size)
1097 .pooling_width(1)
1098 .channels(channels)
1099 .TestF32();
1100 }
1101 }
1102 }
1103 }
1104 }
1105
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_Mx1_pool_with_stride)1106 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_Mx1_pool_with_stride) {
1107 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1108 for (size_t channels = 1; channels <= 100; channels += 15) {
1109 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1110 MaxPoolingOperatorTester()
1111 .batch_size(1)
1112 .input_height(pool_size + 3)
1113 .input_width(3)
1114 .pooling_height(pool_size)
1115 .pooling_width(1)
1116 .stride_height(2)
1117 .channels(channels)
1118 .TestF32();
1119 }
1120 }
1121 }
1122
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_Mx1_pool_with_dilation)1123 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_Mx1_pool_with_dilation) {
1124 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1125 for (size_t channels = 1; channels <= 100; channels += 15) {
1126 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1127 MaxPoolingOperatorTester()
1128 .batch_size(1)
1129 .input_height(2 * pool_size)
1130 .input_width(3)
1131 .pooling_height(pool_size)
1132 .pooling_width(1)
1133 .dilation_height(2)
1134 .channels(channels)
1135 .TestF32();
1136 }
1137 }
1138 }
1139
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_pool_with_input_stride)1140 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_pool_with_input_stride) {
1141 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1142 for (size_t channels = 1; channels <= 100; channels += 15) {
1143 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1144 MaxPoolingOperatorTester()
1145 .batch_size(1)
1146 .input_height(pool_size + 1)
1147 .input_width(3)
1148 .pooling_height(pool_size)
1149 .pooling_width(1)
1150 .channels(channels)
1151 .input_pixel_stride(5 * channels)
1152 .TestF32();
1153 MaxPoolingOperatorTester()
1154 .batch_size(1)
1155 .input_height(2)
1156 .input_width(pool_size + 2)
1157 .pooling_height(1)
1158 .pooling_width(pool_size)
1159 .channels(channels)
1160 .input_pixel_stride(5 * channels)
1161 .TestF32();
1162 }
1163 }
1164 }
1165
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_pool_with_output_stride)1166 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_pool_with_output_stride) {
1167 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1168 for (size_t channels = 1; channels <= 100; channels += 15) {
1169 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1170 MaxPoolingOperatorTester()
1171 .batch_size(1)
1172 .input_height(pool_size + 1)
1173 .input_width(3)
1174 .pooling_height(pool_size)
1175 .pooling_width(1)
1176 .channels(channels)
1177 .output_pixel_stride(5 * channels)
1178 .TestF32();
1179 MaxPoolingOperatorTester()
1180 .batch_size(1)
1181 .input_height(2)
1182 .input_width(pool_size + 2)
1183 .pooling_height(1)
1184 .pooling_width(pool_size)
1185 .channels(channels)
1186 .output_pixel_stride(5 * channels)
1187 .TestF32();
1188 }
1189 }
1190 }
1191
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_pool_with_qmin)1192 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_pool_with_qmin) {
1193 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1194 for (size_t channels = 1; channels <= 100; channels += 15) {
1195 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1196 MaxPoolingOperatorTester()
1197 .batch_size(1)
1198 .input_height(pool_size + 1)
1199 .input_width(3)
1200 .pooling_height(pool_size)
1201 .pooling_width(1)
1202 .channels(channels)
1203 .qmin(192)
1204 .TestF32();
1205 MaxPoolingOperatorTester()
1206 .batch_size(1)
1207 .input_height(2)
1208 .input_width(pool_size + 2)
1209 .pooling_height(1)
1210 .pooling_width(pool_size)
1211 .channels(channels)
1212 .qmin(192)
1213 .TestF32();
1214 }
1215 }
1216 }
1217
TEST(MAX_POOLING_NHWC_F32,unit_batch_large_pool_with_qmax)1218 TEST(MAX_POOLING_NHWC_F32, unit_batch_large_pool_with_qmax) {
1219 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1220 for (size_t channels = 1; channels <= 100; channels += 15) {
1221 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1222 MaxPoolingOperatorTester()
1223 .batch_size(1)
1224 .input_height(pool_size + 1)
1225 .input_width(3)
1226 .pooling_height(pool_size)
1227 .pooling_width(1)
1228 .channels(channels)
1229 .qmax(192)
1230 .TestF32();
1231 MaxPoolingOperatorTester()
1232 .batch_size(1)
1233 .input_height(2)
1234 .input_width(pool_size + 2)
1235 .pooling_height(1)
1236 .pooling_width(pool_size)
1237 .channels(channels)
1238 .qmax(192)
1239 .TestF32();
1240 }
1241 }
1242 }
1243
TEST(MAX_POOLING_NHWC_F32,small_batch_small_pool)1244 TEST(MAX_POOLING_NHWC_F32, small_batch_small_pool) {
1245 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1246 for (size_t channels = 1; channels <= 100; channels += 15) {
1247 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
1248 MaxPoolingOperatorTester()
1249 .batch_size(3)
1250 .input_height(pool_size + 1)
1251 .input_width(3)
1252 .pooling_height(pool_size)
1253 .pooling_width(1)
1254 .channels(channels)
1255 .TestF32();
1256 MaxPoolingOperatorTester()
1257 .batch_size(3)
1258 .input_height(2)
1259 .input_width(pool_size + 2)
1260 .pooling_height(1)
1261 .pooling_width(pool_size)
1262 .channels(channels)
1263 .TestF32();
1264 }
1265 }
1266 }
1267
TEST(MAX_POOLING_NHWC_F32,small_batch_small_pool_with_input_stride)1268 TEST(MAX_POOLING_NHWC_F32, small_batch_small_pool_with_input_stride) {
1269 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1270 for (size_t channels = 1; channels <= 100; channels += 15) {
1271 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
1272 MaxPoolingOperatorTester()
1273 .batch_size(3)
1274 .input_height(pool_size + 1)
1275 .input_width(3)
1276 .pooling_height(pool_size)
1277 .pooling_width(1)
1278 .channels(channels)
1279 .input_pixel_stride(5 * channels)
1280 .TestF32();
1281 MaxPoolingOperatorTester()
1282 .batch_size(3)
1283 .input_height(2)
1284 .input_width(pool_size + 2)
1285 .pooling_height(1)
1286 .pooling_width(pool_size)
1287 .channels(channels)
1288 .input_pixel_stride(5 * channels)
1289 .TestF32();
1290 }
1291 }
1292 }
1293
TEST(MAX_POOLING_NHWC_F32,small_batch_small_pool_with_output_stride)1294 TEST(MAX_POOLING_NHWC_F32, small_batch_small_pool_with_output_stride) {
1295 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1296 for (size_t channels = 1; channels <= 100; channels += 15) {
1297 for (size_t pool_size = 2; pool_size <= xnn_params.f32.maxpool.mr; pool_size++) {
1298 MaxPoolingOperatorTester()
1299 .batch_size(3)
1300 .input_height(pool_size + 1)
1301 .input_width(3)
1302 .pooling_height(pool_size)
1303 .pooling_width(1)
1304 .channels(channels)
1305 .output_pixel_stride(5 * channels)
1306 .TestF32();
1307 MaxPoolingOperatorTester()
1308 .batch_size(3)
1309 .input_height(2)
1310 .input_width(pool_size + 2)
1311 .pooling_height(1)
1312 .pooling_width(pool_size)
1313 .channels(channels)
1314 .output_pixel_stride(5 * channels)
1315 .TestF32();
1316 }
1317 }
1318 }
1319
TEST(MAX_POOLING_NHWC_F32,small_batch_large_pool)1320 TEST(MAX_POOLING_NHWC_F32, small_batch_large_pool) {
1321 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1322 for (size_t channels = 1; channels <= 100; channels += 15) {
1323 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1324 MaxPoolingOperatorTester()
1325 .batch_size(3)
1326 .input_height(pool_size + 1)
1327 .input_width(3)
1328 .pooling_height(pool_size)
1329 .pooling_width(1)
1330 .channels(channels)
1331 .TestF32();
1332 MaxPoolingOperatorTester()
1333 .batch_size(3)
1334 .input_height(2)
1335 .input_width(pool_size + 2)
1336 .pooling_height(1)
1337 .pooling_width(pool_size)
1338 .channels(channels)
1339 .TestF32();
1340 }
1341 }
1342 }
1343
TEST(MAX_POOLING_NHWC_F32,small_batch_large_pool_with_input_stride)1344 TEST(MAX_POOLING_NHWC_F32, small_batch_large_pool_with_input_stride) {
1345 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1346 for (size_t channels = 1; channels <= 100; channels += 15) {
1347 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1348 MaxPoolingOperatorTester()
1349 .batch_size(3)
1350 .input_height(pool_size + 1)
1351 .input_width(3)
1352 .pooling_height(pool_size)
1353 .pooling_width(1)
1354 .channels(channels)
1355 .input_pixel_stride(5 * channels)
1356 .TestF32();
1357 MaxPoolingOperatorTester()
1358 .batch_size(3)
1359 .input_height(2)
1360 .input_width(pool_size + 2)
1361 .pooling_height(1)
1362 .pooling_width(pool_size)
1363 .channels(channels)
1364 .input_pixel_stride(5 * channels)
1365 .TestF32();
1366 }
1367 }
1368 }
1369
TEST(MAX_POOLING_NHWC_F32,small_batch_large_pool_with_output_stride)1370 TEST(MAX_POOLING_NHWC_F32, small_batch_large_pool_with_output_stride) {
1371 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1372 for (size_t channels = 1; channels <= 100; channels += 15) {
1373 for (size_t pool_size = xnn_params.f32.maxpool.mr + 1; pool_size <= xnn_params.f32.maxpool.mr + xnn_params.f32.maxpool.qr; pool_size++) {
1374 MaxPoolingOperatorTester()
1375 .batch_size(3)
1376 .input_height(pool_size + 1)
1377 .input_width(3)
1378 .pooling_height(pool_size)
1379 .pooling_width(1)
1380 .channels(channels)
1381 .output_pixel_stride(5 * channels)
1382 .TestF32();
1383 MaxPoolingOperatorTester()
1384 .batch_size(3)
1385 .input_height(2)
1386 .input_width(pool_size + 2)
1387 .pooling_height(1)
1388 .pooling_width(pool_size)
1389 .channels(channels)
1390 .output_pixel_stride(5 * channels)
1391 .TestF32();
1392 }
1393 }
1394 }
1395
TEST(MAX_POOLING_NHWC_F32,setup_increasing_batch)1396 TEST(MAX_POOLING_NHWC_F32, setup_increasing_batch) {
1397 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1398 MaxPoolingOperatorTester()
1399 .batch_size(3)
1400 .next_batch_size(5)
1401 .input_height(8)
1402 .input_width(8)
1403 .pooling_height(5)
1404 .pooling_width(3)
1405 .channels(24)
1406 .TestSetupF32();
1407 }
1408
TEST(MAX_POOLING_NHWC_F32,setup_decreasing_batch)1409 TEST(MAX_POOLING_NHWC_F32, setup_decreasing_batch) {
1410 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1411 MaxPoolingOperatorTester()
1412 .batch_size(5)
1413 .next_batch_size(3)
1414 .input_height(8)
1415 .input_width(8)
1416 .pooling_height(5)
1417 .pooling_width(3)
1418 .channels(24)
1419 .TestSetupF32();
1420 }
1421
TEST(MAX_POOLING_NHWC_F32,setup_changing_height)1422 TEST(MAX_POOLING_NHWC_F32, setup_changing_height) {
1423 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1424 MaxPoolingOperatorTester()
1425 .batch_size(3)
1426 .input_height(8)
1427 .input_width(8)
1428 .next_input_height(9)
1429 .pooling_height(5)
1430 .pooling_width(3)
1431 .channels(24)
1432 .TestSetupF32();
1433 MaxPoolingOperatorTester()
1434 .batch_size(3)
1435 .input_height(8)
1436 .input_width(8)
1437 .next_input_height(7)
1438 .pooling_height(5)
1439 .pooling_width(3)
1440 .channels(24)
1441 .TestSetupF32();
1442 }
1443
TEST(MAX_POOLING_NHWC_F32,setup_changing_width)1444 TEST(MAX_POOLING_NHWC_F32, setup_changing_width) {
1445 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1446 MaxPoolingOperatorTester()
1447 .batch_size(3)
1448 .input_height(8)
1449 .input_width(8)
1450 .next_input_width(9)
1451 .pooling_height(5)
1452 .pooling_width(3)
1453 .channels(24)
1454 .TestSetupF32();
1455 MaxPoolingOperatorTester()
1456 .batch_size(3)
1457 .input_height(8)
1458 .input_width(8)
1459 .next_input_width(7)
1460 .pooling_height(5)
1461 .pooling_width(3)
1462 .channels(24)
1463 .TestSetupF32();
1464 }
1465
TEST(MAX_POOLING_NHWC_F32,setup_swap_height_and_width)1466 TEST(MAX_POOLING_NHWC_F32, setup_swap_height_and_width) {
1467 ASSERT_EQ(xnn_status_success, xnn_initialize(nullptr /* allocator */));
1468 MaxPoolingOperatorTester()
1469 .batch_size(3)
1470 .input_height(9)
1471 .input_width(8)
1472 .next_input_height(8)
1473 .next_input_width(9)
1474 .pooling_height(5)
1475 .pooling_width(3)
1476 .channels(24)
1477 .TestSetupF32();
1478 }
1479