1 // Copyright 2019 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 <gtest/gtest.h>
7
8 #include <xnnpack/common.h>
9 #include <xnnpack/isa-checks.h>
10
11 #include <xnnpack/unpool.h>
12 #include "unpool-microkernel-tester.h"
13
14
15 #if XNN_ARCH_ARM || XNN_ARCH_ARM64
TEST(X32_UNPOOL__NEON,c_eq_4)16 TEST(X32_UNPOOL__NEON, c_eq_4) {
17 TEST_REQUIRES_ARM_NEON;
18 UnpoolMicrokernelTester()
19 .p(10)
20 .c(4)
21 .Test(xnn_x32_unpool_ukernel__neon);
22 }
23
TEST(X32_UNPOOL__NEON,c_div_4)24 TEST(X32_UNPOOL__NEON, c_div_4) {
25 TEST_REQUIRES_ARM_NEON;
26 for (size_t c = 8; c < 32; c += 4) {
27 UnpoolMicrokernelTester()
28 .p(10)
29 .c(c)
30 .Test(xnn_x32_unpool_ukernel__neon);
31 }
32 }
33
TEST(X32_UNPOOL__NEON,c_lt_4)34 TEST(X32_UNPOOL__NEON, c_lt_4) {
35 TEST_REQUIRES_ARM_NEON;
36 for (size_t c = 1; c < 4; c++) {
37 UnpoolMicrokernelTester()
38 .p(10)
39 .c(c)
40 .Test(xnn_x32_unpool_ukernel__neon);
41 }
42 }
43
TEST(X32_UNPOOL__NEON,c_gt_4)44 TEST(X32_UNPOOL__NEON, c_gt_4) {
45 TEST_REQUIRES_ARM_NEON;
46 for (size_t c = 5; c < 8; c++) {
47 UnpoolMicrokernelTester()
48 .p(10)
49 .c(4)
50 .Test(xnn_x32_unpool_ukernel__neon);
51 }
52 }
53
TEST(X32_UNPOOL__NEON,varying_p)54 TEST(X32_UNPOOL__NEON, varying_p) {
55 TEST_REQUIRES_ARM_NEON;
56 for (size_t p = 1; p < 20; p += 3) {
57 for (size_t c = 1; c < 32; c += 5) {
58 UnpoolMicrokernelTester()
59 .p(p)
60 .c(c)
61 .Test(xnn_x32_unpool_ukernel__neon);
62 }
63 }
64 }
65
TEST(X32_UNPOOL__NEON,varying_f)66 TEST(X32_UNPOOL__NEON, varying_f) {
67 TEST_REQUIRES_ARM_NEON;
68 for (size_t c = 1; c < 32; c += 5) {
69 UnpoolMicrokernelTester()
70 .p(10)
71 .c(c)
72 .f(0xDEADBEAF)
73 .Test(xnn_x32_unpool_ukernel__neon);
74 }
75 }
76
TEST(X32_UNPOOL__NEON,y_stride)77 TEST(X32_UNPOOL__NEON, y_stride) {
78 TEST_REQUIRES_ARM_NEON;
79 for (size_t c = 1; c < 32; c += 5) {
80 UnpoolMicrokernelTester()
81 .p(10)
82 .c(c)
83 .y_stride(c * 2 + 7)
84 .Test(xnn_x32_unpool_ukernel__neon);
85 }
86 }
87 #endif // XNN_ARCH_ARM || XNN_ARCH_ARM64
88
89
90 #if XNN_ARCH_X86 || XNN_ARCH_X86_64
TEST(X32_UNPOOL__SSE2,c_eq_4)91 TEST(X32_UNPOOL__SSE2, c_eq_4) {
92 TEST_REQUIRES_X86_SSE2;
93 UnpoolMicrokernelTester()
94 .p(10)
95 .c(4)
96 .Test(xnn_x32_unpool_ukernel__sse2);
97 }
98
TEST(X32_UNPOOL__SSE2,c_div_4)99 TEST(X32_UNPOOL__SSE2, c_div_4) {
100 TEST_REQUIRES_X86_SSE2;
101 for (size_t c = 8; c < 32; c += 4) {
102 UnpoolMicrokernelTester()
103 .p(10)
104 .c(c)
105 .Test(xnn_x32_unpool_ukernel__sse2);
106 }
107 }
108
TEST(X32_UNPOOL__SSE2,c_lt_4)109 TEST(X32_UNPOOL__SSE2, c_lt_4) {
110 TEST_REQUIRES_X86_SSE2;
111 for (size_t c = 1; c < 4; c++) {
112 UnpoolMicrokernelTester()
113 .p(10)
114 .c(c)
115 .Test(xnn_x32_unpool_ukernel__sse2);
116 }
117 }
118
TEST(X32_UNPOOL__SSE2,c_gt_4)119 TEST(X32_UNPOOL__SSE2, c_gt_4) {
120 TEST_REQUIRES_X86_SSE2;
121 for (size_t c = 5; c < 8; c++) {
122 UnpoolMicrokernelTester()
123 .p(10)
124 .c(4)
125 .Test(xnn_x32_unpool_ukernel__sse2);
126 }
127 }
128
TEST(X32_UNPOOL__SSE2,varying_p)129 TEST(X32_UNPOOL__SSE2, varying_p) {
130 TEST_REQUIRES_X86_SSE2;
131 for (size_t p = 1; p < 20; p += 3) {
132 for (size_t c = 1; c < 32; c += 5) {
133 UnpoolMicrokernelTester()
134 .p(p)
135 .c(c)
136 .Test(xnn_x32_unpool_ukernel__sse2);
137 }
138 }
139 }
140
TEST(X32_UNPOOL__SSE2,varying_f)141 TEST(X32_UNPOOL__SSE2, varying_f) {
142 TEST_REQUIRES_X86_SSE2;
143 for (size_t c = 1; c < 32; c += 5) {
144 UnpoolMicrokernelTester()
145 .p(10)
146 .c(c)
147 .f(0xDEADBEAF)
148 .Test(xnn_x32_unpool_ukernel__sse2);
149 }
150 }
151
TEST(X32_UNPOOL__SSE2,y_stride)152 TEST(X32_UNPOOL__SSE2, y_stride) {
153 TEST_REQUIRES_X86_SSE2;
154 for (size_t c = 1; c < 32; c += 5) {
155 UnpoolMicrokernelTester()
156 .p(10)
157 .c(c)
158 .y_stride(c * 2 + 7)
159 .Test(xnn_x32_unpool_ukernel__sse2);
160 }
161 }
162 #endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
163
164
165 #if XNN_ARCH_WASMSIMD
TEST(X32_UNPOOL__WASMSIMD,c_eq_4)166 TEST(X32_UNPOOL__WASMSIMD, c_eq_4) {
167 UnpoolMicrokernelTester()
168 .p(10)
169 .c(4)
170 .Test(xnn_x32_unpool_ukernel__wasmsimd);
171 }
172
TEST(X32_UNPOOL__WASMSIMD,c_div_4)173 TEST(X32_UNPOOL__WASMSIMD, c_div_4) {
174 for (size_t c = 8; c < 32; c += 4) {
175 UnpoolMicrokernelTester()
176 .p(10)
177 .c(c)
178 .Test(xnn_x32_unpool_ukernel__wasmsimd);
179 }
180 }
181
TEST(X32_UNPOOL__WASMSIMD,c_lt_4)182 TEST(X32_UNPOOL__WASMSIMD, c_lt_4) {
183 for (size_t c = 1; c < 4; c++) {
184 UnpoolMicrokernelTester()
185 .p(10)
186 .c(c)
187 .Test(xnn_x32_unpool_ukernel__wasmsimd);
188 }
189 }
190
TEST(X32_UNPOOL__WASMSIMD,c_gt_4)191 TEST(X32_UNPOOL__WASMSIMD, c_gt_4) {
192 for (size_t c = 5; c < 8; c++) {
193 UnpoolMicrokernelTester()
194 .p(10)
195 .c(4)
196 .Test(xnn_x32_unpool_ukernel__wasmsimd);
197 }
198 }
199
TEST(X32_UNPOOL__WASMSIMD,varying_p)200 TEST(X32_UNPOOL__WASMSIMD, varying_p) {
201 for (size_t p = 1; p < 20; p += 3) {
202 for (size_t c = 1; c < 32; c += 5) {
203 UnpoolMicrokernelTester()
204 .p(p)
205 .c(c)
206 .Test(xnn_x32_unpool_ukernel__wasmsimd);
207 }
208 }
209 }
210
TEST(X32_UNPOOL__WASMSIMD,varying_f)211 TEST(X32_UNPOOL__WASMSIMD, varying_f) {
212 for (size_t c = 1; c < 32; c += 5) {
213 UnpoolMicrokernelTester()
214 .p(10)
215 .c(c)
216 .f(0xDEADBEAF)
217 .Test(xnn_x32_unpool_ukernel__wasmsimd);
218 }
219 }
220
TEST(X32_UNPOOL__WASMSIMD,y_stride)221 TEST(X32_UNPOOL__WASMSIMD, y_stride) {
222 for (size_t c = 1; c < 32; c += 5) {
223 UnpoolMicrokernelTester()
224 .p(10)
225 .c(c)
226 .y_stride(c * 2 + 7)
227 .Test(xnn_x32_unpool_ukernel__wasmsimd);
228 }
229 }
230 #endif // XNN_ARCH_WASMSIMD
231
232
TEST(X32_UNPOOL__SCALAR,c_eq_1)233 TEST(X32_UNPOOL__SCALAR, c_eq_1) {
234 UnpoolMicrokernelTester()
235 .p(10)
236 .c(1)
237 .Test(xnn_x32_unpool_ukernel__scalar);
238 }
239
TEST(X32_UNPOOL__SCALAR,c_gt_1)240 TEST(X32_UNPOOL__SCALAR, c_gt_1) {
241 for (size_t c = 2; c < 16; c++) {
242 UnpoolMicrokernelTester()
243 .p(10)
244 .c(c)
245 .Test(xnn_x32_unpool_ukernel__scalar);
246 }
247 }
248
TEST(X32_UNPOOL__SCALAR,varying_p)249 TEST(X32_UNPOOL__SCALAR, varying_p) {
250 for (size_t p = 1; p < 20; p += 3) {
251 for (size_t c = 1; c < 16; c += 3) {
252 UnpoolMicrokernelTester()
253 .p(p)
254 .c(c)
255 .Test(xnn_x32_unpool_ukernel__scalar);
256 }
257 }
258 }
259
TEST(X32_UNPOOL__SCALAR,varying_f)260 TEST(X32_UNPOOL__SCALAR, varying_f) {
261 for (size_t c = 1; c < 16; c += 3) {
262 UnpoolMicrokernelTester()
263 .p(10)
264 .c(c)
265 .f(0xDEADBEAF)
266 .Test(xnn_x32_unpool_ukernel__scalar);
267 }
268 }
269
TEST(X32_UNPOOL__SCALAR,y_stride)270 TEST(X32_UNPOOL__SCALAR, y_stride) {
271 for (size_t c = 1; c < 16; c += 3) {
272 UnpoolMicrokernelTester()
273 .p(10)
274 .c(c)
275 .y_stride(c * 2 + 7)
276 .Test(xnn_x32_unpool_ukernel__scalar);
277 }
278 }
279