1 // Tencent is pleased to support the open source community by making ncnn available.
2 //
3 // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 //
5 // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 // in compliance with the License. You may obtain a copy of the License at
7 //
8 // https://opensource.org/licenses/BSD-3-Clause
9 //
10 // Unless required by applicable law or agreed to in writing, software distributed
11 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 // specific language governing permissions and limitations under the License.
14 
15 #include "layer/interp.h"
16 #include "testutil.h"
17 
test_interp(const ncnn::Mat & a,int resize_type,float height_scale,float width_scale,int output_height,int output_width)18 static int test_interp(const ncnn::Mat& a, int resize_type, float height_scale, float width_scale, int output_height, int output_width)
19 {
20     ncnn::ParamDict pd;
21     pd.set(0, resize_type);
22     pd.set(1, height_scale);
23     pd.set(2, width_scale);
24     pd.set(3, output_height);
25     pd.set(4, output_width);
26 
27     std::vector<ncnn::Mat> weights(0);
28 
29     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
30     if (ret != 0)
31     {
32         fprintf(stderr, "test_interp failed a.dims=%d a=(%d %d %d) resize_type=%d height_scale=%f width_scale=%f output_height=%d output_width=%d\n", a.dims, a.w, a.h, a.c, resize_type, height_scale, width_scale, output_height, output_width);
33     }
34 
35     return ret;
36 }
37 
test_interp_ref(const ncnn::Mat & a,int resize_type,int output_height,int output_width)38 static int test_interp_ref(const ncnn::Mat& a, int resize_type, int output_height, int output_width)
39 {
40     ncnn::ParamDict pd;
41     pd.set(0, resize_type);
42     pd.set(5, 1);
43 
44     std::vector<ncnn::Mat> as(2);
45     as[0] = a;
46     as[1] = ncnn::Mat(output_width, output_height, 1);
47 
48     std::vector<ncnn::Mat> weights(0);
49 
50     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, as);
51     if (ret != 0)
52     {
53         fprintf(stderr, "test_interp_ref failed a.dims=%d a=(%d %d %d) resize_type=%d output_height=%d output_width=%d\n", a.dims, a.w, a.h, a.c, resize_type, output_height, output_width);
54     }
55 
56     return ret;
57 }
58 
test_interp_align_corner(const ncnn::Mat & a,int resize_type,float height_scale,float width_scale,int output_height,int output_width,int align_corner)59 static int test_interp_align_corner(const ncnn::Mat& a, int resize_type, float height_scale, float width_scale, int output_height, int output_width, int align_corner)
60 {
61     ncnn::ParamDict pd;
62     pd.set(0, resize_type);
63     pd.set(1, height_scale);
64     pd.set(2, width_scale);
65     pd.set(3, output_height);
66     pd.set(4, output_width);
67     pd.set(6, align_corner);
68 
69     std::vector<ncnn::Mat> weights(0);
70 
71     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
72     if (ret != 0)
73     {
74         fprintf(stderr, "test_interp failed a.dims=%d a=(%d %d %d) resize_type=%d height_scale=%f width_scale=%f output_height=%d output_width=%d align_corner=%d\n", a.dims, a.w, a.h, a.c, resize_type, height_scale, width_scale, output_height, output_width, align_corner);
75     }
76 
77     return ret;
78 }
79 
test_interp(const ncnn::Mat & a,int resize_type,float width_scale,int output_width)80 static int test_interp(const ncnn::Mat& a, int resize_type, float width_scale, int output_width)
81 {
82     ncnn::ParamDict pd;
83     pd.set(0, resize_type);
84     pd.set(1, 1.f);
85     pd.set(2, width_scale);
86     pd.set(3, 0);
87     pd.set(4, output_width);
88 
89     std::vector<ncnn::Mat> weights(0);
90 
91     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
92     if (ret != 0)
93     {
94         fprintf(stderr, "test_interp failed a.dims=%d a=(%d %d %d) resize_type=%d width_scale=%f output_width=%d\n", a.dims, a.w, a.h, a.c, resize_type, width_scale, output_width);
95     }
96 
97     return ret;
98 }
99 
test_interp_ref(const ncnn::Mat & a,int resize_type,int output_width)100 static int test_interp_ref(const ncnn::Mat& a, int resize_type, int output_width)
101 {
102     ncnn::ParamDict pd;
103     pd.set(0, resize_type);
104     pd.set(5, 1);
105 
106     std::vector<ncnn::Mat> as(2);
107     as[0] = a;
108     as[1] = ncnn::Mat(output_width, 1);
109 
110     std::vector<ncnn::Mat> weights(0);
111 
112     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, as);
113     if (ret != 0)
114     {
115         fprintf(stderr, "test_interp_ref failed a.dims=%d a=(%d %d %d) resize_type=%d output_width=%d\n", a.dims, a.w, a.h, a.c, resize_type, output_width);
116     }
117 
118     return ret;
119 }
120 
test_interp_align_corner(const ncnn::Mat & a,int resize_type,float width_scale,int output_width,int align_corner)121 static int test_interp_align_corner(const ncnn::Mat& a, int resize_type, float width_scale, int output_width, int align_corner)
122 {
123     ncnn::ParamDict pd;
124     pd.set(0, resize_type);
125     pd.set(1, 1.f);
126     pd.set(2, width_scale);
127     pd.set(3, 0);
128     pd.set(4, output_width);
129     pd.set(6, align_corner);
130 
131     std::vector<ncnn::Mat> weights(0);
132 
133     int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
134     if (ret != 0)
135     {
136         fprintf(stderr, "test_interp failed a.dims=%d a=(%d %d %d) resize_type=%d width_scale=%f output_width=%d align_corner=%d\n", a.dims, a.w, a.h, a.c, resize_type, width_scale, output_width, align_corner);
137     }
138 
139     return ret;
140 }
141 
test_interp_0()142 static int test_interp_0()
143 {
144     ncnn::Mat a = RandomMat(15, 16, 7);
145     ncnn::Mat b = RandomMat(14, 17, 12);
146     ncnn::Mat c = RandomMat(13, 14, 24);
147 
148     return 0
149            || test_interp(a, 1, 2.f, 2.f, 0, 0)
150            || test_interp(a, 1, 4.f, 0.5f, 0, 0)
151            || test_interp(a, 1, 1.2f, 1.2f, 0, 0)
152            || test_interp(a, 1, 0.8f, 0.8f, 0, 0)
153            || test_interp(a, 1, 1.f, 1.f, 10, 12)
154            || test_interp(a, 1, 1.f, 1.f, 2, 2)
155            || test_interp(a, 1, 1.f, 1.f, 15, 16)
156            || test_interp_ref(a, 1, 10, 12)
157            || test_interp_ref(a, 1, 2, 2)
158            || test_interp_ref(a, 1, 15, 16)
159 
160            || test_interp(b, 1, 2.f, 2.f, 0, 0)
161            || test_interp(b, 1, 4.f, 0.5f, 0, 0)
162            || test_interp(b, 1, 1.2f, 1.2f, 0, 0)
163            || test_interp(b, 1, 0.8f, 0.8f, 0, 0)
164            || test_interp(b, 1, 1.f, 1.f, 10, 12)
165            || test_interp(b, 1, 1.f, 1.f, 2, 2)
166            || test_interp(b, 1, 1.f, 1.f, 14, 17)
167            || test_interp_ref(b, 1, 10, 12)
168            || test_interp_ref(b, 1, 2, 2)
169            || test_interp_ref(b, 1, 14, 17)
170 
171            || test_interp(c, 1, 2.f, 2.f, 0, 0)
172            || test_interp(c, 1, 4.f, 0.5f, 0, 0)
173            || test_interp(c, 1, 1.2f, 1.2f, 0, 0)
174            || test_interp(c, 1, 0.8f, 0.8f, 0, 0)
175            || test_interp(c, 1, 1.f, 1.f, 10, 12)
176            || test_interp(c, 1, 1.f, 1.f, 2, 2)
177            || test_interp(c, 1, 1.f, 1.f, 14, 17)
178            || test_interp_ref(c, 1, 10, 12)
179            || test_interp_ref(c, 1, 2, 2)
180            || test_interp_ref(c, 1, 14, 17);
181 }
182 
test_interp_1()183 static int test_interp_1()
184 {
185     ncnn::Mat a = RandomMat(15, 16, 7);
186     ncnn::Mat b = RandomMat(14, 17, 12);
187     ncnn::Mat c = RandomMat(13, 14, 24);
188 
189     return 0
190            || test_interp(a, 2, 2.f, 2.f, 0, 0)
191            || test_interp(a, 2, 4.f, 0.5f, 0, 0)
192            || test_interp(a, 2, 1.2f, 1.2f, 0, 0)
193            || test_interp(a, 2, 0.8f, 0.8f, 0, 0)
194            || test_interp(a, 2, 1.f, 1.f, 10, 12)
195            || test_interp(a, 2, 1.f, 1.f, 2, 2)
196            || test_interp(a, 2, 1.f, 1.f, 15, 16)
197            || test_interp_align_corner(a, 2, 2.f, 2.f, 0, 0, 1)
198            || test_interp_align_corner(a, 2, 4.f, 0.5f, 0, 0, 1)
199            || test_interp_align_corner(a, 2, 1.2f, 1.2f, 0, 0, 1)
200            || test_interp_align_corner(a, 2, 0.8f, 0.8f, 0, 0, 1)
201            || test_interp_align_corner(a, 2, 1.f, 1.f, 10, 12, 1)
202            || test_interp_align_corner(a, 2, 1.f, 1.f, 2, 2, 1)
203            || test_interp_align_corner(a, 2, 1.f, 1.f, 15, 16, 1)
204            || test_interp_ref(a, 2, 10, 12)
205            || test_interp_ref(a, 2, 2, 2)
206            || test_interp_ref(a, 2, 15, 16)
207 
208            || test_interp(b, 2, 2.f, 2.f, 0, 0)
209            || test_interp(b, 2, 4.f, 0.5f, 0, 0)
210            || test_interp(b, 2, 1.2f, 1.2f, 0, 0)
211            || test_interp(b, 2, 0.8f, 0.8f, 0, 0)
212            || test_interp(b, 2, 1.f, 1.f, 10, 12)
213            || test_interp(b, 2, 1.f, 1.f, 2, 2)
214            || test_interp(b, 2, 1.f, 1.f, 14, 17)
215            || test_interp_align_corner(b, 2, 2.f, 2.f, 0, 0, 1)
216            || test_interp_align_corner(b, 2, 4.f, 0.5f, 0, 0, 1)
217            || test_interp_align_corner(b, 2, 1.2f, 1.2f, 0, 0, 1)
218            || test_interp_align_corner(b, 2, 0.8f, 0.8f, 0, 0, 1)
219            || test_interp_align_corner(b, 2, 1.f, 1.f, 10, 12, 1)
220            || test_interp_align_corner(b, 2, 1.f, 1.f, 2, 2, 1)
221            || test_interp_align_corner(b, 2, 1.f, 1.f, 14, 17, 1)
222            || test_interp_ref(b, 2, 10, 12)
223            || test_interp_ref(b, 2, 2, 2)
224            || test_interp_ref(b, 2, 14, 17)
225 
226            || test_interp(c, 2, 2.f, 2.f, 0, 0)
227            || test_interp(c, 2, 4.f, 0.5f, 0, 0)
228            || test_interp(c, 2, 1.2f, 1.2f, 0, 0)
229            || test_interp(c, 2, 0.8f, 0.8f, 0, 0)
230            || test_interp(c, 2, 1.f, 1.f, 10, 12)
231            || test_interp(c, 2, 1.f, 1.f, 2, 2)
232            || test_interp(c, 2, 1.f, 1.f, 14, 17)
233            || test_interp_align_corner(c, 2, 2.f, 2.f, 0, 0, 1)
234            || test_interp_align_corner(c, 2, 4.f, 0.5f, 0, 0, 1)
235            || test_interp_align_corner(c, 2, 1.2f, 1.2f, 0, 0, 1)
236            || test_interp_align_corner(c, 2, 0.8f, 0.8f, 0, 0, 1)
237            || test_interp_align_corner(c, 2, 1.f, 1.f, 10, 12, 1)
238            || test_interp_align_corner(c, 2, 1.f, 1.f, 2, 2, 1)
239            || test_interp_align_corner(c, 2, 1.f, 1.f, 14, 17, 1)
240            || test_interp_ref(c, 2, 10, 12)
241            || test_interp_ref(c, 2, 2, 2)
242            || test_interp_ref(c, 2, 14, 17);
243 }
244 
test_interp_2()245 static int test_interp_2()
246 {
247     ncnn::Mat a = RandomMat(16, 17, 13);
248     ncnn::Mat b = RandomMat(18, 19, 12);
249     ncnn::Mat c = RandomMat(13, 14, 24);
250 
251     return 0
252            || test_interp(a, 3, 2.f, 2.f, 0, 0)
253            || test_interp(a, 3, 4.f, 0.5f, 0, 0)
254            || test_interp(a, 3, 1.2f, 1.2f, 0, 0)
255            || test_interp(a, 3, 0.8f, 0.8f, 0, 0)
256            || test_interp(a, 3, 1.f, 1.f, 10, 12)
257            || test_interp(a, 3, 1.f, 1.f, 2, 2)
258            || test_interp(a, 3, 1.f, 1.f, 6, 7)
259            || test_interp(a, 3, 1.f, 1.f, 16, 17)
260            || test_interp_align_corner(a, 3, 2.f, 2.f, 0, 0, 1)
261            || test_interp_align_corner(a, 3, 4.f, 0.5f, 0, 0, 1)
262            || test_interp_align_corner(a, 3, 1.2f, 1.2f, 0, 0, 1)
263            || test_interp_align_corner(a, 3, 0.8f, 0.8f, 0, 0, 1)
264            || test_interp_align_corner(a, 3, 1.f, 1.f, 10, 12, 1)
265            || test_interp_align_corner(a, 3, 1.f, 1.f, 2, 2, 1)
266            || test_interp_align_corner(a, 3, 1.f, 1.f, 6, 7, 1)
267            || test_interp_align_corner(a, 3, 1.f, 1.f, 16, 17, 1)
268            || test_interp_ref(a, 3, 2, 2)
269            || test_interp_ref(a, 3, 6, 7)
270            || test_interp_ref(a, 3, 16, 17)
271 
272            || test_interp(b, 3, 2.f, 2.f, 0, 0)
273            || test_interp(b, 3, 4.f, 0.5f, 0, 0)
274            || test_interp(b, 3, 1.2f, 1.2f, 0, 0)
275            || test_interp(b, 3, 0.8f, 0.8f, 0, 0)
276            || test_interp(b, 3, 1.f, 1.f, 10, 12)
277            || test_interp(b, 3, 1.f, 1.f, 2, 2)
278            || test_interp(b, 3, 1.f, 1.f, 6, 7)
279            || test_interp(b, 3, 1.f, 1.f, 18, 19)
280            || test_interp_align_corner(b, 3, 2.f, 2.f, 0, 0, 1)
281            || test_interp_align_corner(b, 3, 4.f, 0.5f, 0, 0, 1)
282            || test_interp_align_corner(b, 3, 1.2f, 1.2f, 0, 0, 1)
283            || test_interp_align_corner(b, 3, 0.8f, 0.8f, 0, 0, 1)
284            || test_interp_align_corner(b, 3, 1.f, 1.f, 10, 12, 1)
285            || test_interp_align_corner(b, 3, 1.f, 1.f, 2, 2, 1)
286            || test_interp_align_corner(b, 3, 1.f, 1.f, 6, 7, 1)
287            || test_interp_align_corner(b, 3, 1.f, 1.f, 18, 19, 1)
288            || test_interp_ref(b, 3, 2, 2)
289            || test_interp_ref(b, 3, 6, 7)
290            || test_interp_ref(b, 3, 18, 19)
291 
292            || test_interp(c, 3, 2.f, 2.f, 0, 0)
293            || test_interp(c, 3, 4.f, 0.5f, 0, 0)
294            || test_interp(c, 3, 1.2f, 1.2f, 0, 0)
295            || test_interp(c, 3, 0.8f, 0.8f, 0, 0)
296            || test_interp(c, 3, 1.f, 1.f, 10, 12)
297            || test_interp(c, 3, 1.f, 1.f, 2, 2)
298            || test_interp(c, 3, 1.f, 1.f, 6, 7)
299            || test_interp(c, 3, 1.f, 1.f, 18, 19)
300            || test_interp_align_corner(c, 3, 2.f, 2.f, 0, 0, 1)
301            || test_interp_align_corner(c, 3, 4.f, 0.5f, 0, 0, 1)
302            || test_interp_align_corner(c, 3, 1.2f, 1.2f, 0, 0, 1)
303            || test_interp_align_corner(c, 3, 0.8f, 0.8f, 0, 0, 1)
304            || test_interp_align_corner(c, 3, 1.f, 1.f, 10, 12, 1)
305            || test_interp_align_corner(c, 3, 1.f, 1.f, 2, 2, 1)
306            || test_interp_align_corner(c, 3, 1.f, 1.f, 6, 7, 1)
307            || test_interp_align_corner(c, 3, 1.f, 1.f, 18, 19, 1)
308            || test_interp_ref(c, 3, 2, 2)
309            || test_interp_ref(c, 3, 6, 7)
310            || test_interp_ref(c, 3, 18, 19);
311 }
312 
test_interp_3()313 static int test_interp_3()
314 {
315     ncnn::Mat a = RandomMat(15, 7);
316     ncnn::Mat b = RandomMat(14, 12);
317     ncnn::Mat c = RandomMat(13, 24);
318 
319     return 0
320            || test_interp(a, 1, 2.f, 0)
321            || test_interp(a, 1, 0.5f, 0)
322            || test_interp(a, 1, 1.2f, 0)
323            || test_interp(a, 1, 0.8f, 0)
324            || test_interp(a, 1, 1.f, 12)
325            || test_interp(a, 1, 1.f, 2)
326            || test_interp(a, 1, 1.f, 16)
327            || test_interp_ref(a, 1, 12)
328            || test_interp_ref(a, 1, 2)
329            || test_interp_ref(a, 1, 16)
330 
331            || test_interp(b, 1, 2.f, 0)
332            || test_interp(b, 1, 0.5f, 0)
333            || test_interp(b, 1, 1.2f, 0)
334            || test_interp(b, 1, 0.8f, 0)
335            || test_interp(b, 1, 1.f, 12)
336            || test_interp(b, 1, 1.f, 2)
337            || test_interp(b, 1, 1.f, 17)
338            || test_interp_ref(b, 1, 12)
339            || test_interp_ref(b, 1, 2)
340            || test_interp_ref(b, 1, 17)
341 
342            || test_interp(c, 1, 2.f, 0)
343            || test_interp(c, 1, 0.5f, 0)
344            || test_interp(c, 1, 1.2f, 0)
345            || test_interp(c, 1, 0.8f, 0)
346            || test_interp(c, 1, 1.f, 12)
347            || test_interp(c, 1, 1.f, 2)
348            || test_interp(c, 1, 1.f, 17)
349            || test_interp_ref(c, 1, 12)
350            || test_interp_ref(c, 1, 2)
351            || test_interp_ref(c, 1, 17);
352 }
353 
test_interp_4()354 static int test_interp_4()
355 {
356     ncnn::Mat a = RandomMat(15, 7);
357     ncnn::Mat b = RandomMat(14, 12);
358     ncnn::Mat c = RandomMat(13, 24);
359 
360     return 0
361            || test_interp(a, 2, 2.f, 0)
362            || test_interp(a, 2, 0.5f, 0)
363            || test_interp(a, 2, 1.2f, 0)
364            || test_interp(a, 2, 0.8f, 0)
365            || test_interp(a, 2, 1.f, 12)
366            || test_interp(a, 2, 1.f, 2)
367            || test_interp(a, 2, 1.f, 16)
368            || test_interp_align_corner(a, 2, 2.f, 0, 1)
369            || test_interp_align_corner(a, 2, 0.5f, 0, 1)
370            || test_interp_align_corner(a, 2, 1.2f, 0, 1)
371            || test_interp_align_corner(a, 2, 0.8f, 0, 1)
372            || test_interp_align_corner(a, 2, 1.f, 12, 1)
373            || test_interp_align_corner(a, 2, 1.f, 2, 1)
374            || test_interp_align_corner(a, 2, 1.f, 16, 1)
375            || test_interp_ref(a, 2, 12)
376            || test_interp_ref(a, 2, 2)
377            || test_interp_ref(a, 2, 16)
378 
379            || test_interp(b, 2, 2.f, 0)
380            || test_interp(b, 2, 0.5f, 0)
381            || test_interp(b, 2, 1.2f, 0)
382            || test_interp(b, 2, 0.8f, 0)
383            || test_interp(b, 2, 1.f, 12)
384            || test_interp(b, 2, 1.f, 2)
385            || test_interp(b, 2, 1.f, 17)
386            || test_interp_align_corner(b, 2, 2.f, 0, 1)
387            || test_interp_align_corner(b, 2, 0.5f, 0, 1)
388            || test_interp_align_corner(b, 2, 1.2f, 0, 1)
389            || test_interp_align_corner(b, 2, 0.8f, 0, 1)
390            || test_interp_align_corner(b, 2, 1.f, 12, 1)
391            || test_interp_align_corner(b, 2, 1.f, 2, 1)
392            || test_interp_align_corner(b, 2, 1.f, 17, 1)
393            || test_interp_ref(b, 2, 12)
394            || test_interp_ref(b, 2, 2)
395            || test_interp_ref(b, 2, 17)
396 
397            || test_interp(c, 2, 2.f, 0)
398            || test_interp(c, 2, 0.5f, 0)
399            || test_interp(c, 2, 1.2f, 0)
400            || test_interp(c, 2, 0.8f, 0)
401            || test_interp(c, 2, 1.f, 12)
402            || test_interp(c, 2, 1.f, 2)
403            || test_interp(c, 2, 1.f, 17)
404            || test_interp_align_corner(c, 2, 2.f, 0, 1)
405            || test_interp_align_corner(c, 2, 0.5f, 0, 1)
406            || test_interp_align_corner(c, 2, 1.2f, 0, 1)
407            || test_interp_align_corner(c, 2, 0.8f, 0, 1)
408            || test_interp_align_corner(c, 2, 1.f, 12, 1)
409            || test_interp_align_corner(c, 2, 1.f, 2, 1)
410            || test_interp_align_corner(c, 2, 1.f, 17, 1)
411            || test_interp_ref(c, 2, 12)
412            || test_interp_ref(c, 2, 2)
413            || test_interp_ref(c, 2, 17);
414 }
415 
test_interp_5()416 static int test_interp_5()
417 {
418     ncnn::Mat a = RandomMat(16, 13);
419     ncnn::Mat b = RandomMat(18, 12);
420     ncnn::Mat c = RandomMat(13, 24);
421 
422     return 0
423            || test_interp(a, 3, 2.f, 0)
424            || test_interp(a, 3, 0.5f, 0)
425            || test_interp(a, 3, 1.2f, 0)
426            || test_interp(a, 3, 0.8f, 0)
427            || test_interp(a, 3, 1.f, 12)
428            || test_interp(a, 3, 1.f, 2)
429            || test_interp(a, 3, 1.f, 7)
430            || test_interp(a, 3, 1.f, 17)
431            || test_interp_align_corner(a, 3, 2.f, 0, 1)
432            || test_interp_align_corner(a, 3, 0.5f, 0, 1)
433            || test_interp_align_corner(a, 3, 1.2f, 0, 1)
434            || test_interp_align_corner(a, 3, 0.8f, 0, 1)
435            || test_interp_align_corner(a, 3, 1.f, 12, 1)
436            || test_interp_align_corner(a, 3, 1.f, 2, 1)
437            || test_interp_align_corner(a, 3, 1.f, 7, 1)
438            || test_interp_align_corner(a, 3, 1.f, 17, 1)
439            || test_interp_ref(a, 3, 2)
440            || test_interp_ref(a, 3, 7)
441            || test_interp_ref(a, 3, 17)
442 
443            || test_interp(b, 3, 2.f, 0)
444            || test_interp(b, 3, 0.5f, 0)
445            || test_interp(b, 3, 1.2f, 0)
446            || test_interp(b, 3, 0.8f, 0)
447            || test_interp(b, 3, 1.f, 12)
448            || test_interp(b, 3, 1.f, 2)
449            || test_interp(b, 3, 1.f, 7)
450            || test_interp(b, 3, 1.f, 19)
451            || test_interp_align_corner(b, 3, 2.f, 0, 1)
452            || test_interp_align_corner(b, 3, 0.5f, 0, 1)
453            || test_interp_align_corner(b, 3, 1.2f, 0, 1)
454            || test_interp_align_corner(b, 3, 0.8f, 0, 1)
455            || test_interp_align_corner(b, 3, 1.f, 12, 1)
456            || test_interp_align_corner(b, 3, 1.f, 2, 1)
457            || test_interp_align_corner(b, 3, 1.f, 7, 1)
458            || test_interp_align_corner(b, 3, 1.f, 19, 1)
459            || test_interp_ref(b, 3, 2)
460            || test_interp_ref(b, 3, 7)
461            || test_interp_ref(b, 3, 19)
462 
463            || test_interp(c, 3, 2.f, 0)
464            || test_interp(c, 3, 0.5f, 0)
465            || test_interp(c, 3, 1.2f, 0)
466            || test_interp(c, 3, 0.8f, 0)
467            || test_interp(c, 3, 1.f, 12)
468            || test_interp(c, 3, 1.f, 2)
469            || test_interp(c, 3, 1.f, 7)
470            || test_interp(c, 3, 1.f, 19)
471            || test_interp_align_corner(c, 3, 2.f, 0, 1)
472            || test_interp_align_corner(c, 3, 0.5f, 0, 1)
473            || test_interp_align_corner(c, 3, 1.2f, 0, 1)
474            || test_interp_align_corner(c, 3, 0.8f, 0, 1)
475            || test_interp_align_corner(c, 3, 1.f, 12, 1)
476            || test_interp_align_corner(c, 3, 1.f, 2, 1)
477            || test_interp_align_corner(c, 3, 1.f, 7, 1)
478            || test_interp_align_corner(c, 3, 1.f, 19, 1)
479            || test_interp_ref(c, 3, 2)
480            || test_interp_ref(c, 3, 7)
481            || test_interp_ref(c, 3, 19);
482 }
483 
test_interp_6()484 static int test_interp_6()
485 {
486     ncnn::Mat a = RandomMat(17);
487     ncnn::Mat b = RandomMat(20);
488     ncnn::Mat c = RandomMat(48);
489 
490     return 0
491            || test_interp(a, 1, 2.f, 3.f, 0, 0)
492            || test_interp(a, 1, 1.f, 1.f, 10, 12)
493            || test_interp(a, 1, 1.f, 1.f, 15, 16)
494            || test_interp_ref(a, 1, 10, 12)
495            || test_interp_ref(a, 1, 4, 4)
496            || test_interp_ref(a, 1, 15, 16)
497 
498            || test_interp(b, 1, 4.f, 5.f, 0, 0)
499            || test_interp(b, 1, 1.f, 1.f, 10, 12)
500            || test_interp(b, 1, 1.f, 1.f, 14, 17)
501            || test_interp_ref(b, 1, 5, 5)
502            || test_interp_ref(b, 1, 14, 17)
503 
504            || test_interp(c, 1, 6.f, 7.f, 0, 0)
505            || test_interp(c, 1, 1.f, 1.f, 10, 12)
506            || test_interp(c, 1, 1.f, 1.f, 14, 17)
507            || test_interp_ref(c, 1, 6, 6)
508            || test_interp_ref(c, 1, 14, 17);
509 }
510 
main()511 int main()
512 {
513     SRAND(7767517);
514 
515     return 0
516            || test_interp_0()
517            || test_interp_1()
518            || test_interp_2()
519            || test_interp_3()
520            || test_interp_4()
521            || test_interp_5()
522            || test_interp_6();
523 }
524