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