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