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 "clamp-operator-tester.h"
12
13
TEST(CLAMP_NC_U8,unit_batch)14 TEST(CLAMP_NC_U8, unit_batch) {
15 for (size_t channels = 1; channels < 100; channels++) {
16 ClampOperatorTester()
17 .batch_size(1)
18 .channels(channels)
19 .iterations(3)
20 .TestU8();
21 }
22 }
23
TEST(CLAMP_NC_U8,unit_batch_with_qmin)24 TEST(CLAMP_NC_U8, unit_batch_with_qmin) {
25 for (size_t channels = 1; channels < 100; channels += 15) {
26 for (uint8_t qmin = 1; qmin < 255; qmin++) {
27 ClampOperatorTester()
28 .batch_size(1)
29 .channels(channels)
30 .qmin(qmin)
31 .qmax(255)
32 .iterations(3)
33 .TestU8();
34 }
35 }
36 }
37
TEST(CLAMP_NC_U8,unit_batch_with_qmax)38 TEST(CLAMP_NC_U8, unit_batch_with_qmax) {
39 for (size_t channels = 1; channels < 100; channels += 15) {
40 for (uint8_t qmax = 1; qmax < 255; qmax++) {
41 ClampOperatorTester()
42 .batch_size(1)
43 .channels(channels)
44 .qmin(0)
45 .qmax(qmax)
46 .iterations(3)
47 .TestU8();
48 }
49 }
50 }
51
TEST(CLAMP_NC_U8,small_batch)52 TEST(CLAMP_NC_U8, small_batch) {
53 for (size_t channels = 1; channels < 100; channels++) {
54 ClampOperatorTester()
55 .batch_size(3)
56 .channels(channels)
57 .iterations(3)
58 .TestU8();
59 }
60 }
61
TEST(CLAMP_NC_U8,small_batch_with_input_stride)62 TEST(CLAMP_NC_U8, small_batch_with_input_stride) {
63 for (size_t channels = 1; channels < 100; channels += 15) {
64 ClampOperatorTester()
65 .batch_size(3)
66 .channels(channels)
67 .input_stride(129)
68 .iterations(3)
69 .TestU8();
70 }
71 }
72
TEST(CLAMP_NC_U8,small_batch_with_output_stride)73 TEST(CLAMP_NC_U8, small_batch_with_output_stride) {
74 for (size_t channels = 1; channels < 100; channels += 15) {
75 ClampOperatorTester()
76 .batch_size(3)
77 .channels(channels)
78 .output_stride(117)
79 .iterations(3)
80 .TestU8();
81 }
82 }
83
TEST(CLAMP_NC_U8,small_batch_with_input_and_output_stride)84 TEST(CLAMP_NC_U8, small_batch_with_input_and_output_stride) {
85 for (size_t channels = 1; channels < 100; channels += 15) {
86 ClampOperatorTester()
87 .batch_size(3)
88 .channels(channels)
89 .input_stride(129)
90 .output_stride(117)
91 .iterations(3)
92 .TestU8();
93 }
94 }
95
TEST(CLAMP_NC_F32,unit_batch)96 TEST(CLAMP_NC_F32, unit_batch) {
97 for (size_t channels = 1; channels < 100; channels++) {
98 ClampOperatorTester()
99 .batch_size(1)
100 .channels(channels)
101 .iterations(3)
102 .TestF32();
103 }
104 }
105
TEST(CLAMP_NC_F32,unit_batch_with_qmin)106 TEST(CLAMP_NC_F32, unit_batch_with_qmin) {
107 for (size_t channels = 1; channels < 100; channels += 15) {
108 for (uint8_t qmin = 1; qmin < 255; qmin++) {
109 ClampOperatorTester()
110 .batch_size(1)
111 .channels(channels)
112 .qmin(qmin)
113 .qmax(255)
114 .iterations(3)
115 .TestF32();
116 }
117 }
118 }
119
TEST(CLAMP_NC_F32,unit_batch_with_qmax)120 TEST(CLAMP_NC_F32, unit_batch_with_qmax) {
121 for (size_t channels = 1; channels < 100; channels += 15) {
122 for (uint8_t qmax = 1; qmax < 255; qmax++) {
123 ClampOperatorTester()
124 .batch_size(1)
125 .channels(channels)
126 .qmin(0)
127 .qmax(qmax)
128 .iterations(3)
129 .TestF32();
130 }
131 }
132 }
133
TEST(CLAMP_NC_F32,unit_batch_with_relu)134 TEST(CLAMP_NC_F32, unit_batch_with_relu) {
135 for (size_t channels = 1; channels < 100; channels++) {
136 ClampOperatorTester()
137 .batch_size(1)
138 .channels(channels)
139 .relu_activation(true)
140 .iterations(3)
141 .TestF32();
142 }
143 }
TEST(CLAMP_NC_F32,small_batch)144 TEST(CLAMP_NC_F32, small_batch) {
145 for (size_t channels = 1; channels < 100; channels++) {
146 ClampOperatorTester()
147 .batch_size(3)
148 .channels(channels)
149 .iterations(3)
150 .TestF32();
151 }
152 }
153
TEST(CLAMP_NC_F32,small_batch_with_input_stride)154 TEST(CLAMP_NC_F32, small_batch_with_input_stride) {
155 for (size_t channels = 1; channels < 100; channels += 15) {
156 ClampOperatorTester()
157 .batch_size(3)
158 .channels(channels)
159 .input_stride(129)
160 .iterations(3)
161 .TestF32();
162 }
163 }
164
TEST(CLAMP_NC_F32,small_batch_with_output_stride)165 TEST(CLAMP_NC_F32, small_batch_with_output_stride) {
166 for (size_t channels = 1; channels < 100; channels += 15) {
167 ClampOperatorTester()
168 .batch_size(3)
169 .channels(channels)
170 .output_stride(117)
171 .iterations(3)
172 .TestF32();
173 }
174 }
175
TEST(CLAMP_NC_F32,small_batch_with_input_and_output_stride)176 TEST(CLAMP_NC_F32, small_batch_with_input_and_output_stride) {
177 for (size_t channels = 1; channels < 100; channels += 15) {
178 ClampOperatorTester()
179 .batch_size(3)
180 .channels(channels)
181 .input_stride(129)
182 .output_stride(117)
183 .iterations(3)
184 .TestF32();
185 }
186 }
187