1 // Copyright 2022 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 "space-to-depth-operator-tester.h"
7
8 #include <gtest/gtest.h>
9
10
TEST(SPACE_TO_DEPTH_NHWC_X8,one_output_pixel)11 TEST(SPACE_TO_DEPTH_NHWC_X8, one_output_pixel) {
12 size_t block_size = 3;
13 SpaceToDepthOperatorTester()
14 .input_size(block_size, block_size)
15 .block_size(block_size)
16 .input_channels(17)
17 .TestNHWCxX8();
18 }
19
TEST(SPACE_TO_DEPTH_NHWC_X8,one_column)20 TEST(SPACE_TO_DEPTH_NHWC_X8, one_column) {
21 size_t block_size = 3;
22 for (size_t input_height = 2; input_height <= 7; input_height++) {
23 SpaceToDepthOperatorTester()
24 .input_size(input_height * block_size, block_size)
25 .block_size(block_size)
26 .input_channels(17)
27 .TestNHWCxX8();
28 }
29 }
30
TEST(SPACE_TO_DEPTH_NHWC_X8,one_row)31 TEST(SPACE_TO_DEPTH_NHWC_X8, one_row) {
32 size_t block_size = 3;
33 for (size_t input_width = 2; input_width <= 7; input_width++) {
34 SpaceToDepthOperatorTester()
35 .input_size(block_size, input_width * block_size)
36 .block_size(block_size)
37 .input_channels(17)
38 .TestNHWCxX8();
39 }
40 }
41
TEST(SPACE_TO_DEPTH_NHWC_X8,varying_input_size)42 TEST(SPACE_TO_DEPTH_NHWC_X8, varying_input_size) {
43 size_t block_size = 3;
44 for (size_t input_height = 1; input_height <= 5; input_height++) {
45 for (size_t input_width = 1; input_width <= 5; input_width++) {
46 SpaceToDepthOperatorTester()
47 .input_size(input_height * block_size, input_width * block_size)
48 .block_size(block_size)
49 .input_channels(17)
50 .TestNHWCxX8();
51 }
52 }
53 }
54
TEST(SPACE_TO_DEPTH_NHWC_X8,varying_block_size)55 TEST(SPACE_TO_DEPTH_NHWC_X8, varying_block_size) {
56 for (uint32_t block_size = 2; block_size <= 5; block_size++) {
57 SpaceToDepthOperatorTester()
58 .input_size(7 * block_size, 5 * block_size)
59 .block_size(block_size)
60 .input_channels(17)
61 .TestNHWCxX8();
62 }
63 }
64
TEST(SPACE_TO_DEPTH_NHWC_X8,varying_input_channels)65 TEST(SPACE_TO_DEPTH_NHWC_X8, varying_input_channels) {
66 size_t block_size = 3;
67 for (size_t input_channels = 1; input_channels <= 15; input_channels++) {
68 SpaceToDepthOperatorTester()
69 .input_size(7 * block_size, 5 * block_size)
70 .block_size(block_size)
71 .input_channels(input_channels)
72 .TestNHWCxX8();
73 }
74 }
75
TEST(SPACE_TO_DEPTH_NHWC_X8,varying_batch_size)76 TEST(SPACE_TO_DEPTH_NHWC_X8, varying_batch_size) {
77 size_t block_size = 3;
78 for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
79 SpaceToDepthOperatorTester()
80 .batch_size(batch_size)
81 .input_size(7 * block_size, 5 * block_size)
82 .block_size(block_size)
83 .input_channels(17)
84 .TestNHWCxX8();
85 }
86 }
87
TEST(SPACE_TO_DEPTH_NHWC_X8,input_channels_stride)88 TEST(SPACE_TO_DEPTH_NHWC_X8, input_channels_stride) {
89 size_t block_size = 3;
90 SpaceToDepthOperatorTester()
91 .batch_size(1)
92 .input_size(7 * block_size, 5 * block_size)
93 .block_size(block_size)
94 .input_channels_stride(10)
95 .input_channels(9)
96 .TestNHWCxX8();
97 }
98
TEST(SPACE_TO_DEPTH_NHWC_X8,output_channels_stride)99 TEST(SPACE_TO_DEPTH_NHWC_X8, output_channels_stride) {
100 size_t block_size = 3;
101 SpaceToDepthOperatorTester()
102 .batch_size(2)
103 .input_size(7 * block_size, 5 * block_size)
104 .block_size(block_size)
105 .output_channels_stride(171)
106 .input_channels(17)
107 .TestNHWCxX8();
108 }
109
TEST(SPACE_TO_DEPTH_NHWC_X16,one_output_pixel)110 TEST(SPACE_TO_DEPTH_NHWC_X16, one_output_pixel) {
111 size_t block_size = 3;
112 SpaceToDepthOperatorTester()
113 .input_size(block_size, block_size)
114 .block_size(block_size)
115 .input_channels(17)
116 .TestNHWCxX16();
117 }
118
TEST(SPACE_TO_DEPTH_NHWC_X16,one_column)119 TEST(SPACE_TO_DEPTH_NHWC_X16, one_column) {
120 size_t block_size = 3;
121 for (size_t input_height = 2; input_height <= 7; input_height++) {
122 SpaceToDepthOperatorTester()
123 .input_size(input_height * block_size, block_size)
124 .block_size(block_size)
125 .input_channels(17)
126 .TestNHWCxX16();
127 }
128 }
129
TEST(SPACE_TO_DEPTH_NHWC_X16,one_row)130 TEST(SPACE_TO_DEPTH_NHWC_X16, one_row) {
131 size_t block_size = 3;
132 for (size_t input_width = 2; input_width <= 7; input_width++) {
133 SpaceToDepthOperatorTester()
134 .input_size(block_size, input_width * block_size)
135 .block_size(block_size)
136 .input_channels(17)
137 .TestNHWCxX16();
138 }
139 }
140
TEST(SPACE_TO_DEPTH_NHWC_X16,varying_input_size)141 TEST(SPACE_TO_DEPTH_NHWC_X16, varying_input_size) {
142 size_t block_size = 3;
143 for (size_t input_height = 1; input_height <= 5; input_height++) {
144 for (size_t input_width = 1; input_width <= 5; input_width++) {
145 SpaceToDepthOperatorTester()
146 .input_size(input_height * block_size, input_width * block_size)
147 .block_size(block_size)
148 .input_channels(17)
149 .TestNHWCxX16();
150 }
151 }
152 }
153
TEST(SPACE_TO_DEPTH_NHWC_X16,varying_block_size)154 TEST(SPACE_TO_DEPTH_NHWC_X16, varying_block_size) {
155 for (uint32_t block_size = 2; block_size <= 5; block_size++) {
156 SpaceToDepthOperatorTester()
157 .input_size(7 * block_size, 5 * block_size)
158 .block_size(block_size)
159 .input_channels(17)
160 .TestNHWCxX16();
161 }
162 }
163
TEST(SPACE_TO_DEPTH_NHWC_X16,varying_input_channels)164 TEST(SPACE_TO_DEPTH_NHWC_X16, varying_input_channels) {
165 size_t block_size = 3;
166 for (size_t input_channels = 1; input_channels <= 15; input_channels++) {
167 SpaceToDepthOperatorTester()
168 .input_size(7 * block_size, 5 * block_size)
169 .block_size(block_size)
170 .input_channels(input_channels)
171 .TestNHWCxX16();
172 }
173 }
174
TEST(SPACE_TO_DEPTH_NHWC_X16,varying_batch_size)175 TEST(SPACE_TO_DEPTH_NHWC_X16, varying_batch_size) {
176 size_t block_size = 3;
177 for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
178 SpaceToDepthOperatorTester()
179 .batch_size(batch_size)
180 .input_size(7 * block_size, 5 * block_size)
181 .block_size(block_size)
182 .input_channels(17)
183 .TestNHWCxX32();
184 }
185 }
186
TEST(SPACE_TO_DEPTH_NHWC_X16,input_channels_stride)187 TEST(SPACE_TO_DEPTH_NHWC_X16, input_channels_stride) {
188 size_t block_size = 3;
189 SpaceToDepthOperatorTester()
190 .batch_size(1)
191 .input_size(7 * block_size, 5 * block_size)
192 .block_size(block_size)
193 .input_channels_stride(10)
194 .input_channels(9)
195 .TestNHWCxX16();
196 }
197
TEST(SPACE_TO_DEPTH_NHWC_X16,output_channels_stride)198 TEST(SPACE_TO_DEPTH_NHWC_X16, output_channels_stride) {
199 size_t block_size = 3;
200 SpaceToDepthOperatorTester()
201 .batch_size(2)
202 .input_size(7 * block_size, 5 * block_size)
203 .block_size(block_size)
204 .output_channels_stride(171)
205 .input_channels(17)
206 .TestNHWCxX32();
207 }
208
TEST(SPACE_TO_DEPTH_NHWC_X32,one_output_pixel)209 TEST(SPACE_TO_DEPTH_NHWC_X32, one_output_pixel) {
210 size_t block_size = 3;
211 SpaceToDepthOperatorTester()
212 .input_size(block_size, block_size)
213 .block_size(block_size)
214 .input_channels(17)
215 .TestNHWCxX32();
216 }
217
TEST(SPACE_TO_DEPTH_NHWC_X32,one_column)218 TEST(SPACE_TO_DEPTH_NHWC_X32, one_column) {
219 size_t block_size = 3;
220 for (size_t input_height = 2; input_height <= 7; input_height++) {
221 SpaceToDepthOperatorTester()
222 .input_size(input_height * block_size, block_size)
223 .block_size(block_size)
224 .input_channels(17)
225 .TestNHWCxX32();
226 }
227 }
228
TEST(SPACE_TO_DEPTH_NHWC_X32,one_row)229 TEST(SPACE_TO_DEPTH_NHWC_X32, one_row) {
230 size_t block_size = 3;
231 for (size_t input_width = 2; input_width <= 7; input_width++) {
232 SpaceToDepthOperatorTester()
233 .input_size(block_size, input_width * block_size)
234 .block_size(block_size)
235 .input_channels(17)
236 .TestNHWCxX32();
237 }
238 }
239
TEST(SPACE_TO_DEPTH_NHWC_X32,varying_input_size)240 TEST(SPACE_TO_DEPTH_NHWC_X32, varying_input_size) {
241 size_t block_size = 3;
242 for (size_t input_height = 1; input_height <= 5; input_height++) {
243 for (size_t input_width = 1; input_width <= 5; input_width++) {
244 SpaceToDepthOperatorTester()
245 .input_size(input_height * block_size, input_width * block_size)
246 .block_size(block_size)
247 .input_channels(17)
248 .TestNHWCxX32();
249 }
250 }
251 }
252
TEST(SPACE_TO_DEPTH_NHWC_X32,varying_block_size)253 TEST(SPACE_TO_DEPTH_NHWC_X32, varying_block_size) {
254 for (uint32_t block_size = 2; block_size <= 5; block_size++) {
255 SpaceToDepthOperatorTester()
256 .input_size(7 * block_size, 5 * block_size)
257 .block_size(block_size)
258 .input_channels(17)
259 .TestNHWCxX32();
260 }
261 }
262
TEST(SPACE_TO_DEPTH_NHWC_X32,varying_input_channels)263 TEST(SPACE_TO_DEPTH_NHWC_X32, varying_input_channels) {
264 size_t block_size = 3;
265 for (size_t input_channels = 1; input_channels <= 15; input_channels++) {
266 SpaceToDepthOperatorTester()
267 .input_size(7 * block_size, 5 * block_size)
268 .block_size(block_size)
269 .input_channels(input_channels)
270 .TestNHWCxX32();
271 }
272 }
273
TEST(SPACE_TO_DEPTH_NHWC_X32,varying_batch_size)274 TEST(SPACE_TO_DEPTH_NHWC_X32, varying_batch_size) {
275 size_t block_size = 3;
276 for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
277 SpaceToDepthOperatorTester()
278 .batch_size(batch_size)
279 .input_size(7 * block_size, 5 * block_size)
280 .block_size(block_size)
281 .input_channels(17)
282 .TestNHWCxX32();
283 }
284 }
285
TEST(SPACE_TO_DEPTH_NHWC_X32,input_channels_stride)286 TEST(SPACE_TO_DEPTH_NHWC_X32, input_channels_stride) {
287 size_t block_size = 3;
288 SpaceToDepthOperatorTester()
289 .batch_size(1)
290 .input_size(7 * block_size, 5 * block_size)
291 .block_size(block_size)
292 .input_channels_stride(10)
293 .input_channels(9)
294 .TestNHWCxX32();
295 }
296
TEST(SPACE_TO_DEPTH_NHWC_X32,output_channels_stride)297 TEST(SPACE_TO_DEPTH_NHWC_X32, output_channels_stride) {
298 size_t block_size = 3;
299 SpaceToDepthOperatorTester()
300 .batch_size(2)
301 .input_size(7 * block_size, 5 * block_size)
302 .block_size(block_size)
303 .output_channels_stride(171)
304 .input_channels(17)
305 .TestNHWCxX32();
306 }
307