blob: 90a716dbd5ef196a86ac069af54022367e99025a [file] [log] [blame]
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001#!/usr/bin/env python
2# Copyright 2020 Google LLC
3#
4# This source code is licensed under the BSD-style license found in the
5# LICENSE file in the root directory of this source tree.
6
7import argparse
8import codecs
9import math
10import os
11import re
12import sys
13import yaml
14
15sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
16from primes import next_prime
17import xngen
18import xnncommon
19
20
21parser = argparse.ArgumentParser(description='AvgPool microkernel test generator')
22parser.add_argument("-s", "--spec", metavar="FILE", required=True,
23 help="Specification (YAML) file")
24parser.add_argument("-o", "--output", metavar="FILE", required=True,
25 help='Output (C++ source) file')
26parser.set_defaults(defines=list())
27
28
29def split_ukernel_name(name):
Marat Dukhan08b7a972020-07-14 18:17:29 -070030 match = re.match(r"^xnn_(qu8|f16|f32)_[p]?avgpool(_(minmax))?_ukernel_((\d+)p)?(\d+)x__(.+)_c(\d+)$", name)
Marat Dukhan6ee435a2020-02-26 22:33:38 -080031 if match is None:
32 raise ValueError("Unexpected microkernel name: " + name)
33
Marat Dukhan99936602020-04-11 16:47:01 -070034 if match.group(4):
35 primary_tile = int(match.group(5))
36 incremental_tile = int(match.group(6))
Marat Dukhan6ee435a2020-02-26 22:33:38 -080037 else:
Marat Dukhan99936602020-04-11 16:47:01 -070038 primary_tile = int(match.group(6))
Marat Dukhan6ee435a2020-02-26 22:33:38 -080039 incremental_tile = 0
Marat Dukhan99936602020-04-11 16:47:01 -070040 channel_tile = int(match.group(8))
Marat Dukhan6ee435a2020-02-26 22:33:38 -080041
Marat Dukhan99936602020-04-11 16:47:01 -070042 arch, isa = xnncommon.parse_target_name(target_name=match.group(7))
Marat Dukhan6ee435a2020-02-26 22:33:38 -080043 return primary_tile, incremental_tile, channel_tile, arch, isa
44
45
46AVGPOOL_TEST_TEMPLATE = """\
47$if INCREMENTAL_TILE == 0:
48 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile) {
49 $if ISA_CHECK:
50 ${ISA_CHECK};
51 AvgPoolMicrokernelTester()
52 .pooling_elements(${PRIMARY_TILE})
53 .pooling_tile(${PRIMARY_TILE})
54 .channels(${CHANNEL_TILE})
55 .Test(${", ".join(TEST_ARGS)});
56 }
57
58 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_input_offset) {
59 $if ISA_CHECK:
60 ${ISA_CHECK};
61 AvgPoolMicrokernelTester()
62 .pooling_elements(${PRIMARY_TILE})
63 .pooling_tile(${PRIMARY_TILE})
64 .channels(${CHANNEL_TILE})
65 .input_offset(${next_prime(CHANNEL_TILE+1)})
66 .Test(${", ".join(TEST_ARGS)});
67 }
68
Marat Dukhanee1f63e2020-02-27 15:43:52 -080069 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_zero) {
70 $if ISA_CHECK:
71 ${ISA_CHECK};
72 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE}; zero_index++) {
73 AvgPoolMicrokernelTester()
74 .pooling_elements(${PRIMARY_TILE})
75 .pooling_tile(${PRIMARY_TILE})
76 .channels(${CHANNEL_TILE})
77 .input_offset(${next_prime(CHANNEL_TILE+1)})
78 .zero_index(zero_index)
79 .Test(${", ".join(TEST_ARGS)});
80 }
81 }
82
Marat Dukhan08b7a972020-07-14 18:17:29 -070083 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -080084 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_input_scale) {
85 $if ISA_CHECK:
86 ${ISA_CHECK};
87 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
88 AvgPoolMicrokernelTester()
89 .pooling_elements(${PRIMARY_TILE})
90 .pooling_tile(${PRIMARY_TILE})
91 .channels(${CHANNEL_TILE})
92 .input_scale(scale)
93 .Test(${", ".join(TEST_ARGS)});
94 }
95 }
96
97 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_input_zero_point) {
98 $if ISA_CHECK:
99 ${ISA_CHECK};
100 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
101 AvgPoolMicrokernelTester()
102 .pooling_elements(${PRIMARY_TILE})
103 .pooling_tile(${PRIMARY_TILE})
104 .channels(${CHANNEL_TILE})
105 .input_zero_point(zero_point)
106 .Test(${", ".join(TEST_ARGS)});
107 }
108 }
109
110 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_output_scale) {
111 $if ISA_CHECK:
112 ${ISA_CHECK};
113 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
114 AvgPoolMicrokernelTester()
115 .pooling_elements(${PRIMARY_TILE})
116 .pooling_tile(${PRIMARY_TILE})
117 .channels(${CHANNEL_TILE})
118 .output_scale(scale)
119 .Test(${", ".join(TEST_ARGS)});
120 }
121 }
122
123 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_output_zero_point) {
124 $if ISA_CHECK:
125 ${ISA_CHECK};
126 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
127 AvgPoolMicrokernelTester()
128 .pooling_elements(${PRIMARY_TILE})
129 .pooling_tile(${PRIMARY_TILE})
130 .channels(${CHANNEL_TILE})
131 .output_zero_point(zero_point)
132 .Test(${", ".join(TEST_ARGS)});
133 }
134 }
135
136 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_qmin) {
137 $if ISA_CHECK:
138 ${ISA_CHECK};
139 AvgPoolMicrokernelTester()
140 .pooling_elements(${PRIMARY_TILE})
141 .pooling_tile(${PRIMARY_TILE})
142 .channels(${CHANNEL_TILE})
143 .qmin(128)
144 .Test(${", ".join(TEST_ARGS)});
145 }
146
147 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_fulltile_with_qmax) {
148 $if ISA_CHECK:
149 ${ISA_CHECK};
150 AvgPoolMicrokernelTester()
151 .pooling_elements(${PRIMARY_TILE})
152 .pooling_tile(${PRIMARY_TILE})
153 .channels(${CHANNEL_TILE})
154 .qmax(128)
155 .Test(${", ".join(TEST_ARGS)});
156 }
157
158 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_subtile) {
159 $if ISA_CHECK:
160 ${ISA_CHECK};
161 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
162 AvgPoolMicrokernelTester()
163 .pooling_elements(pooling_elements)
164 .pooling_tile(${PRIMARY_TILE})
165 .channels(${CHANNEL_TILE})
166 .Test(${", ".join(TEST_ARGS)});
167 }
168 }
169
170 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_subtile_with_input_offset) {
171 $if ISA_CHECK:
172 ${ISA_CHECK};
173 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
174 AvgPoolMicrokernelTester()
175 .pooling_elements(pooling_elements)
176 .pooling_tile(${PRIMARY_TILE})
177 .channels(${CHANNEL_TILE})
178 .input_offset(${next_prime(CHANNEL_TILE+1)})
179 .Test(${", ".join(TEST_ARGS)});
180 }
181 }
182
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800183 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_unipass_subtile_with_zero) {
184 $if ISA_CHECK:
185 ${ISA_CHECK};
186 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
187 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
188 AvgPoolMicrokernelTester()
189 .pooling_elements(pooling_elements)
190 .pooling_tile(${PRIMARY_TILE})
191 .channels(${CHANNEL_TILE})
192 .input_offset(${next_prime(CHANNEL_TILE+1)})
193 .zero_index(zero_index)
194 .Test(${", ".join(TEST_ARGS)});
195 }
196 }
197 }
198
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800199 $if CHANNEL_TILE > 1:
200 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile) {
201 $if ISA_CHECK:
202 ${ISA_CHECK};
203 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
204 AvgPoolMicrokernelTester()
205 .pooling_elements(${PRIMARY_TILE})
206 .pooling_tile(${PRIMARY_TILE})
207 .channels(channels)
208 .Test(${", ".join(TEST_ARGS)});
209 }
210 }
211
212 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_input_offset) {
213 $if ISA_CHECK:
214 ${ISA_CHECK};
215 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
216 AvgPoolMicrokernelTester()
217 .pooling_elements(${PRIMARY_TILE})
218 .pooling_tile(${PRIMARY_TILE})
219 .channels(channels)
220 .input_offset(${next_prime(CHANNEL_TILE*8)})
221 .Test(${", ".join(TEST_ARGS)});
222 }
223 }
224
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800225 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_zero) {
226 $if ISA_CHECK:
227 ${ISA_CHECK};
228 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
229 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE}; zero_index++) {
230 AvgPoolMicrokernelTester()
231 .pooling_elements(${PRIMARY_TILE})
232 .pooling_tile(${PRIMARY_TILE})
233 .channels(channels)
234 .input_offset(${next_prime(CHANNEL_TILE*8)})
235 .zero_index(zero_index)
236 .Test(${", ".join(TEST_ARGS)});
237 }
238 }
239 }
240
Marat Dukhan08b7a972020-07-14 18:17:29 -0700241 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800242 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_input_scale) {
243 $if ISA_CHECK:
244 ${ISA_CHECK};
245 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
246 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
247 AvgPoolMicrokernelTester()
248 .pooling_elements(${PRIMARY_TILE})
249 .pooling_tile(${PRIMARY_TILE})
250 .channels(channels)
251 .input_scale(scale)
252 .Test(${", ".join(TEST_ARGS)});
253 }
254 }
255 }
256
257 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_input_zero_point) {
258 $if ISA_CHECK:
259 ${ISA_CHECK};
260 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
261 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
262 AvgPoolMicrokernelTester()
263 .pooling_elements(${PRIMARY_TILE})
264 .pooling_tile(${PRIMARY_TILE})
265 .channels(channels)
266 .input_zero_point(zero_point)
267 .Test(${", ".join(TEST_ARGS)});
268 }
269 }
270 }
271
272 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_output_scale) {
273 $if ISA_CHECK:
274 ${ISA_CHECK};
275 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
276 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
277 AvgPoolMicrokernelTester()
278 .pooling_elements(${PRIMARY_TILE})
279 .pooling_tile(${PRIMARY_TILE})
280 .channels(channels)
281 .output_scale(scale)
282 .Test(${", ".join(TEST_ARGS)});
283 }
284 }
285 }
286
287 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_output_zero_point) {
288 $if ISA_CHECK:
289 ${ISA_CHECK};
290 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
291 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
292 AvgPoolMicrokernelTester()
293 .pooling_elements(${PRIMARY_TILE})
294 .pooling_tile(${PRIMARY_TILE})
295 .channels(channels)
296 .output_zero_point(zero_point)
297 .Test(${", ".join(TEST_ARGS)});
298 }
299 }
300 }
301
302 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_qmin) {
303 $if ISA_CHECK:
304 ${ISA_CHECK};
305 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
306 AvgPoolMicrokernelTester()
307 .pooling_elements(${PRIMARY_TILE})
308 .pooling_tile(${PRIMARY_TILE})
309 .channels(channels)
310 .qmin(128)
311 .Test(${", ".join(TEST_ARGS)});
312 }
313 }
314
315 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_fulltile_with_qmax) {
316 $if ISA_CHECK:
317 ${ISA_CHECK};
318 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
319 AvgPoolMicrokernelTester()
320 .pooling_elements(${PRIMARY_TILE})
321 .pooling_tile(${PRIMARY_TILE})
322 .channels(channels)
323 .qmax(128)
324 .Test(${", ".join(TEST_ARGS)});
325 }
326 }
327
328 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_subtile) {
329 $if ISA_CHECK:
330 ${ISA_CHECK};
331 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
332 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
333 AvgPoolMicrokernelTester()
334 .pooling_elements(pooling_elements)
335 .pooling_tile(${PRIMARY_TILE})
336 .channels(channels)
337 .Test(${", ".join(TEST_ARGS)});
338 }
339 }
340 }
341
342 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_subtile_with_input_offset) {
343 $if ISA_CHECK:
344 ${ISA_CHECK};
345 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
346 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
347 AvgPoolMicrokernelTester()
348 .pooling_elements(pooling_elements)
349 .pooling_tile(${PRIMARY_TILE})
350 .channels(channels)
351 .input_offset(${next_prime(CHANNEL_TILE*8)})
352 .Test(${", ".join(TEST_ARGS)});
353 }
354 }
355 }
356
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800357 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_unipass_subtile_with_zero) {
358 $if ISA_CHECK:
359 ${ISA_CHECK};
360 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
361 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
362 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
363 AvgPoolMicrokernelTester()
364 .pooling_elements(pooling_elements)
365 .pooling_tile(${PRIMARY_TILE})
366 .channels(channels)
367 .input_offset(${next_prime(CHANNEL_TILE*8)})
368 .zero_index(zero_index)
369 .Test(${", ".join(TEST_ARGS)});
370 }
371 }
372 }
373 }
374
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800375 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile) {
376 $if ISA_CHECK:
377 ${ISA_CHECK};
378 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
379 AvgPoolMicrokernelTester()
380 .pooling_elements(${PRIMARY_TILE})
381 .pooling_tile(${PRIMARY_TILE})
382 .channels(channels)
383 .Test(${", ".join(TEST_ARGS)});
384 }
385 }
386
387 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_input_offset) {
388 $if ISA_CHECK:
389 ${ISA_CHECK};
390 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
391 AvgPoolMicrokernelTester()
392 .pooling_elements(${PRIMARY_TILE})
393 .pooling_tile(${PRIMARY_TILE})
394 .channels(channels)
395 .input_offset(${next_prime(CHANNEL_TILE)})
396 .Test(${", ".join(TEST_ARGS)});
397 }
398 }
399
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800400 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_zero) {
401 $if ISA_CHECK:
402 ${ISA_CHECK};
403 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
404 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE}; zero_index++) {
405 AvgPoolMicrokernelTester()
406 .pooling_elements(${PRIMARY_TILE})
407 .pooling_tile(${PRIMARY_TILE})
408 .channels(channels)
409 .input_offset(${next_prime(CHANNEL_TILE)})
410 .zero_index(zero_index)
411 .Test(${", ".join(TEST_ARGS)});
412 }
413 }
414 }
415
Marat Dukhan08b7a972020-07-14 18:17:29 -0700416 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800417 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_input_scale) {
418 $if ISA_CHECK:
419 ${ISA_CHECK};
420 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
421 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
422 AvgPoolMicrokernelTester()
423 .pooling_elements(${PRIMARY_TILE})
424 .pooling_tile(${PRIMARY_TILE})
425 .channels(channels)
426 .input_scale(scale)
427 .Test(${", ".join(TEST_ARGS)});
428 }
429 }
430 }
431
432 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_input_zero_point) {
433 $if ISA_CHECK:
434 ${ISA_CHECK};
435 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
436 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
437 AvgPoolMicrokernelTester()
438 .pooling_elements(${PRIMARY_TILE})
439 .pooling_tile(${PRIMARY_TILE})
440 .channels(channels)
441 .input_zero_point(zero_point)
442 .Test(${", ".join(TEST_ARGS)});
443 }
444 }
445 }
446
447 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_output_scale) {
448 $if ISA_CHECK:
449 ${ISA_CHECK};
450 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
451 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
452 AvgPoolMicrokernelTester()
453 .pooling_elements(${PRIMARY_TILE})
454 .pooling_tile(${PRIMARY_TILE})
455 .channels(channels)
456 .output_scale(scale)
457 .Test(${", ".join(TEST_ARGS)});
458 }
459 }
460 }
461
462 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_output_zero_point) {
463 $if ISA_CHECK:
464 ${ISA_CHECK};
465 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
466 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
467 AvgPoolMicrokernelTester()
468 .pooling_elements(${PRIMARY_TILE})
469 .pooling_tile(${PRIMARY_TILE})
470 .channels(channels)
471 .output_zero_point(zero_point)
472 .Test(${", ".join(TEST_ARGS)});
473 }
474 }
475 }
476
477 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_qmin) {
478 $if ISA_CHECK:
479 ${ISA_CHECK};
480 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
481 AvgPoolMicrokernelTester()
482 .pooling_elements(${PRIMARY_TILE})
483 .pooling_tile(${PRIMARY_TILE})
484 .channels(channels)
485 .qmin(128)
486 .Test(${", ".join(TEST_ARGS)});
487 }
488 }
489
490 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_fulltile_with_qmax) {
491 $if ISA_CHECK:
492 ${ISA_CHECK};
493 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
494 AvgPoolMicrokernelTester()
495 .pooling_elements(${PRIMARY_TILE})
496 .pooling_tile(${PRIMARY_TILE})
497 .channels(channels)
498 .qmax(128)
499 .Test(${", ".join(TEST_ARGS)});
500 }
501 }
502
503 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_subtile) {
504 $if ISA_CHECK:
505 ${ISA_CHECK};
506 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
507 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
508 AvgPoolMicrokernelTester()
509 .pooling_elements(pooling_elements)
510 .pooling_tile(${PRIMARY_TILE})
511 .channels(channels)
512 .Test(${", ".join(TEST_ARGS)});
513 }
514 }
515 }
516
517 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_subtile_with_input_offset) {
518 $if ISA_CHECK:
519 ${ISA_CHECK};
520 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
521 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
522 AvgPoolMicrokernelTester()
523 .pooling_elements(pooling_elements)
524 .pooling_tile(${PRIMARY_TILE})
525 .channels(channels)
526 .input_offset(${next_prime(CHANNEL_TILE)})
527 .Test(${", ".join(TEST_ARGS)});
528 }
529 }
530 }
531
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800532 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_unipass_subtile_with_zero) {
533 $if ISA_CHECK:
534 ${ISA_CHECK};
535 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
536 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
537 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
538 AvgPoolMicrokernelTester()
539 .pooling_elements(pooling_elements)
540 .pooling_tile(${PRIMARY_TILE})
541 .channels(channels)
542 .input_offset(${next_prime(CHANNEL_TILE)})
543 .zero_index(zero_index)
544 .Test(${", ".join(TEST_ARGS)});
545 }
546 }
547 }
548 }
549
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800550 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile) {
551 $if ISA_CHECK:
552 ${ISA_CHECK};
553 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
554 AvgPoolMicrokernelTester()
555 .pooling_elements(${PRIMARY_TILE})
556 .pooling_tile(${PRIMARY_TILE})
557 .channels(channels)
558 .Test(${", ".join(TEST_ARGS)});
559 }
560 }
561
562 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_input_offset) {
563 $if ISA_CHECK:
564 ${ISA_CHECK};
565 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
566 AvgPoolMicrokernelTester()
567 .pooling_elements(${PRIMARY_TILE})
568 .pooling_tile(${PRIMARY_TILE})
569 .channels(channels)
570 .input_offset(${next_prime(CHANNEL_TILE*2)})
571 .Test(${", ".join(TEST_ARGS)});
572 }
573 }
574
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800575 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_zero) {
576 $if ISA_CHECK:
577 ${ISA_CHECK};
578 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
579 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE}; zero_index++) {
580 AvgPoolMicrokernelTester()
581 .pooling_elements(${PRIMARY_TILE})
582 .pooling_tile(${PRIMARY_TILE})
583 .channels(channels)
584 .input_offset(${next_prime(CHANNEL_TILE*2)})
585 .zero_index(zero_index)
586 .Test(${", ".join(TEST_ARGS)});
587 }
588 }
589 }
590
Marat Dukhan08b7a972020-07-14 18:17:29 -0700591 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800592 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_input_scale) {
593 $if ISA_CHECK:
594 ${ISA_CHECK};
595 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
596 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
597 AvgPoolMicrokernelTester()
598 .pooling_elements(${PRIMARY_TILE})
599 .pooling_tile(${PRIMARY_TILE})
600 .channels(channels)
601 .input_scale(scale)
602 .Test(${", ".join(TEST_ARGS)});
603 }
604 }
605 }
606
607 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_input_zero_point) {
608 $if ISA_CHECK:
609 ${ISA_CHECK};
610 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
611 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
612 AvgPoolMicrokernelTester()
613 .pooling_elements(${PRIMARY_TILE})
614 .pooling_tile(${PRIMARY_TILE})
615 .channels(channels)
616 .input_zero_point(zero_point)
617 .Test(${", ".join(TEST_ARGS)});
618 }
619 }
620 }
621
622 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_output_scale) {
623 $if ISA_CHECK:
624 ${ISA_CHECK};
625 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
626 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
627 AvgPoolMicrokernelTester()
628 .pooling_elements(${PRIMARY_TILE})
629 .pooling_tile(${PRIMARY_TILE})
630 .channels(channels)
631 .output_scale(scale)
632 .Test(${", ".join(TEST_ARGS)});
633 }
634 }
635 }
636
637 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_output_zero_point) {
638 $if ISA_CHECK:
639 ${ISA_CHECK};
640 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
641 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
642 AvgPoolMicrokernelTester()
643 .pooling_elements(${PRIMARY_TILE})
644 .pooling_tile(${PRIMARY_TILE})
645 .channels(channels)
646 .output_zero_point(zero_point)
647 .Test(${", ".join(TEST_ARGS)});
648 }
649 }
650 }
651
652 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_qmin) {
653 $if ISA_CHECK:
654 ${ISA_CHECK};
655 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
656 AvgPoolMicrokernelTester()
657 .pooling_elements(${PRIMARY_TILE})
658 .pooling_tile(${PRIMARY_TILE})
659 .channels(channels)
660 .qmin(128)
661 .Test(${", ".join(TEST_ARGS)});
662 }
663 }
664
665 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_fulltile_with_qmax) {
666 $if ISA_CHECK:
667 ${ISA_CHECK};
668 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
669 AvgPoolMicrokernelTester()
670 .pooling_elements(${PRIMARY_TILE})
671 .pooling_tile(${PRIMARY_TILE})
672 .channels(channels)
673 .qmax(128)
674 .Test(${", ".join(TEST_ARGS)});
675 }
676 }
677
678 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_subtile) {
679 $if ISA_CHECK:
680 ${ISA_CHECK};
681 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
682 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
683 AvgPoolMicrokernelTester()
684 .pooling_elements(pooling_elements)
685 .pooling_tile(${PRIMARY_TILE})
686 .channels(channels)
687 .Test(${", ".join(TEST_ARGS)});
688 }
689 }
690 }
691
692 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_subtile_with_input_offset) {
693 $if ISA_CHECK:
694 ${ISA_CHECK};
695 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
696 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
697 AvgPoolMicrokernelTester()
698 .pooling_elements(pooling_elements)
699 .pooling_tile(${PRIMARY_TILE})
700 .channels(channels)
701 .input_offset(${next_prime(CHANNEL_TILE*2)})
702 .Test(${", ".join(TEST_ARGS)});
703 }
704 }
705 }
706
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800707 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_unipass_subtile_with_zero) {
708 $if ISA_CHECK:
709 ${ISA_CHECK};
710 for (size_t pooling_elements = 2; pooling_elements < ${PRIMARY_TILE}; pooling_elements++) {
711 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
712 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
713 AvgPoolMicrokernelTester()
714 .pooling_elements(pooling_elements)
715 .pooling_tile(${PRIMARY_TILE})
716 .channels(channels)
717 .input_offset(${next_prime(CHANNEL_TILE*2)})
718 .zero_index(zero_index)
719 .Test(${", ".join(TEST_ARGS)});
720 }
721 }
722 }
723 }
724
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800725 TEST(${TEST_NAME}, few_output_pixels) {
726 $if ISA_CHECK:
727 ${ISA_CHECK};
728 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
729 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
730 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
731 AvgPoolMicrokernelTester()
732 .output_pixels(output_pixels)
733 .pooling_elements(pooling_elements)
734 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
735 .channels(channels)
736 .Test(${", ".join(TEST_ARGS)});
737 }
738 }
739 }
740 }
741
742 TEST(${TEST_NAME}, few_output_pixels_with_input_offset) {
743 $if ISA_CHECK:
744 ${ISA_CHECK};
745 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
746 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
747 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
748 AvgPoolMicrokernelTester()
749 .output_pixels(output_pixels)
750 .pooling_elements(pooling_elements)
751 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
752 .channels(channels)
753 .input_offset(${next_prime(CHANNEL_TILE*5+1)})
754 .Test(${", ".join(TEST_ARGS)});
755 }
756 }
757 }
758 }
759
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800760 TEST(${TEST_NAME}, few_output_pixels_with_zero) {
761 $if ISA_CHECK:
762 ${ISA_CHECK};
763 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
764 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
765 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
766 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
767 AvgPoolMicrokernelTester()
768 .output_pixels(output_pixels)
769 .pooling_elements(pooling_elements)
770 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
771 .channels(channels)
772 .input_offset(${next_prime(CHANNEL_TILE*5+1)})
773 .zero_index(zero_index)
774 .Test(${", ".join(TEST_ARGS)});
775 }
776 }
777 }
778 }
779 }
780
Marat Dukhan08b7a972020-07-14 18:17:29 -0700781 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800782 TEST(${TEST_NAME}, few_output_pixels_with_input_scale) {
783 $if ISA_CHECK:
784 ${ISA_CHECK};
785 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
786 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
787 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
788 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
789 AvgPoolMicrokernelTester()
790 .output_pixels(output_pixels)
791 .pooling_elements(pooling_elements)
792 .pooling_tile(${PRIMARY_TILE})
793 .channels(channels)
794 .input_scale(scale)
795 .Test(${", ".join(TEST_ARGS)});
796 }
797 }
798 }
799 }
800 }
801
802 TEST(${TEST_NAME}, few_output_pixels_with_input_zero_point) {
803 $if ISA_CHECK:
804 ${ISA_CHECK};
805 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
806 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
807 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
808 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
809 AvgPoolMicrokernelTester()
810 .output_pixels(output_pixels)
811 .pooling_elements(pooling_elements)
812 .pooling_tile(${PRIMARY_TILE})
813 .channels(channels)
814 .input_zero_point(zero_point)
815 .Test(${", ".join(TEST_ARGS)});
816 }
817 }
818 }
819 }
820 }
821
822 TEST(${TEST_NAME}, few_output_pixels_with_output_scale) {
823 $if ISA_CHECK:
824 ${ISA_CHECK};
825 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
826 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
827 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
828 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
829 AvgPoolMicrokernelTester()
830 .output_pixels(output_pixels)
831 .pooling_elements(pooling_elements)
832 .pooling_tile(${PRIMARY_TILE})
833 .channels(channels)
834 .output_scale(scale)
835 .Test(${", ".join(TEST_ARGS)});
836 }
837 }
838 }
839 }
840 }
841
842 TEST(${TEST_NAME}, few_output_pixels_with_output_zero_point) {
843 $if ISA_CHECK:
844 ${ISA_CHECK};
845 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
846 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
847 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
848 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
849 AvgPoolMicrokernelTester()
850 .output_pixels(output_pixels)
851 .pooling_elements(pooling_elements)
852 .pooling_tile(${PRIMARY_TILE})
853 .channels(channels)
854 .output_zero_point(zero_point)
855 .Test(${", ".join(TEST_ARGS)});
856 }
857 }
858 }
859 }
860 }
861
862 TEST(${TEST_NAME}, few_output_pixels_with_qmin) {
863 $if ISA_CHECK:
864 ${ISA_CHECK};
865 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
866 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
867 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
868 AvgPoolMicrokernelTester()
869 .output_pixels(output_pixels)
870 .pooling_elements(pooling_elements)
871 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
872 .channels(channels)
873 .qmin(128)
874 .Test(${", ".join(TEST_ARGS)});
875 }
876 }
877 }
878 }
879
880 TEST(${TEST_NAME}, few_output_pixels_with_qmax) {
881 $if ISA_CHECK:
882 ${ISA_CHECK};
883 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
884 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
885 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
886 AvgPoolMicrokernelTester()
887 .output_pixels(output_pixels)
888 .pooling_elements(pooling_elements)
889 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
890 .channels(channels)
891 .qmax(128)
892 .Test(${", ".join(TEST_ARGS)});
893 }
894 }
895 }
896 }
897
898 TEST(${TEST_NAME}, few_output_pixels_with_output_stride) {
899 $if ISA_CHECK:
900 ${ISA_CHECK};
901 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
902 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
903 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
904 AvgPoolMicrokernelTester()
905 .output_pixels(output_pixels)
906 .pooling_elements(pooling_elements)
907 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
908 .channels(channels)
909 .output_stride(${next_prime(CHANNEL_TILE*5+1)})
910 .Test(${", ".join(TEST_ARGS)});
911 }
912 }
913 }
914 }
915
916 TEST(${TEST_NAME}, few_output_pixels_with_step) {
917 $if ISA_CHECK:
918 ${ISA_CHECK};
919 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
920 for (size_t pooling_elements : std::vector<size_t>{{2, ${PRIMARY_TILE-1}, ${PRIMARY_TILE}}}) {
921 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
922 for (size_t step = 2; step <= pooling_elements; step++) {
923 AvgPoolMicrokernelTester()
924 .output_pixels(output_pixels)
925 .pooling_elements(pooling_elements)
926 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
927 .step(step)
928 .channels(channels)
929 .output_stride(${next_prime(CHANNEL_TILE*5+1)})
930 .Test(${", ".join(TEST_ARGS)});
931 }
932 }
933 }
934 }
935 }
936$else:
937 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile) {
938 $if ISA_CHECK:
939 ${ISA_CHECK};
940 AvgPoolMicrokernelTester()
941 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
942 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
943 .channels(${CHANNEL_TILE})
944 .Test(${", ".join(TEST_ARGS)});
945 }
946
947 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_input_offset) {
948 $if ISA_CHECK:
949 ${ISA_CHECK};
950 AvgPoolMicrokernelTester()
951 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
952 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
953 .channels(${CHANNEL_TILE})
954 .input_offset(${next_prime(CHANNEL_TILE+1)})
955 .Test(${", ".join(TEST_ARGS)});
956 }
957
Marat Dukhanee1f63e2020-02-27 15:43:52 -0800958 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_zero) {
959 $if ISA_CHECK:
960 ${ISA_CHECK};
961 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE+INCREMENTAL_TILE}; zero_index++) {
962 AvgPoolMicrokernelTester()
963 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
964 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
965 .channels(${CHANNEL_TILE})
966 .input_offset(${next_prime(CHANNEL_TILE+1)})
967 .zero_index(zero_index)
968 .Test(${", ".join(TEST_ARGS)});
969 }
970 }
971
Marat Dukhan08b7a972020-07-14 18:17:29 -0700972 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -0800973 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_input_scale) {
974 $if ISA_CHECK:
975 ${ISA_CHECK};
976 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
977 AvgPoolMicrokernelTester()
978 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
979 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
980 .channels(${CHANNEL_TILE})
981 .input_scale(scale)
982 .Test(${", ".join(TEST_ARGS)});
983 }
984 }
985
986 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_input_zero_point) {
987 $if ISA_CHECK:
988 ${ISA_CHECK};
989 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
990 AvgPoolMicrokernelTester()
991 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
992 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
993 .channels(${CHANNEL_TILE})
994 .input_zero_point(zero_point)
995 .Test(${", ".join(TEST_ARGS)});
996 }
997 }
998
999 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_output_scale) {
1000 $if ISA_CHECK:
1001 ${ISA_CHECK};
1002 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1003 AvgPoolMicrokernelTester()
1004 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1005 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1006 .channels(${CHANNEL_TILE})
1007 .output_scale(scale)
1008 .Test(${", ".join(TEST_ARGS)});
1009 }
1010 }
1011
1012 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_output_zero_point) {
1013 $if ISA_CHECK:
1014 ${ISA_CHECK};
1015 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1016 AvgPoolMicrokernelTester()
1017 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1018 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1019 .channels(${CHANNEL_TILE})
1020 .output_zero_point(zero_point)
1021 .Test(${", ".join(TEST_ARGS)});
1022 }
1023 }
1024
1025 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_qmin) {
1026 $if ISA_CHECK:
1027 ${ISA_CHECK};
1028 AvgPoolMicrokernelTester()
1029 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1030 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1031 .channels(${CHANNEL_TILE})
1032 .qmin(128)
1033 .Test(${", ".join(TEST_ARGS)});
1034 }
1035
1036 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_fulltile_with_qmax) {
1037 $if ISA_CHECK:
1038 ${ISA_CHECK};
1039 AvgPoolMicrokernelTester()
1040 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1041 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1042 .channels(${CHANNEL_TILE})
1043 .qmax(128)
1044 .Test(${", ".join(TEST_ARGS)});
1045 }
1046
1047 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_subtile) {
1048 $if ISA_CHECK:
1049 ${ISA_CHECK};
1050 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1051 AvgPoolMicrokernelTester()
1052 .pooling_elements(pooling_elements)
1053 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1054 .channels(${CHANNEL_TILE})
1055 .Test(${", ".join(TEST_ARGS)});
1056 }
1057 }
1058
1059 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_subtile_with_input_offset) {
1060 $if ISA_CHECK:
1061 ${ISA_CHECK};
1062 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1063 AvgPoolMicrokernelTester()
1064 .pooling_elements(pooling_elements)
1065 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1066 .channels(${CHANNEL_TILE})
1067 .input_offset(${next_prime(CHANNEL_TILE+1)})
1068 .Test(${", ".join(TEST_ARGS)});
1069 }
1070 }
1071
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001072 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_twopass_subtile_with_zero) {
1073 $if ISA_CHECK:
1074 ${ISA_CHECK};
1075 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1076 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1077 AvgPoolMicrokernelTester()
1078 .pooling_elements(pooling_elements)
1079 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1080 .channels(${CHANNEL_TILE})
1081 .input_offset(${next_prime(CHANNEL_TILE+1)})
1082 .zero_index(zero_index)
1083 .Test(${", ".join(TEST_ARGS)});
1084 }
1085 }
1086 }
1087
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001088 $if CHANNEL_TILE > 1:
1089 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile) {
1090 $if ISA_CHECK:
1091 ${ISA_CHECK};
1092 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1093 AvgPoolMicrokernelTester()
1094 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1095 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1096 .channels(channels)
1097 .Test(${", ".join(TEST_ARGS)});
1098 }
1099 }
1100
1101 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_input_offset) {
1102 $if ISA_CHECK:
1103 ${ISA_CHECK};
1104 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1105 AvgPoolMicrokernelTester()
1106 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1107 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1108 .channels(channels)
1109 .input_offset(${next_prime(CHANNEL_TILE*5)})
1110 .Test(${", ".join(TEST_ARGS)});
1111 }
1112 }
1113
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001114 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_zero) {
1115 $if ISA_CHECK:
1116 ${ISA_CHECK};
1117 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1118 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE+INCREMENTAL_TILE}; zero_index++) {
1119 AvgPoolMicrokernelTester()
1120 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1121 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1122 .channels(channels)
1123 .input_offset(${next_prime(CHANNEL_TILE*5)})
1124 .zero_index(zero_index)
1125 .Test(${", ".join(TEST_ARGS)});
1126 }
1127 }
1128 }
1129
Marat Dukhan08b7a972020-07-14 18:17:29 -07001130 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001131 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_input_scale) {
1132 $if ISA_CHECK:
1133 ${ISA_CHECK};
1134 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1135 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1136 AvgPoolMicrokernelTester()
1137 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1138 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1139 .channels(channels)
1140 .input_scale(scale)
1141 .Test(${", ".join(TEST_ARGS)});
1142 }
1143 }
1144 }
1145
1146 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_input_zero_point) {
1147 $if ISA_CHECK:
1148 ${ISA_CHECK};
1149 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1150 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1151 AvgPoolMicrokernelTester()
1152 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1153 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1154 .channels(channels)
1155 .input_zero_point(zero_point)
1156 .Test(${", ".join(TEST_ARGS)});
1157 }
1158 }
1159 }
1160
1161 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_output_scale) {
1162 $if ISA_CHECK:
1163 ${ISA_CHECK};
1164 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1165 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1166 AvgPoolMicrokernelTester()
1167 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1168 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1169 .channels(channels)
1170 .output_scale(scale)
1171 .Test(${", ".join(TEST_ARGS)});
1172 }
1173 }
1174 }
1175
1176 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_output_zero_point) {
1177 $if ISA_CHECK:
1178 ${ISA_CHECK};
1179 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1180 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1181 AvgPoolMicrokernelTester()
1182 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1183 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1184 .channels(channels)
1185 .output_zero_point(zero_point)
1186 .Test(${", ".join(TEST_ARGS)});
1187 }
1188 }
1189 }
1190
1191 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_qmin) {
1192 $if ISA_CHECK:
1193 ${ISA_CHECK};
1194 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1195 AvgPoolMicrokernelTester()
1196 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1197 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1198 .channels(channels)
1199 .qmin(128)
1200 .Test(${", ".join(TEST_ARGS)});
1201 }
1202 }
1203
1204 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_fulltile_with_qmax) {
1205 $if ISA_CHECK:
1206 ${ISA_CHECK};
1207 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1208 AvgPoolMicrokernelTester()
1209 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1210 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1211 .channels(channels)
1212 .qmax(128)
1213 .Test(${", ".join(TEST_ARGS)});
1214 }
1215 }
1216
1217 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_subtile) {
1218 $if ISA_CHECK:
1219 ${ISA_CHECK};
1220 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1221 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1222 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001223 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001224 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1225 .channels(channels)
1226 .Test(${", ".join(TEST_ARGS)});
1227 }
1228 }
1229 }
1230
1231 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_subtile_with_input_offset) {
1232 $if ISA_CHECK:
1233 ${ISA_CHECK};
1234 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1235 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1236 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001237 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001238 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1239 .channels(channels)
1240 .input_offset(${next_prime(CHANNEL_TILE*8)})
1241 .Test(${", ".join(TEST_ARGS)});
1242 }
1243 }
1244 }
1245
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001246 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_twopass_subtile_with_zero) {
1247 $if ISA_CHECK:
1248 ${ISA_CHECK};
1249 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1250 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1251 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1252 AvgPoolMicrokernelTester()
1253 .pooling_elements(pooling_elements)
1254 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1255 .channels(channels)
1256 .input_offset(${next_prime(CHANNEL_TILE*8)})
1257 .zero_index(zero_index)
1258 .Test(${", ".join(TEST_ARGS)});
1259 }
1260 }
1261 }
1262 }
1263
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001264 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile) {
1265 $if ISA_CHECK:
1266 ${ISA_CHECK};
1267 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1268 AvgPoolMicrokernelTester()
1269 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1270 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1271 .channels(channels)
1272 .Test(${", ".join(TEST_ARGS)});
1273 }
1274 }
1275
1276 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_input_offset) {
1277 $if ISA_CHECK:
1278 ${ISA_CHECK};
1279 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1280 AvgPoolMicrokernelTester()
1281 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1282 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1283 .channels(channels)
1284 .input_offset(${next_prime(CHANNEL_TILE)})
1285 .Test(${", ".join(TEST_ARGS)});
1286 }
1287 }
1288
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001289 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_zero_index) {
1290 $if ISA_CHECK:
1291 ${ISA_CHECK};
1292 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1293 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE+INCREMENTAL_TILE}; zero_index++) {
1294 AvgPoolMicrokernelTester()
1295 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1296 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1297 .channels(channels)
1298 .input_offset(${next_prime(CHANNEL_TILE)})
1299 .zero_index(zero_index)
1300 .Test(${", ".join(TEST_ARGS)});
1301 }
1302 }
1303 }
1304
Marat Dukhan08b7a972020-07-14 18:17:29 -07001305 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001306 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_input_scale) {
1307 $if ISA_CHECK:
1308 ${ISA_CHECK};
1309 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1310 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1311 AvgPoolMicrokernelTester()
1312 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1313 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1314 .channels(channels)
1315 .input_scale(scale)
1316 .Test(${", ".join(TEST_ARGS)});
1317 }
1318 }
1319 }
1320
1321 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_input_zero_point) {
1322 $if ISA_CHECK:
1323 ${ISA_CHECK};
1324 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1325 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1326 AvgPoolMicrokernelTester()
1327 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1328 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1329 .channels(channels)
1330 .input_zero_point(zero_point)
1331 .Test(${", ".join(TEST_ARGS)});
1332 }
1333 }
1334 }
1335
1336 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_output_scale) {
1337 $if ISA_CHECK:
1338 ${ISA_CHECK};
1339 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1340 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1341 AvgPoolMicrokernelTester()
1342 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1343 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1344 .channels(channels)
1345 .output_scale(scale)
1346 .Test(${", ".join(TEST_ARGS)});
1347 }
1348 }
1349 }
1350
1351 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_output_zero_point) {
1352 $if ISA_CHECK:
1353 ${ISA_CHECK};
1354 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1355 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1356 AvgPoolMicrokernelTester()
1357 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1358 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1359 .channels(channels)
1360 .output_zero_point(zero_point)
1361 .Test(${", ".join(TEST_ARGS)});
1362 }
1363 }
1364 }
1365
1366 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_qmin) {
1367 $if ISA_CHECK:
1368 ${ISA_CHECK};
1369 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1370 AvgPoolMicrokernelTester()
1371 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1372 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1373 .channels(channels)
1374 .qmin(128)
1375 .Test(${", ".join(TEST_ARGS)});
1376 }
1377 }
1378
1379 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_fulltile_with_qmax) {
1380 $if ISA_CHECK:
1381 ${ISA_CHECK};
1382 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1383 AvgPoolMicrokernelTester()
1384 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1385 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1386 .channels(channels)
1387 .qmax(128)
1388 .Test(${", ".join(TEST_ARGS)});
1389 }
1390 }
1391
1392 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_subtile) {
1393 $if ISA_CHECK:
1394 ${ISA_CHECK};
1395 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1396 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1397 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001398 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001399 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1400 .channels(channels)
1401 .Test(${", ".join(TEST_ARGS)});
1402 }
1403 }
1404 }
1405
1406 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_subtile_with_input_offset) {
1407 $if ISA_CHECK:
1408 ${ISA_CHECK};
1409 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1410 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1411 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001412 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001413 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1414 .channels(channels)
1415 .input_offset(${next_prime(CHANNEL_TILE)})
1416 .Test(${", ".join(TEST_ARGS)});
1417 }
1418 }
1419 }
1420
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001421 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_twopass_subtile_with_zero) {
1422 $if ISA_CHECK:
1423 ${ISA_CHECK};
1424 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1425 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1426 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1427 AvgPoolMicrokernelTester()
1428 .pooling_elements(pooling_elements)
1429 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1430 .channels(channels)
1431 .input_offset(${next_prime(CHANNEL_TILE)})
1432 .zero_index(zero_index)
1433 .Test(${", ".join(TEST_ARGS)});
1434 }
1435 }
1436 }
1437 }
1438
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001439 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile) {
1440 $if ISA_CHECK:
1441 ${ISA_CHECK};
1442 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1443 AvgPoolMicrokernelTester()
1444 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1445 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1446 .channels(channels)
1447 .Test(${", ".join(TEST_ARGS)});
1448 }
1449 }
1450
1451 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_input_offset) {
1452 $if ISA_CHECK:
1453 ${ISA_CHECK};
1454 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1455 AvgPoolMicrokernelTester()
1456 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1457 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1458 .channels(channels)
1459 .input_offset(${next_prime(CHANNEL_TILE*2)})
1460 .Test(${", ".join(TEST_ARGS)});
1461 }
1462 }
1463
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001464 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_zero) {
1465 $if ISA_CHECK:
1466 ${ISA_CHECK};
1467 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1468 for (size_t zero_index = 0; zero_index < ${PRIMARY_TILE+INCREMENTAL_TILE}; zero_index++) {
1469 AvgPoolMicrokernelTester()
1470 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1471 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1472 .channels(channels)
1473 .input_offset(${next_prime(CHANNEL_TILE*2)})
1474 .zero_index(zero_index)
1475 .Test(${", ".join(TEST_ARGS)});
1476 }
1477 }
1478 }
1479
Marat Dukhan08b7a972020-07-14 18:17:29 -07001480 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001481 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_input_scale) {
1482 $if ISA_CHECK:
1483 ${ISA_CHECK};
1484 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1485 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1486 AvgPoolMicrokernelTester()
1487 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1488 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1489 .channels(channels)
1490 .input_scale(scale)
1491 .Test(${", ".join(TEST_ARGS)});
1492 }
1493 }
1494 }
1495
1496 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_input_zero_point) {
1497 $if ISA_CHECK:
1498 ${ISA_CHECK};
1499 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1500 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1501 AvgPoolMicrokernelTester()
1502 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1503 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1504 .channels(channels)
1505 .input_zero_point(zero_point)
1506 .Test(${", ".join(TEST_ARGS)});
1507 }
1508 }
1509 }
1510
1511 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_output_scale) {
1512 $if ISA_CHECK:
1513 ${ISA_CHECK};
1514 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1515 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1516 AvgPoolMicrokernelTester()
1517 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1518 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1519 .channels(channels)
1520 .output_scale(scale)
1521 .Test(${", ".join(TEST_ARGS)});
1522 }
1523 }
1524 }
1525
1526 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_output_zero_point) {
1527 $if ISA_CHECK:
1528 ${ISA_CHECK};
1529 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1530 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1531 AvgPoolMicrokernelTester()
1532 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1533 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1534 .channels(channels)
1535 .output_zero_point(zero_point)
1536 .Test(${", ".join(TEST_ARGS)});
1537 }
1538 }
1539 }
1540
1541 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_qmin) {
1542 $if ISA_CHECK:
1543 ${ISA_CHECK};
1544 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1545 AvgPoolMicrokernelTester()
1546 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1547 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1548 .channels(channels)
1549 .qmin(128)
1550 .Test(${", ".join(TEST_ARGS)});
1551 }
1552 }
1553
1554 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_fulltile_with_qmax) {
1555 $if ISA_CHECK:
1556 ${ISA_CHECK};
1557 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1558 AvgPoolMicrokernelTester()
1559 .pooling_elements(${PRIMARY_TILE+INCREMENTAL_TILE})
1560 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1561 .channels(channels)
1562 .qmax(128)
1563 .Test(${", ".join(TEST_ARGS)});
1564 }
1565 }
1566
1567 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_subtile) {
1568 $if ISA_CHECK:
1569 ${ISA_CHECK};
1570 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1571 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1572 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001573 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001574 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1575 .channels(channels)
1576 .Test(${", ".join(TEST_ARGS)});
1577 }
1578 }
1579 }
1580
1581 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_subtile_with_input_offset) {
1582 $if ISA_CHECK:
1583 ${ISA_CHECK};
1584 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1585 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1586 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001587 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001588 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1589 .channels(channels)
1590 .input_offset(${next_prime(CHANNEL_TILE*2)})
1591 .Test(${", ".join(TEST_ARGS)});
1592 }
1593 }
1594 }
1595
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001596 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_twopass_subtile_with_zero) {
1597 $if ISA_CHECK:
1598 ${ISA_CHECK};
1599 for (size_t pooling_elements = ${PRIMARY_TILE+1}; pooling_elements < ${PRIMARY_TILE+INCREMENTAL_TILE}; pooling_elements++) {
1600 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
1601 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1602 AvgPoolMicrokernelTester()
1603 .pooling_elements(pooling_elements)
1604 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1605 .channels(channels)
1606 .input_offset(${next_prime(CHANNEL_TILE*2)})
1607 .zero_index(zero_index)
1608 .Test(${", ".join(TEST_ARGS)});
1609 }
1610 }
1611 }
1612 }
1613
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001614 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass) {
1615 $if ISA_CHECK:
1616 ${ISA_CHECK};
1617 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1618 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001619 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001620 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1621 .channels(${CHANNEL_TILE})
1622 .Test(${", ".join(TEST_ARGS)});
1623 }
1624 }
1625
1626 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_input_offset) {
1627 $if ISA_CHECK:
1628 ${ISA_CHECK};
1629 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1630 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001631 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001632 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1633 .channels(${CHANNEL_TILE})
1634 .input_offset(${next_prime(CHANNEL_TILE+1)})
1635 .Test(${", ".join(TEST_ARGS)});
1636 }
1637 }
1638
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001639 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_zero) {
1640 $if ISA_CHECK:
1641 ${ISA_CHECK};
1642 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1643 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1644 AvgPoolMicrokernelTester()
1645 .pooling_elements(pooling_elements)
1646 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1647 .channels(${CHANNEL_TILE})
1648 .input_offset(${next_prime(CHANNEL_TILE+1)})
1649 .zero_index(zero_index)
1650 .Test(${", ".join(TEST_ARGS)});
1651 }
1652 }
1653 }
1654
Marat Dukhan08b7a972020-07-14 18:17:29 -07001655 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001656 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_input_scale) {
1657 $if ISA_CHECK:
1658 ${ISA_CHECK};
1659 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1660 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1661 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001662 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001663 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1664 .channels(${CHANNEL_TILE})
1665 .input_scale(scale)
1666 .Test(${", ".join(TEST_ARGS)});
1667 }
1668 }
1669 }
1670
1671 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_input_zero_point) {
1672 $if ISA_CHECK:
1673 ${ISA_CHECK};
1674 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1675 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1676 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001677 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001678 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1679 .channels(${CHANNEL_TILE})
1680 .input_zero_point(zero_point)
1681 .Test(${", ".join(TEST_ARGS)});
1682 }
1683 }
1684 }
1685
1686 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_output_scale) {
1687 $if ISA_CHECK:
1688 ${ISA_CHECK};
1689 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1690 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1691 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001692 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001693 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1694 .channels(${CHANNEL_TILE})
1695 .output_scale(scale)
1696 .Test(${", ".join(TEST_ARGS)});
1697 }
1698 }
1699 }
1700
1701 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_output_zero_point) {
1702 $if ISA_CHECK:
1703 ${ISA_CHECK};
1704 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1705 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1706 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001707 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001708 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1709 .channels(${CHANNEL_TILE})
1710 .output_zero_point(zero_point)
1711 .Test(${", ".join(TEST_ARGS)});
1712 }
1713 }
1714 }
1715
1716 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_qmin) {
1717 $if ISA_CHECK:
1718 ${ISA_CHECK};
1719 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1720 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001721 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001722 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1723 .channels(${CHANNEL_TILE})
1724 .qmin(128)
1725 .Test(${", ".join(TEST_ARGS)});
1726 }
1727 }
1728
1729 TEST(${TEST_NAME}, channels_eq_${CHANNEL_TILE}_multipass_with_qmax) {
1730 $if ISA_CHECK:
1731 ${ISA_CHECK};
1732 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1733 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001734 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001735 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1736 .channels(${CHANNEL_TILE})
1737 .qmax(128)
1738 .Test(${", ".join(TEST_ARGS)});
1739 }
1740 }
1741
1742 $if CHANNEL_TILE > 1:
1743 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass) {
1744 $if ISA_CHECK:
1745 ${ISA_CHECK};
1746 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1747 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1748 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001749 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001750 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1751 .channels(channels)
1752 .Test(${", ".join(TEST_ARGS)});
1753 }
1754 }
1755 }
1756
1757 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_input_offset) {
1758 $if ISA_CHECK:
1759 ${ISA_CHECK};
1760 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1761 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1762 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001763 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001764 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1765 .channels(channels)
1766 .input_offset(${next_prime(CHANNEL_TILE*8)})
1767 .Test(${", ".join(TEST_ARGS)});
1768 }
1769 }
1770 }
1771
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001772 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_zero) {
1773 $if ISA_CHECK:
1774 ${ISA_CHECK};
1775 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1776 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1777 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1778 AvgPoolMicrokernelTester()
1779 .pooling_elements(pooling_elements)
1780 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1781 .channels(channels)
1782 .input_offset(${next_prime(CHANNEL_TILE*8)})
1783 .zero_index(zero_index)
1784 .Test(${", ".join(TEST_ARGS)});
1785 }
1786 }
1787 }
1788 }
1789
Marat Dukhan08b7a972020-07-14 18:17:29 -07001790 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001791 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_input_scale) {
1792 $if ISA_CHECK:
1793 ${ISA_CHECK};
1794 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1795 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1796 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1797 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001798 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001799 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1800 .channels(channels)
1801 .input_scale(scale)
1802 .Test(${", ".join(TEST_ARGS)});
1803 }
1804 }
1805 }
1806 }
1807
1808 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_input_zero_point) {
1809 $if ISA_CHECK:
1810 ${ISA_CHECK};
1811 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1812 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1813 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1814 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001815 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001816 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1817 .channels(channels)
1818 .input_zero_point(zero_point)
1819 .Test(${", ".join(TEST_ARGS)});
1820 }
1821 }
1822 }
1823 }
1824
1825 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_output_scale) {
1826 $if ISA_CHECK:
1827 ${ISA_CHECK};
1828 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1829 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1830 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1831 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001832 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001833 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1834 .channels(channels)
1835 .output_scale(scale)
1836 .Test(${", ".join(TEST_ARGS)});
1837 }
1838 }
1839 }
1840 }
1841
1842 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_output_zero_point) {
1843 $if ISA_CHECK:
1844 ${ISA_CHECK};
1845 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1846 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1847 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1848 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001849 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001850 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1851 .channels(channels)
1852 .output_zero_point(zero_point)
1853 .Test(${", ".join(TEST_ARGS)});
1854 }
1855 }
1856 }
1857 }
1858
1859 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_qmin) {
1860 $if ISA_CHECK:
1861 ${ISA_CHECK};
1862 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1863 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1864 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001865 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001866 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1867 .channels(channels)
1868 .qmin(128)
1869 .Test(${", ".join(TEST_ARGS)});
1870 }
1871 }
1872 }
1873
1874 TEST(${TEST_NAME}, channels_div_${CHANNEL_TILE}_multipass_with_qmax) {
1875 $if ISA_CHECK:
1876 ${ISA_CHECK};
1877 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1878 for (size_t channels = ${CHANNEL_TILE*2}; channels < ${CHANNEL_TILE*8}; channels += ${CHANNEL_TILE}) {
1879 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001880 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001881 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1882 .channels(channels)
1883 .qmax(128)
1884 .Test(${", ".join(TEST_ARGS)});
1885 }
1886 }
1887 }
1888
1889 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass) {
1890 $if ISA_CHECK:
1891 ${ISA_CHECK};
1892 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1893 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1894 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001895 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001896 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1897 .channels(channels)
1898 .Test(${", ".join(TEST_ARGS)});
1899 }
1900 }
1901 }
1902
1903 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_input_offset) {
1904 $if ISA_CHECK:
1905 ${ISA_CHECK};
1906 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1907 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1908 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001909 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001910 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1911 .channels(channels)
1912 .input_offset(${CHANNEL_TILE})
1913 .Test(${", ".join(TEST_ARGS)});
1914 }
1915 }
1916 }
1917
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001918 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_zero) {
1919 $if ISA_CHECK:
1920 ${ISA_CHECK};
1921 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1922 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1923 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
1924 AvgPoolMicrokernelTester()
1925 .pooling_elements(pooling_elements)
1926 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1927 .channels(channels)
1928 .input_offset(${CHANNEL_TILE})
1929 .zero_index(zero_index)
1930 .Test(${", ".join(TEST_ARGS)});
1931 }
1932 }
1933 }
1934 }
1935
Marat Dukhan08b7a972020-07-14 18:17:29 -07001936 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001937 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_input_scale) {
1938 $if ISA_CHECK:
1939 ${ISA_CHECK};
1940 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1941 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1942 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1943 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001944 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001945 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1946 .channels(channels)
1947 .input_scale(scale)
1948 .Test(${", ".join(TEST_ARGS)});
1949 }
1950 }
1951 }
1952 }
1953
1954 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_input_zero_point) {
1955 $if ISA_CHECK:
1956 ${ISA_CHECK};
1957 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1958 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1959 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1960 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001961 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001962 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1963 .channels(channels)
1964 .input_zero_point(zero_point)
1965 .Test(${", ".join(TEST_ARGS)});
1966 }
1967 }
1968 }
1969 }
1970
1971 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_output_scale) {
1972 $if ISA_CHECK:
1973 ${ISA_CHECK};
1974 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1975 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1976 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
1977 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001978 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001979 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1980 .channels(channels)
1981 .output_scale(scale)
1982 .Test(${", ".join(TEST_ARGS)});
1983 }
1984 }
1985 }
1986 }
1987
1988 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_output_zero_point) {
1989 $if ISA_CHECK:
1990 ${ISA_CHECK};
1991 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
1992 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
1993 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
1994 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08001995 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08001996 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
1997 .channels(channels)
1998 .output_zero_point(zero_point)
1999 .Test(${", ".join(TEST_ARGS)});
2000 }
2001 }
2002 }
2003 }
2004
2005 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_qmin) {
2006 $if ISA_CHECK:
2007 ${ISA_CHECK};
2008 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2009 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
2010 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002011 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002012 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2013 .channels(channels)
2014 .qmin(128)
2015 .Test(${", ".join(TEST_ARGS)});
2016 }
2017 }
2018 }
2019
2020 TEST(${TEST_NAME}, channels_lt_${CHANNEL_TILE}_multipass_with_qmax) {
2021 $if ISA_CHECK:
2022 ${ISA_CHECK};
2023 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2024 for (size_t channels = 1; channels < ${CHANNEL_TILE}; channels++) {
2025 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002026 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002027 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2028 .channels(channels)
2029 .qmax(128)
2030 .Test(${", ".join(TEST_ARGS)});
2031 }
2032 }
2033 }
2034
2035 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass) {
2036 $if ISA_CHECK:
2037 ${ISA_CHECK};
2038 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2039 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2040 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002041 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002042 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2043 .channels(channels)
2044 .Test(${", ".join(TEST_ARGS)});
2045 }
2046 }
2047 }
2048
2049 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_input_offset) {
2050 $if ISA_CHECK:
2051 ${ISA_CHECK};
2052 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2053 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2054 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002055 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002056 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2057 .channels(channels)
2058 .input_offset(${next_prime(CHANNEL_TILE*2)})
2059 .Test(${", ".join(TEST_ARGS)});
2060 }
2061 }
2062 }
2063
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002064 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_zero) {
2065 $if ISA_CHECK:
2066 ${ISA_CHECK};
2067 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2068 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2069 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
2070 AvgPoolMicrokernelTester()
2071 .pooling_elements(pooling_elements)
2072 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2073 .channels(channels)
2074 .input_offset(${next_prime(CHANNEL_TILE*2)})
2075 .zero_index(zero_index)
2076 .Test(${", ".join(TEST_ARGS)});
2077 }
2078 }
2079 }
2080 }
2081
Marat Dukhan08b7a972020-07-14 18:17:29 -07002082 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002083 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_input_scale) {
2084 $if ISA_CHECK:
2085 ${ISA_CHECK};
2086 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2087 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2088 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
2089 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002090 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002091 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2092 .channels(channels)
2093 .input_scale(scale)
2094 .Test(${", ".join(TEST_ARGS)});
2095 }
2096 }
2097 }
2098 }
2099
2100 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_input_zero_point) {
2101 $if ISA_CHECK:
2102 ${ISA_CHECK};
2103 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2104 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2105 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
2106 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002107 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002108 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2109 .channels(channels)
2110 .input_zero_point(zero_point)
2111 .Test(${", ".join(TEST_ARGS)});
2112 }
2113 }
2114 }
2115 }
2116
2117 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_output_scale) {
2118 $if ISA_CHECK:
2119 ${ISA_CHECK};
2120 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2121 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2122 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
2123 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002124 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002125 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2126 .channels(channels)
2127 .output_scale(scale)
2128 .Test(${", ".join(TEST_ARGS)});
2129 }
2130 }
2131 }
2132 }
2133
2134 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_output_zero_point) {
2135 $if ISA_CHECK:
2136 ${ISA_CHECK};
2137 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2138 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2139 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
2140 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002141 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002142 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2143 .channels(channels)
2144 .output_zero_point(zero_point)
2145 .Test(${", ".join(TEST_ARGS)});
2146 }
2147 }
2148 }
2149 }
2150
2151 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_qmin) {
2152 $if ISA_CHECK:
2153 ${ISA_CHECK};
2154 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2155 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2156 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002157 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002158 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2159 .channels(channels)
2160 .qmin(128)
2161 .Test(${", ".join(TEST_ARGS)});
2162 }
2163 }
2164 }
2165
2166 TEST(${TEST_NAME}, channels_gt_${CHANNEL_TILE}_multipass_with_qmax) {
2167 $if ISA_CHECK:
2168 ${ISA_CHECK};
2169 for (size_t pooling_elements = ${PRIMARY_TILE+INCREMENTAL_TILE+1}; pooling_elements <= ${PRIMARY_TILE+INCREMENTAL_TILE*3}; pooling_elements += 3) {
2170 for (size_t channels = ${CHANNEL_TILE+1}; channels < ${10 if CHANNEL_TILE == 1 else CHANNEL_TILE*2}; channels++) {
2171 AvgPoolMicrokernelTester()
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002172 .pooling_elements(pooling_elements)
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002173 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2174 .channels(channels)
2175 .qmax(128)
2176 .Test(${", ".join(TEST_ARGS)});
2177 }
2178 }
2179 }
2180
2181 TEST(${TEST_NAME}, few_output_pixels) {
2182 $if ISA_CHECK:
2183 ${ISA_CHECK};
2184 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2185 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2186 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2187 AvgPoolMicrokernelTester()
2188 .output_pixels(output_pixels)
2189 .pooling_elements(pooling_elements)
2190 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2191 .channels(channels)
2192 .Test(${", ".join(TEST_ARGS)});
2193 }
2194 }
2195 }
2196 }
2197
2198 TEST(${TEST_NAME}, few_output_pixels_with_input_offset) {
2199 $if ISA_CHECK:
2200 ${ISA_CHECK};
2201 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2202 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2203 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2204 AvgPoolMicrokernelTester()
2205 .output_pixels(output_pixels)
2206 .pooling_elements(pooling_elements)
2207 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2208 .channels(channels)
2209 .input_offset(${next_prime(CHANNEL_TILE*5+1)})
2210 .Test(${", ".join(TEST_ARGS)});
2211 }
2212 }
2213 }
2214 }
2215
Marat Dukhanee1f63e2020-02-27 15:43:52 -08002216 TEST(${TEST_NAME}, few_output_pixels_with_zero) {
2217 $if ISA_CHECK:
2218 ${ISA_CHECK};
2219 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2220 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2221 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2222 for (size_t zero_index = 0; zero_index < pooling_elements; zero_index++) {
2223 AvgPoolMicrokernelTester()
2224 .output_pixels(output_pixels)
2225 .pooling_elements(pooling_elements)
2226 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2227 .channels(channels)
2228 .input_offset(${next_prime(CHANNEL_TILE*5+1)})
2229 .zero_index(zero_index)
2230 .Test(${", ".join(TEST_ARGS)});
2231 }
2232 }
2233 }
2234 }
2235 }
2236
Marat Dukhan08b7a972020-07-14 18:17:29 -07002237 $if DATATYPE == "qu8":
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002238 TEST(${TEST_NAME}, few_output_pixels_with_input_scale) {
2239 $if ISA_CHECK:
2240 ${ISA_CHECK};
2241 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2242 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2243 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2244 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
2245 AvgPoolMicrokernelTester()
2246 .output_pixels(output_pixels)
2247 .pooling_elements(pooling_elements)
2248 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2249 .channels(channels)
2250 .input_scale(scale)
2251 .Test(${", ".join(TEST_ARGS)});
2252 }
2253 }
2254 }
2255 }
2256 }
2257
2258 TEST(${TEST_NAME}, few_output_pixels_with_input_zero_point) {
2259 $if ISA_CHECK:
2260 ${ISA_CHECK};
2261 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2262 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2263 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2264 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
2265 AvgPoolMicrokernelTester()
2266 .output_pixels(output_pixels)
2267 .pooling_elements(pooling_elements)
2268 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2269 .channels(channels)
2270 .input_zero_point(zero_point)
2271 .Test(${", ".join(TEST_ARGS)});
2272 }
2273 }
2274 }
2275 }
2276 }
2277
2278 TEST(${TEST_NAME}, few_output_pixels_with_output_scale) {
2279 $if ISA_CHECK:
2280 ${ISA_CHECK};
2281 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2282 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2283 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2284 for (float scale = 0.01f; scale < 100.0f; scale *= 3.14159265f) {
2285 AvgPoolMicrokernelTester()
2286 .output_pixels(output_pixels)
2287 .pooling_elements(pooling_elements)
2288 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2289 .channels(channels)
2290 .output_scale(scale)
2291 .Test(${", ".join(TEST_ARGS)});
2292 }
2293 }
2294 }
2295 }
2296 }
2297
2298 TEST(${TEST_NAME}, few_output_pixels_with_output_zero_point) {
2299 $if ISA_CHECK:
2300 ${ISA_CHECK};
2301 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2302 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2303 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2304 for (int32_t zero_point = 0; zero_point <= 255; zero_point += 51) {
2305 AvgPoolMicrokernelTester()
2306 .output_pixels(output_pixels)
2307 .pooling_elements(pooling_elements)
2308 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2309 .channels(channels)
2310 .output_zero_point(zero_point)
2311 .Test(${", ".join(TEST_ARGS)});
2312 }
2313 }
2314 }
2315 }
2316 }
2317
2318 TEST(${TEST_NAME}, few_output_pixels_with_qmin) {
2319 $if ISA_CHECK:
2320 ${ISA_CHECK};
2321 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2322 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2323 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2324 AvgPoolMicrokernelTester()
2325 .output_pixels(output_pixels)
2326 .pooling_elements(pooling_elements)
2327 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2328 .channels(channels)
2329 .qmin(128)
2330 .Test(${", ".join(TEST_ARGS)});
2331 }
2332 }
2333 }
2334 }
2335
2336 TEST(${TEST_NAME}, few_output_pixels_with_qmax) {
2337 $if ISA_CHECK:
2338 ${ISA_CHECK};
2339 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2340 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2341 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2342 AvgPoolMicrokernelTester()
2343 .output_pixels(output_pixels)
2344 .pooling_elements(pooling_elements)
2345 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2346 .channels(channels)
2347 .qmax(128)
2348 .Test(${", ".join(TEST_ARGS)});
2349 }
2350 }
2351 }
2352 }
2353
2354 TEST(${TEST_NAME}, few_output_pixels_with_output_stride) {
2355 $if ISA_CHECK:
2356 ${ISA_CHECK};
2357 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2358 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2359 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2360 AvgPoolMicrokernelTester()
2361 .output_pixels(output_pixels)
2362 .pooling_elements(pooling_elements)
2363 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2364 .channels(channels)
2365 .output_stride(${next_prime(CHANNEL_TILE*5+1)})
2366 .Test(${", ".join(TEST_ARGS)});
2367 }
2368 }
2369 }
2370 }
2371
2372 TEST(${TEST_NAME}, few_output_pixels_with_step) {
2373 $if ISA_CHECK:
2374 ${ISA_CHECK};
2375 for (size_t output_pixels = 2; output_pixels <= 5; output_pixels++) {
2376 for (size_t pooling_elements : std::vector<size_t>{{${PRIMARY_TILE+1}, ${PRIMARY_TILE+INCREMENTAL_TILE-1}, ${PRIMARY_TILE+INCREMENTAL_TILE+1}}}) {
2377 for (size_t channels = 1; channels <= ${CHANNEL_TILE*5}; channels += ${max(1, CHANNEL_TILE-1)}) {
2378 for (size_t step = 2; step <= pooling_elements; step++) {
2379 AvgPoolMicrokernelTester()
2380 .output_pixels(output_pixels)
2381 .pooling_elements(pooling_elements)
2382 .pooling_tile(${PRIMARY_TILE}, ${INCREMENTAL_TILE})
2383 .step(step)
2384 .channels(channels)
2385 .output_stride(${next_prime(CHANNEL_TILE*5+1)})
2386 .Test(${", ".join(TEST_ARGS)});
2387 }
2388 }
2389 }
2390 }
2391 }
2392"""
2393
2394
2395def generate_test_cases(ukernel, primary_tile, incremental_tile, channel_tile,
2396 isa):
2397 """Generates all tests cases for a AVGPOOL micro-kernel.
2398
2399 Args:
2400 ukernel: C name of the micro-kernel function.
2401 primary_tile: Number of rows (pixels) processed per one iteration of the
2402 primary outer loop of the micro-kernel.
2403 incremental_tile: Number of rows (pixels) processed per one iteration of
2404 the incremental outer loop of the micro-kernel.
2405 channel_tile: Number of channels processed per one iteration of the inner
2406 loops of the micro-kernel.
2407 isa: instruction set required to run the micro-kernel. Generated unit test
2408 will skip execution if the host processor doesn't support this ISA.
2409
2410 Returns:
2411 Code for the test case.
2412 """
2413 _, test_name = ukernel.split("_", 1)
2414 _, datatype, ukernel_type, _ = ukernel.split("_", 3)
2415 test_args = [ukernel]
Marat Dukhan3de5dfa2020-12-10 11:19:47 -08002416 if not isa:
Marat Dukhan6ee435a2020-02-26 22:33:38 -08002417 test_args.append("AvgPoolMicrokernelTester::Variant::Scalar")
2418 return xngen.preprocess(AVGPOOL_TEST_TEMPLATE, {
2419 "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
2420 "TEST_ARGS": test_args,
2421 "DATATYPE": datatype,
2422 "PRIMARY_TILE": primary_tile,
2423 "INCREMENTAL_TILE": incremental_tile,
2424 "CHANNEL_TILE": channel_tile,
2425 "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
2426 "next_prime": next_prime,
2427 })
2428
2429
2430def main(args):
2431 options = parser.parse_args(args)
2432
2433 with codecs.open(options.spec, "r", encoding="utf-8") as spec_file:
2434 spec_yaml = yaml.safe_load(spec_file)
2435 if not isinstance(spec_yaml, list):
2436 raise ValueError("expected a list of micro-kernels in the spec")
2437
2438 tests = """\
2439// Copyright (c) Facebook, Inc. and its affiliates.
2440// All rights reserved.
2441//
2442// Copyright 2020 Google LLC
2443//
2444// This source code is licensed under the BSD-style license found in the
2445// LICENSE file in the root directory of this source tree.
2446//
2447// Auto-generated file. Do not edit!
2448// Specification: {specification}
2449// Generator: {generator}
2450
2451
2452#include <gtest/gtest.h>
2453
2454#include <xnnpack/common.h>
2455#include <xnnpack/isa-checks.h>
2456
2457#include <xnnpack/avgpool.h>
2458#include <xnnpack/pavgpool.h>
2459#include "avgpool-microkernel-tester.h"
2460""".format(specification=options.spec, generator=sys.argv[0])
2461
2462 for ukernel_spec in spec_yaml:
2463 name = ukernel_spec["name"]
2464 primary_tile, incremental_tile, channel_tile, arch, isa = \
2465 split_ukernel_name(name)
2466
2467 # specification can override architecture
2468 arch = ukernel_spec.get("arch", arch)
2469
2470 test_case = generate_test_cases(name, primary_tile, incremental_tile,
2471 channel_tile, isa)
2472 tests += "\n\n" + xnncommon.postprocess_test_case(test_case, arch, isa)
2473
2474 with codecs.open(options.output, "w", encoding="utf-8") as output_file:
2475 output_file.write(tests)
2476
2477
2478if __name__ == "__main__":
2479 main(sys.argv[1:])