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_Q8,unit_batch)14 TEST(LEAKY_RELU_NC_Q8, unit_batch) {
15 for (size_t channels = 1; channels < 100; channels++) {
16 LeakyReLUOperatorTester()
17 .batch_size(1)
18 .channels(channels)
19 .iterations(3)
20 .TestQ8();
21 }
22 }
23
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_qmin)24 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_qmin) {
25 for (size_t channels = 1; channels < 100; channels += 15) {
26 LeakyReLUOperatorTester()
27 .batch_size(1)
28 .channels(channels)
29 .qmin(128)
30 .iterations(3)
31 .TestQ8();
32 }
33 }
34
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_qmax)35 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_qmax) {
36 for (size_t channels = 1; channels < 100; channels += 15) {
37 LeakyReLUOperatorTester()
38 .batch_size(1)
39 .channels(channels)
40 .qmax(128)
41 .iterations(3)
42 .TestQ8();
43 }
44 }
45
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_negative_slope)46 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_negative_slope) {
47 for (size_t channels = 1; channels < 100; channels += 15) {
48 for (float negative_slope = 1.0e-4f; negative_slope < 1.0f; negative_slope *= 3.14159265f) {
49 LeakyReLUOperatorTester()
50 .batch_size(1)
51 .channels(channels)
52 .negative_slope(negative_slope)
53 .iterations(1)
54 .TestQ8();
55 }
56 }
57 }
58
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_input_scale)59 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_input_scale) {
60 for (size_t channels = 1; channels < 100; channels += 15) {
61 for (float input_scale = 1.0e-2f; input_scale < 1.0e+2f; input_scale *= 3.14159265f) {
62 LeakyReLUOperatorTester()
63 .batch_size(1)
64 .channels(channels)
65 .input_scale(input_scale)
66 .iterations(1)
67 .TestQ8();
68 }
69 }
70 }
71
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_input_zero_point)72 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_input_zero_point) {
73 for (size_t channels = 1; channels < 100; channels += 15) {
74 for (int32_t input_zero_point = 0; input_zero_point <= 255; input_zero_point += 51) {
75 LeakyReLUOperatorTester()
76 .batch_size(1)
77 .channels(channels)
78 .input_zero_point(uint8_t(input_zero_point))
79 .iterations(1)
80 .TestQ8();
81 }
82 }
83 }
84
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_output_scale)85 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_output_scale) {
86 for (size_t channels = 1; channels < 100; channels += 15) {
87 for (float output_scale = 1.0e-2f; output_scale < 1.0e+2f; output_scale *= 3.14159265f) {
88 LeakyReLUOperatorTester()
89 .batch_size(1)
90 .channels(channels)
91 .output_scale(output_scale)
92 .iterations(1)
93 .TestQ8();
94 }
95 }
96 }
97
TEST(LEAKY_RELU_NC_Q8,unit_batch_with_output_zero_point)98 TEST(LEAKY_RELU_NC_Q8, unit_batch_with_output_zero_point) {
99 for (size_t channels = 1; channels < 100; channels += 15) {
100 for (int32_t output_zero_point = 0; output_zero_point <= 255; output_zero_point += 51) {
101 LeakyReLUOperatorTester()
102 .batch_size(1)
103 .channels(channels)
104 .output_zero_point(uint8_t(output_zero_point))
105 .iterations(1)
106 .TestQ8();
107 }
108 }
109 }
110
TEST(LEAKY_RELU_NC_Q8,small_batch)111 TEST(LEAKY_RELU_NC_Q8, small_batch) {
112 for (size_t channels = 1; channels < 100; channels++) {
113 LeakyReLUOperatorTester()
114 .batch_size(3)
115 .channels(channels)
116 .iterations(3)
117 .TestQ8();
118 }
119 }
120
TEST(LEAKY_RELU_NC_Q8,small_batch_with_input_stride)121 TEST(LEAKY_RELU_NC_Q8, small_batch_with_input_stride) {
122 for (size_t channels = 1; channels < 100; channels += 15) {
123 LeakyReLUOperatorTester()
124 .batch_size(3)
125 .channels(channels)
126 .input_stride(129)
127 .iterations(3)
128 .TestQ8();
129 }
130 }
131
TEST(LEAKY_RELU_NC_Q8,small_batch_with_output_stride)132 TEST(LEAKY_RELU_NC_Q8, small_batch_with_output_stride) {
133 for (size_t channels = 1; channels < 100; channels += 15) {
134 LeakyReLUOperatorTester()
135 .batch_size(3)
136 .channels(channels)
137 .output_stride(117)
138 .iterations(3)
139 .TestQ8();
140 }
141 }
142
TEST(LEAKY_RELU_NC_Q8,small_batch_with_input_and_output_stride)143 TEST(LEAKY_RELU_NC_Q8, small_batch_with_input_and_output_stride) {
144 for (size_t channels = 1; channels < 100; channels += 15) {
145 LeakyReLUOperatorTester()
146 .batch_size(3)
147 .channels(channels)
148 .input_stride(129)
149 .output_stride(117)
150 .iterations(3)
151 .TestQ8();
152 }
153 }
154