1 // Copyright 2021 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5
6 #include <gtest/gtest.h>
7
8 #include "tanh-operator-tester.h"
9
10
TEST(TANH_NC_QS8,unit_batch)11 TEST(TANH_NC_QS8, unit_batch) {
12 for (size_t channels = 1; channels < 100; channels += 15) {
13 TanhOperatorTester()
14 .batch_size(1)
15 .channels(channels)
16 .iterations(3)
17 .TestQS8();
18 }
19 }
20
TEST(TANH_NC_QS8,unit_batch_with_qmin)21 TEST(TANH_NC_QS8, unit_batch_with_qmin) {
22 for (size_t channels = 1; channels < 100; channels += 15) {
23 TanhOperatorTester()
24 .batch_size(1)
25 .channels(channels)
26 .qmin(128)
27 .iterations(3)
28 .TestQS8();
29 }
30 }
31
TEST(TANH_NC_QS8,unit_batch_with_qmax)32 TEST(TANH_NC_QS8, unit_batch_with_qmax) {
33 for (size_t channels = 1; channels < 100; channels += 15) {
34 TanhOperatorTester()
35 .batch_size(1)
36 .channels(channels)
37 .qmax(128)
38 .iterations(3)
39 .TestQS8();
40 }
41 }
42
TEST(TANH_NC_QS8,unit_batch_with_input_scale)43 TEST(TANH_NC_QS8, unit_batch_with_input_scale) {
44 for (size_t channels = 1; channels < 100; channels += 15) {
45 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
46 TanhOperatorTester()
47 .batch_size(1)
48 .channels(channels)
49 .input_scale(input_scale)
50 .iterations(1)
51 .TestQS8();
52 }
53 }
54 }
55
TEST(TANH_NC_QS8,unit_batch_with_input_zero_point)56 TEST(TANH_NC_QS8, unit_batch_with_input_zero_point) {
57 for (size_t channels = 1; channels < 100; channels += 15) {
58 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
59 TanhOperatorTester()
60 .batch_size(1)
61 .channels(channels)
62 .input_zero_point(uint8_t(input_zero_point))
63 .iterations(1)
64 .TestQS8();
65 }
66 }
67 }
68
TEST(TANH_NC_QS8,small_batch)69 TEST(TANH_NC_QS8, small_batch) {
70 for (size_t channels = 1; channels < 100; channels += 15) {
71 TanhOperatorTester()
72 .batch_size(3)
73 .channels(channels)
74 .iterations(3)
75 .TestQS8();
76 }
77 }
78
TEST(TANH_NC_QS8,small_batch_with_input_stride)79 TEST(TANH_NC_QS8, small_batch_with_input_stride) {
80 for (size_t channels = 1; channels < 100; channels += 15) {
81 TanhOperatorTester()
82 .batch_size(3)
83 .channels(channels)
84 .input_stride(129)
85 .iterations(3)
86 .TestQS8();
87 }
88 }
89
TEST(TANH_NC_QS8,small_batch_with_output_stride)90 TEST(TANH_NC_QS8, small_batch_with_output_stride) {
91 for (size_t channels = 1; channels < 100; channels += 15) {
92 TanhOperatorTester()
93 .batch_size(3)
94 .channels(channels)
95 .output_stride(117)
96 .iterations(3)
97 .TestQS8();
98 }
99 }
100
TEST(TANH_NC_QS8,small_batch_with_qmin)101 TEST(TANH_NC_QS8, small_batch_with_qmin) {
102 for (size_t channels = 1; channels < 100; channels += 15) {
103 TanhOperatorTester()
104 .batch_size(3)
105 .channels(channels)
106 .qmin(128)
107 .iterations(3)
108 .TestQS8();
109 }
110 }
111
TEST(TANH_NC_QS8,small_batch_with_qmax)112 TEST(TANH_NC_QS8, small_batch_with_qmax) {
113 for (size_t channels = 1; channels < 100; channels += 15) {
114 TanhOperatorTester()
115 .batch_size(3)
116 .channels(channels)
117 .qmax(128)
118 .iterations(3)
119 .TestQS8();
120 }
121 }
122
TEST(TANH_NC_QS8,small_batch_with_input_scale)123 TEST(TANH_NC_QS8, small_batch_with_input_scale) {
124 for (size_t channels = 1; channels < 100; channels += 15) {
125 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
126 TanhOperatorTester()
127 .batch_size(3)
128 .channels(channels)
129 .input_scale(input_scale)
130 .iterations(1)
131 .TestQS8();
132 }
133 }
134 }
135
TEST(TANH_NC_QS8,small_batch_with_input_zero_point)136 TEST(TANH_NC_QS8, small_batch_with_input_zero_point) {
137 for (size_t channels = 1; channels < 100; channels += 15) {
138 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
139 TanhOperatorTester()
140 .batch_size(3)
141 .channels(channels)
142 .input_zero_point(uint8_t(input_zero_point))
143 .iterations(1)
144 .TestQS8();
145 }
146 }
147 }
148
TEST(TANH_NC_QS8,strided_batch)149 TEST(TANH_NC_QS8, strided_batch) {
150 for (size_t channels = 1; channels < 100; channels += 15) {
151 TanhOperatorTester()
152 .batch_size(3)
153 .channels(channels)
154 .input_stride(129)
155 .output_stride(117)
156 .iterations(3)
157 .TestQS8();
158 }
159 }
160
TEST(TANH_NC_QS8,strided_batch_with_qmin)161 TEST(TANH_NC_QS8, strided_batch_with_qmin) {
162 for (size_t channels = 1; channels < 100; channels += 15) {
163 TanhOperatorTester()
164 .batch_size(3)
165 .channels(channels)
166 .input_stride(129)
167 .output_stride(117)
168 .qmin(128)
169 .iterations(3)
170 .TestQS8();
171 }
172 }
173
TEST(TANH_NC_QS8,strided_batch_with_qmax)174 TEST(TANH_NC_QS8, strided_batch_with_qmax) {
175 for (size_t channels = 1; channels < 100; channels += 15) {
176 TanhOperatorTester()
177 .batch_size(3)
178 .channels(channels)
179 .input_stride(129)
180 .output_stride(117)
181 .qmax(128)
182 .iterations(3)
183 .TestQS8();
184 }
185 }
186
TEST(TANH_NC_QS8,strided_batch_with_input_scale)187 TEST(TANH_NC_QS8, strided_batch_with_input_scale) {
188 for (size_t channels = 1; channels < 100; channels += 15) {
189 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
190 TanhOperatorTester()
191 .batch_size(3)
192 .channels(channels)
193 .input_stride(129)
194 .output_stride(117)
195 .input_scale(input_scale)
196 .iterations(1)
197 .TestQS8();
198 }
199 }
200 }
201
TEST(TANH_NC_QS8,strided_batch_with_input_zero_point)202 TEST(TANH_NC_QS8, strided_batch_with_input_zero_point) {
203 for (size_t channels = 1; channels < 100; channels += 15) {
204 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
205 TanhOperatorTester()
206 .batch_size(3)
207 .channels(channels)
208 .input_stride(129)
209 .output_stride(117)
210 .input_zero_point(uint8_t(input_zero_point))
211 .iterations(1)
212 .TestQS8();
213 }
214 }
215 }
216
TEST(TANH_NC_QU8,unit_batch)217 TEST(TANH_NC_QU8, unit_batch) {
218 for (size_t channels = 1; channels < 100; channels += 15) {
219 TanhOperatorTester()
220 .batch_size(1)
221 .channels(channels)
222 .iterations(3)
223 .TestQU8();
224 }
225 }
226
TEST(TANH_NC_QU8,unit_batch_with_qmin)227 TEST(TANH_NC_QU8, unit_batch_with_qmin) {
228 for (size_t channels = 1; channels < 100; channels += 15) {
229 TanhOperatorTester()
230 .batch_size(1)
231 .channels(channels)
232 .qmin(128)
233 .iterations(3)
234 .TestQU8();
235 }
236 }
237
TEST(TANH_NC_QU8,unit_batch_with_qmax)238 TEST(TANH_NC_QU8, unit_batch_with_qmax) {
239 for (size_t channels = 1; channels < 100; channels += 15) {
240 TanhOperatorTester()
241 .batch_size(1)
242 .channels(channels)
243 .qmax(128)
244 .iterations(3)
245 .TestQU8();
246 }
247 }
248
TEST(TANH_NC_QU8,unit_batch_with_input_scale)249 TEST(TANH_NC_QU8, unit_batch_with_input_scale) {
250 for (size_t channels = 1; channels < 100; channels += 15) {
251 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
252 TanhOperatorTester()
253 .batch_size(1)
254 .channels(channels)
255 .input_scale(input_scale)
256 .iterations(1)
257 .TestQU8();
258 }
259 }
260 }
261
TEST(TANH_NC_QU8,unit_batch_with_input_zero_point)262 TEST(TANH_NC_QU8, unit_batch_with_input_zero_point) {
263 for (size_t channels = 1; channels < 100; channels += 15) {
264 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
265 TanhOperatorTester()
266 .batch_size(1)
267 .channels(channels)
268 .input_zero_point(uint8_t(input_zero_point))
269 .iterations(1)
270 .TestQU8();
271 }
272 }
273 }
274
TEST(TANH_NC_QU8,small_batch)275 TEST(TANH_NC_QU8, small_batch) {
276 for (size_t channels = 1; channels < 100; channels += 15) {
277 TanhOperatorTester()
278 .batch_size(3)
279 .channels(channels)
280 .iterations(3)
281 .TestQU8();
282 }
283 }
284
TEST(TANH_NC_QU8,small_batch_with_input_stride)285 TEST(TANH_NC_QU8, small_batch_with_input_stride) {
286 for (size_t channels = 1; channels < 100; channels += 15) {
287 TanhOperatorTester()
288 .batch_size(3)
289 .channels(channels)
290 .input_stride(129)
291 .iterations(3)
292 .TestQU8();
293 }
294 }
295
TEST(TANH_NC_QU8,small_batch_with_output_stride)296 TEST(TANH_NC_QU8, small_batch_with_output_stride) {
297 for (size_t channels = 1; channels < 100; channels += 15) {
298 TanhOperatorTester()
299 .batch_size(3)
300 .channels(channels)
301 .output_stride(117)
302 .iterations(3)
303 .TestQU8();
304 }
305 }
306
TEST(TANH_NC_QU8,small_batch_with_qmin)307 TEST(TANH_NC_QU8, small_batch_with_qmin) {
308 for (size_t channels = 1; channels < 100; channels += 15) {
309 TanhOperatorTester()
310 .batch_size(3)
311 .channels(channels)
312 .qmin(128)
313 .iterations(3)
314 .TestQU8();
315 }
316 }
317
TEST(TANH_NC_QU8,small_batch_with_qmax)318 TEST(TANH_NC_QU8, small_batch_with_qmax) {
319 for (size_t channels = 1; channels < 100; channels += 15) {
320 TanhOperatorTester()
321 .batch_size(3)
322 .channels(channels)
323 .qmax(128)
324 .iterations(3)
325 .TestQU8();
326 }
327 }
328
TEST(TANH_NC_QU8,small_batch_with_input_scale)329 TEST(TANH_NC_QU8, small_batch_with_input_scale) {
330 for (size_t channels = 1; channels < 100; channels += 15) {
331 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
332 TanhOperatorTester()
333 .batch_size(3)
334 .channels(channels)
335 .input_scale(input_scale)
336 .iterations(1)
337 .TestQU8();
338 }
339 }
340 }
341
TEST(TANH_NC_QU8,small_batch_with_input_zero_point)342 TEST(TANH_NC_QU8, small_batch_with_input_zero_point) {
343 for (size_t channels = 1; channels < 100; channels += 15) {
344 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
345 TanhOperatorTester()
346 .batch_size(3)
347 .channels(channels)
348 .input_zero_point(uint8_t(input_zero_point))
349 .iterations(1)
350 .TestQU8();
351 }
352 }
353 }
354
TEST(TANH_NC_QU8,strided_batch)355 TEST(TANH_NC_QU8, strided_batch) {
356 for (size_t channels = 1; channels < 100; channels += 15) {
357 TanhOperatorTester()
358 .batch_size(3)
359 .channels(channels)
360 .input_stride(129)
361 .output_stride(117)
362 .iterations(3)
363 .TestQU8();
364 }
365 }
366
TEST(TANH_NC_QU8,strided_batch_with_qmin)367 TEST(TANH_NC_QU8, strided_batch_with_qmin) {
368 for (size_t channels = 1; channels < 100; channels += 15) {
369 TanhOperatorTester()
370 .batch_size(3)
371 .channels(channels)
372 .input_stride(129)
373 .output_stride(117)
374 .qmin(128)
375 .iterations(3)
376 .TestQU8();
377 }
378 }
379
TEST(TANH_NC_QU8,strided_batch_with_qmax)380 TEST(TANH_NC_QU8, strided_batch_with_qmax) {
381 for (size_t channels = 1; channels < 100; channels += 15) {
382 TanhOperatorTester()
383 .batch_size(3)
384 .channels(channels)
385 .input_stride(129)
386 .output_stride(117)
387 .qmax(128)
388 .iterations(3)
389 .TestQU8();
390 }
391 }
392
TEST(TANH_NC_QU8,strided_batch_with_input_scale)393 TEST(TANH_NC_QU8, strided_batch_with_input_scale) {
394 for (size_t channels = 1; channels < 100; channels += 15) {
395 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 10.0f) {
396 TanhOperatorTester()
397 .batch_size(3)
398 .channels(channels)
399 .input_stride(129)
400 .output_stride(117)
401 .input_scale(input_scale)
402 .iterations(1)
403 .TestQU8();
404 }
405 }
406 }
407
TEST(TANH_NC_QU8,strided_batch_with_input_zero_point)408 TEST(TANH_NC_QU8, strided_batch_with_input_zero_point) {
409 for (size_t channels = 1; channels < 100; channels += 15) {
410 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
411 TanhOperatorTester()
412 .batch_size(3)
413 .channels(channels)
414 .input_stride(129)
415 .output_stride(117)
416 .input_zero_point(uint8_t(input_zero_point))
417 .iterations(1)
418 .TestQU8();
419 }
420 }
421 }
422