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