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