You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_interp.cpp 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. #include "layer/interp.h"
  15. #include "testutil.h"
  16. static int test_interp(const ncnn::Mat& a, int resize_type, float height_scale, float width_scale, int output_height, int output_width)
  17. {
  18. ncnn::ParamDict pd;
  19. pd.set(0, resize_type);
  20. pd.set(1, height_scale);
  21. pd.set(2, width_scale);
  22. pd.set(3, output_height);
  23. pd.set(4, output_width);
  24. std::vector<ncnn::Mat> weights(0);
  25. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
  26. if (ret != 0)
  27. {
  28. 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);
  29. }
  30. return ret;
  31. }
  32. static int test_interp_ref(const ncnn::Mat& a, int resize_type, int output_height, int output_width)
  33. {
  34. ncnn::ParamDict pd;
  35. pd.set(0, resize_type);
  36. pd.set(5, 1);
  37. std::vector<ncnn::Mat> as(2);
  38. as[0] = a;
  39. as[1] = ncnn::Mat(output_width, output_height, 1);
  40. std::vector<ncnn::Mat> weights(0);
  41. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, as);
  42. if (ret != 0)
  43. {
  44. 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);
  45. }
  46. return ret;
  47. }
  48. 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)
  49. {
  50. ncnn::ParamDict pd;
  51. pd.set(0, resize_type);
  52. pd.set(1, height_scale);
  53. pd.set(2, width_scale);
  54. pd.set(3, output_height);
  55. pd.set(4, output_width);
  56. pd.set(6, align_corner);
  57. std::vector<ncnn::Mat> weights(0);
  58. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
  59. if (ret != 0)
  60. {
  61. 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);
  62. }
  63. return ret;
  64. }
  65. static int test_interp(const ncnn::Mat& a, int resize_type, float width_scale, int output_width)
  66. {
  67. ncnn::ParamDict pd;
  68. pd.set(0, resize_type);
  69. pd.set(1, 1.f);
  70. pd.set(2, width_scale);
  71. pd.set(3, 0);
  72. pd.set(4, output_width);
  73. std::vector<ncnn::Mat> weights(0);
  74. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
  75. if (ret != 0)
  76. {
  77. 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);
  78. }
  79. return ret;
  80. }
  81. static int test_interp_ref(const ncnn::Mat& a, int resize_type, int output_width)
  82. {
  83. ncnn::ParamDict pd;
  84. pd.set(0, resize_type);
  85. pd.set(5, 1);
  86. std::vector<ncnn::Mat> as(2);
  87. as[0] = a;
  88. as[1] = ncnn::Mat(output_width, 1);
  89. std::vector<ncnn::Mat> weights(0);
  90. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, as);
  91. if (ret != 0)
  92. {
  93. 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);
  94. }
  95. return ret;
  96. }
  97. static int test_interp_align_corner(const ncnn::Mat& a, int resize_type, float width_scale, int output_width, int align_corner)
  98. {
  99. ncnn::ParamDict pd;
  100. pd.set(0, resize_type);
  101. pd.set(1, 1.f);
  102. pd.set(2, width_scale);
  103. pd.set(3, 0);
  104. pd.set(4, output_width);
  105. pd.set(6, align_corner);
  106. std::vector<ncnn::Mat> weights(0);
  107. int ret = test_layer<ncnn::Interp>("Interp", pd, weights, a);
  108. if (ret != 0)
  109. {
  110. 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);
  111. }
  112. return ret;
  113. }
  114. static int test_interp_0()
  115. {
  116. ncnn::Mat a = RandomMat(15, 16, 7);
  117. ncnn::Mat b = RandomMat(14, 17, 12);
  118. ncnn::Mat c = RandomMat(13, 14, 24);
  119. return 0
  120. || test_interp(a, 1, 2.f, 2.f, 0, 0)
  121. || test_interp(a, 1, 4.f, 0.5f, 0, 0)
  122. || test_interp(a, 1, 1.2f, 1.2f, 0, 0)
  123. || test_interp(a, 1, 0.8f, 0.8f, 0, 0)
  124. || test_interp(a, 1, 1.f, 1.f, 10, 12)
  125. || test_interp(a, 1, 1.f, 1.f, 2, 2)
  126. || test_interp(a, 1, 1.f, 1.f, 15, 16)
  127. || test_interp_ref(a, 1, 10, 12)
  128. || test_interp_ref(a, 1, 2, 2)
  129. || test_interp_ref(a, 1, 15, 16)
  130. || test_interp(b, 1, 2.f, 2.f, 0, 0)
  131. || test_interp(b, 1, 4.f, 0.5f, 0, 0)
  132. || test_interp(b, 1, 1.2f, 1.2f, 0, 0)
  133. || test_interp(b, 1, 0.8f, 0.8f, 0, 0)
  134. || test_interp(b, 1, 1.f, 1.f, 10, 12)
  135. || test_interp(b, 1, 1.f, 1.f, 2, 2)
  136. || test_interp(b, 1, 1.f, 1.f, 14, 17)
  137. || test_interp_ref(b, 1, 10, 12)
  138. || test_interp_ref(b, 1, 2, 2)
  139. || test_interp_ref(b, 1, 14, 17)
  140. || test_interp(c, 1, 2.f, 2.f, 0, 0)
  141. || test_interp(c, 1, 4.f, 0.5f, 0, 0)
  142. || test_interp(c, 1, 1.2f, 1.2f, 0, 0)
  143. || test_interp(c, 1, 0.8f, 0.8f, 0, 0)
  144. || test_interp(c, 1, 1.f, 1.f, 10, 12)
  145. || test_interp(c, 1, 1.f, 1.f, 2, 2)
  146. || test_interp(c, 1, 1.f, 1.f, 14, 17)
  147. || test_interp_ref(c, 1, 10, 12)
  148. || test_interp_ref(c, 1, 2, 2)
  149. || test_interp_ref(c, 1, 14, 17);
  150. }
  151. static int test_interp_1()
  152. {
  153. ncnn::Mat a = RandomMat(15, 16, 7);
  154. ncnn::Mat b = RandomMat(14, 17, 12);
  155. ncnn::Mat c = RandomMat(13, 14, 24);
  156. return 0
  157. || test_interp(a, 2, 2.f, 2.f, 0, 0)
  158. || test_interp(a, 2, 4.f, 0.5f, 0, 0)
  159. || test_interp(a, 2, 1.2f, 1.2f, 0, 0)
  160. || test_interp(a, 2, 0.8f, 0.8f, 0, 0)
  161. || test_interp(a, 2, 1.f, 1.f, 10, 12)
  162. || test_interp(a, 2, 1.f, 1.f, 2, 2)
  163. || test_interp(a, 2, 1.f, 1.f, 15, 16)
  164. || test_interp_align_corner(a, 2, 2.f, 2.f, 0, 0, 1)
  165. || test_interp_align_corner(a, 2, 4.f, 0.5f, 0, 0, 1)
  166. || test_interp_align_corner(a, 2, 1.2f, 1.2f, 0, 0, 1)
  167. || test_interp_align_corner(a, 2, 0.8f, 0.8f, 0, 0, 1)
  168. || test_interp_align_corner(a, 2, 1.f, 1.f, 10, 12, 1)
  169. || test_interp_align_corner(a, 2, 1.f, 1.f, 2, 2, 1)
  170. || test_interp_align_corner(a, 2, 1.f, 1.f, 15, 16, 1)
  171. || test_interp_ref(a, 2, 10, 12)
  172. || test_interp_ref(a, 2, 2, 2)
  173. || test_interp_ref(a, 2, 15, 16)
  174. || test_interp(b, 2, 2.f, 2.f, 0, 0)
  175. || test_interp(b, 2, 4.f, 0.5f, 0, 0)
  176. || test_interp(b, 2, 1.2f, 1.2f, 0, 0)
  177. || test_interp(b, 2, 0.8f, 0.8f, 0, 0)
  178. || test_interp(b, 2, 1.f, 1.f, 10, 12)
  179. || test_interp(b, 2, 1.f, 1.f, 2, 2)
  180. || test_interp(b, 2, 1.f, 1.f, 14, 17)
  181. || test_interp_align_corner(b, 2, 2.f, 2.f, 0, 0, 1)
  182. || test_interp_align_corner(b, 2, 4.f, 0.5f, 0, 0, 1)
  183. || test_interp_align_corner(b, 2, 1.2f, 1.2f, 0, 0, 1)
  184. || test_interp_align_corner(b, 2, 0.8f, 0.8f, 0, 0, 1)
  185. || test_interp_align_corner(b, 2, 1.f, 1.f, 10, 12, 1)
  186. || test_interp_align_corner(b, 2, 1.f, 1.f, 2, 2, 1)
  187. || test_interp_align_corner(b, 2, 1.f, 1.f, 14, 17, 1)
  188. || test_interp_ref(b, 2, 10, 12)
  189. || test_interp_ref(b, 2, 2, 2)
  190. || test_interp_ref(b, 2, 14, 17)
  191. || test_interp(c, 2, 2.f, 2.f, 0, 0)
  192. || test_interp(c, 2, 4.f, 0.5f, 0, 0)
  193. || test_interp(c, 2, 1.2f, 1.2f, 0, 0)
  194. || test_interp(c, 2, 0.8f, 0.8f, 0, 0)
  195. || test_interp(c, 2, 1.f, 1.f, 10, 12)
  196. || test_interp(c, 2, 1.f, 1.f, 2, 2)
  197. || test_interp(c, 2, 1.f, 1.f, 14, 17)
  198. || test_interp_align_corner(c, 2, 2.f, 2.f, 0, 0, 1)
  199. || test_interp_align_corner(c, 2, 4.f, 0.5f, 0, 0, 1)
  200. || test_interp_align_corner(c, 2, 1.2f, 1.2f, 0, 0, 1)
  201. || test_interp_align_corner(c, 2, 0.8f, 0.8f, 0, 0, 1)
  202. || test_interp_align_corner(c, 2, 1.f, 1.f, 10, 12, 1)
  203. || test_interp_align_corner(c, 2, 1.f, 1.f, 2, 2, 1)
  204. || test_interp_align_corner(c, 2, 1.f, 1.f, 14, 17, 1)
  205. || test_interp_ref(c, 2, 10, 12)
  206. || test_interp_ref(c, 2, 2, 2)
  207. || test_interp_ref(c, 2, 14, 17);
  208. }
  209. static int test_interp_2()
  210. {
  211. ncnn::Mat a = RandomMat(16, 17, 13);
  212. ncnn::Mat b = RandomMat(18, 19, 12);
  213. ncnn::Mat c = RandomMat(13, 14, 24);
  214. return 0
  215. || test_interp(a, 3, 2.f, 2.f, 0, 0)
  216. || test_interp(a, 3, 4.f, 0.5f, 0, 0)
  217. || test_interp(a, 3, 1.2f, 1.2f, 0, 0)
  218. || test_interp(a, 3, 0.8f, 0.8f, 0, 0)
  219. || test_interp(a, 3, 1.f, 1.f, 10, 12)
  220. || test_interp(a, 3, 1.f, 1.f, 2, 2)
  221. || test_interp(a, 3, 1.f, 1.f, 6, 7)
  222. || test_interp(a, 3, 1.f, 1.f, 16, 17)
  223. || test_interp_align_corner(a, 3, 2.f, 2.f, 0, 0, 1)
  224. || test_interp_align_corner(a, 3, 4.f, 0.5f, 0, 0, 1)
  225. || test_interp_align_corner(a, 3, 1.2f, 1.2f, 0, 0, 1)
  226. || test_interp_align_corner(a, 3, 0.8f, 0.8f, 0, 0, 1)
  227. || test_interp_align_corner(a, 3, 1.f, 1.f, 10, 12, 1)
  228. || test_interp_align_corner(a, 3, 1.f, 1.f, 2, 2, 1)
  229. || test_interp_align_corner(a, 3, 1.f, 1.f, 6, 7, 1)
  230. || test_interp_align_corner(a, 3, 1.f, 1.f, 16, 17, 1)
  231. || test_interp_ref(a, 3, 2, 2)
  232. || test_interp_ref(a, 3, 6, 7)
  233. || test_interp_ref(a, 3, 16, 17)
  234. || test_interp(b, 3, 2.f, 2.f, 0, 0)
  235. || test_interp(b, 3, 4.f, 0.5f, 0, 0)
  236. || test_interp(b, 3, 1.2f, 1.2f, 0, 0)
  237. || test_interp(b, 3, 0.8f, 0.8f, 0, 0)
  238. || test_interp(b, 3, 1.f, 1.f, 10, 12)
  239. || test_interp(b, 3, 1.f, 1.f, 2, 2)
  240. || test_interp(b, 3, 1.f, 1.f, 6, 7)
  241. || test_interp(b, 3, 1.f, 1.f, 18, 19)
  242. || test_interp_align_corner(b, 3, 2.f, 2.f, 0, 0, 1)
  243. || test_interp_align_corner(b, 3, 4.f, 0.5f, 0, 0, 1)
  244. || test_interp_align_corner(b, 3, 1.2f, 1.2f, 0, 0, 1)
  245. || test_interp_align_corner(b, 3, 0.8f, 0.8f, 0, 0, 1)
  246. || test_interp_align_corner(b, 3, 1.f, 1.f, 10, 12, 1)
  247. || test_interp_align_corner(b, 3, 1.f, 1.f, 2, 2, 1)
  248. || test_interp_align_corner(b, 3, 1.f, 1.f, 6, 7, 1)
  249. || test_interp_align_corner(b, 3, 1.f, 1.f, 18, 19, 1)
  250. || test_interp_ref(b, 3, 2, 2)
  251. || test_interp_ref(b, 3, 6, 7)
  252. || test_interp_ref(b, 3, 18, 19)
  253. || test_interp(c, 3, 2.f, 2.f, 0, 0)
  254. || test_interp(c, 3, 4.f, 0.5f, 0, 0)
  255. || test_interp(c, 3, 1.2f, 1.2f, 0, 0)
  256. || test_interp(c, 3, 0.8f, 0.8f, 0, 0)
  257. || test_interp(c, 3, 1.f, 1.f, 10, 12)
  258. || test_interp(c, 3, 1.f, 1.f, 2, 2)
  259. || test_interp(c, 3, 1.f, 1.f, 6, 7)
  260. || test_interp(c, 3, 1.f, 1.f, 18, 19)
  261. || test_interp_align_corner(c, 3, 2.f, 2.f, 0, 0, 1)
  262. || test_interp_align_corner(c, 3, 4.f, 0.5f, 0, 0, 1)
  263. || test_interp_align_corner(c, 3, 1.2f, 1.2f, 0, 0, 1)
  264. || test_interp_align_corner(c, 3, 0.8f, 0.8f, 0, 0, 1)
  265. || test_interp_align_corner(c, 3, 1.f, 1.f, 10, 12, 1)
  266. || test_interp_align_corner(c, 3, 1.f, 1.f, 2, 2, 1)
  267. || test_interp_align_corner(c, 3, 1.f, 1.f, 6, 7, 1)
  268. || test_interp_align_corner(c, 3, 1.f, 1.f, 18, 19, 1)
  269. || test_interp_ref(c, 3, 2, 2)
  270. || test_interp_ref(c, 3, 6, 7)
  271. || test_interp_ref(c, 3, 18, 19);
  272. }
  273. static int test_interp_3()
  274. {
  275. ncnn::Mat a = RandomMat(15, 7);
  276. ncnn::Mat b = RandomMat(14, 12);
  277. ncnn::Mat c = RandomMat(13, 24);
  278. return 0
  279. || test_interp(a, 1, 2.f, 0)
  280. || test_interp(a, 1, 0.5f, 0)
  281. || test_interp(a, 1, 1.2f, 0)
  282. || test_interp(a, 1, 0.8f, 0)
  283. || test_interp(a, 1, 1.f, 12)
  284. || test_interp(a, 1, 1.f, 2)
  285. || test_interp(a, 1, 1.f, 16)
  286. || test_interp_ref(a, 1, 12)
  287. || test_interp_ref(a, 1, 2)
  288. || test_interp_ref(a, 1, 16)
  289. || test_interp(b, 1, 2.f, 0)
  290. || test_interp(b, 1, 0.5f, 0)
  291. || test_interp(b, 1, 1.2f, 0)
  292. || test_interp(b, 1, 0.8f, 0)
  293. || test_interp(b, 1, 1.f, 12)
  294. || test_interp(b, 1, 1.f, 2)
  295. || test_interp(b, 1, 1.f, 17)
  296. || test_interp_ref(b, 1, 12)
  297. || test_interp_ref(b, 1, 2)
  298. || test_interp_ref(b, 1, 17)
  299. || test_interp(c, 1, 2.f, 0)
  300. || test_interp(c, 1, 0.5f, 0)
  301. || test_interp(c, 1, 1.2f, 0)
  302. || test_interp(c, 1, 0.8f, 0)
  303. || test_interp(c, 1, 1.f, 12)
  304. || test_interp(c, 1, 1.f, 2)
  305. || test_interp(c, 1, 1.f, 17)
  306. || test_interp_ref(c, 1, 12)
  307. || test_interp_ref(c, 1, 2)
  308. || test_interp_ref(c, 1, 17);
  309. }
  310. static int test_interp_4()
  311. {
  312. ncnn::Mat a = RandomMat(15, 7);
  313. ncnn::Mat b = RandomMat(14, 12);
  314. ncnn::Mat c = RandomMat(13, 24);
  315. return 0
  316. || test_interp(a, 2, 2.f, 0)
  317. || test_interp(a, 2, 0.5f, 0)
  318. || test_interp(a, 2, 1.2f, 0)
  319. || test_interp(a, 2, 0.8f, 0)
  320. || test_interp(a, 2, 1.f, 12)
  321. || test_interp(a, 2, 1.f, 2)
  322. || test_interp(a, 2, 1.f, 16)
  323. || test_interp_align_corner(a, 2, 2.f, 0, 1)
  324. || test_interp_align_corner(a, 2, 0.5f, 0, 1)
  325. || test_interp_align_corner(a, 2, 1.2f, 0, 1)
  326. || test_interp_align_corner(a, 2, 0.8f, 0, 1)
  327. || test_interp_align_corner(a, 2, 1.f, 12, 1)
  328. || test_interp_align_corner(a, 2, 1.f, 2, 1)
  329. || test_interp_align_corner(a, 2, 1.f, 16, 1)
  330. || test_interp_ref(a, 2, 12)
  331. || test_interp_ref(a, 2, 2)
  332. || test_interp_ref(a, 2, 16)
  333. || test_interp(b, 2, 2.f, 0)
  334. || test_interp(b, 2, 0.5f, 0)
  335. || test_interp(b, 2, 1.2f, 0)
  336. || test_interp(b, 2, 0.8f, 0)
  337. || test_interp(b, 2, 1.f, 12)
  338. || test_interp(b, 2, 1.f, 2)
  339. || test_interp(b, 2, 1.f, 17)
  340. || test_interp_align_corner(b, 2, 2.f, 0, 1)
  341. || test_interp_align_corner(b, 2, 0.5f, 0, 1)
  342. || test_interp_align_corner(b, 2, 1.2f, 0, 1)
  343. || test_interp_align_corner(b, 2, 0.8f, 0, 1)
  344. || test_interp_align_corner(b, 2, 1.f, 12, 1)
  345. || test_interp_align_corner(b, 2, 1.f, 2, 1)
  346. || test_interp_align_corner(b, 2, 1.f, 17, 1)
  347. || test_interp_ref(b, 2, 12)
  348. || test_interp_ref(b, 2, 2)
  349. || test_interp_ref(b, 2, 17)
  350. || test_interp(c, 2, 2.f, 0)
  351. || test_interp(c, 2, 0.5f, 0)
  352. || test_interp(c, 2, 1.2f, 0)
  353. || test_interp(c, 2, 0.8f, 0)
  354. || test_interp(c, 2, 1.f, 12)
  355. || test_interp(c, 2, 1.f, 2)
  356. || test_interp(c, 2, 1.f, 17)
  357. || test_interp_align_corner(c, 2, 2.f, 0, 1)
  358. || test_interp_align_corner(c, 2, 0.5f, 0, 1)
  359. || test_interp_align_corner(c, 2, 1.2f, 0, 1)
  360. || test_interp_align_corner(c, 2, 0.8f, 0, 1)
  361. || test_interp_align_corner(c, 2, 1.f, 12, 1)
  362. || test_interp_align_corner(c, 2, 1.f, 2, 1)
  363. || test_interp_align_corner(c, 2, 1.f, 17, 1)
  364. || test_interp_ref(c, 2, 12)
  365. || test_interp_ref(c, 2, 2)
  366. || test_interp_ref(c, 2, 17);
  367. }
  368. static int test_interp_5()
  369. {
  370. ncnn::Mat a = RandomMat(16, 13);
  371. ncnn::Mat b = RandomMat(18, 12);
  372. ncnn::Mat c = RandomMat(13, 24);
  373. return 0
  374. || test_interp(a, 3, 2.f, 0)
  375. || test_interp(a, 3, 0.5f, 0)
  376. || test_interp(a, 3, 1.2f, 0)
  377. || test_interp(a, 3, 0.8f, 0)
  378. || test_interp(a, 3, 1.f, 12)
  379. || test_interp(a, 3, 1.f, 2)
  380. || test_interp(a, 3, 1.f, 7)
  381. || test_interp(a, 3, 1.f, 17)
  382. || test_interp_align_corner(a, 3, 2.f, 0, 1)
  383. || test_interp_align_corner(a, 3, 0.5f, 0, 1)
  384. || test_interp_align_corner(a, 3, 1.2f, 0, 1)
  385. || test_interp_align_corner(a, 3, 0.8f, 0, 1)
  386. || test_interp_align_corner(a, 3, 1.f, 12, 1)
  387. || test_interp_align_corner(a, 3, 1.f, 2, 1)
  388. || test_interp_align_corner(a, 3, 1.f, 7, 1)
  389. || test_interp_align_corner(a, 3, 1.f, 17, 1)
  390. || test_interp_ref(a, 3, 2)
  391. || test_interp_ref(a, 3, 7)
  392. || test_interp_ref(a, 3, 17)
  393. || test_interp(b, 3, 2.f, 0)
  394. || test_interp(b, 3, 0.5f, 0)
  395. || test_interp(b, 3, 1.2f, 0)
  396. || test_interp(b, 3, 0.8f, 0)
  397. || test_interp(b, 3, 1.f, 12)
  398. || test_interp(b, 3, 1.f, 2)
  399. || test_interp(b, 3, 1.f, 7)
  400. || test_interp(b, 3, 1.f, 19)
  401. || test_interp_align_corner(b, 3, 2.f, 0, 1)
  402. || test_interp_align_corner(b, 3, 0.5f, 0, 1)
  403. || test_interp_align_corner(b, 3, 1.2f, 0, 1)
  404. || test_interp_align_corner(b, 3, 0.8f, 0, 1)
  405. || test_interp_align_corner(b, 3, 1.f, 12, 1)
  406. || test_interp_align_corner(b, 3, 1.f, 2, 1)
  407. || test_interp_align_corner(b, 3, 1.f, 7, 1)
  408. || test_interp_align_corner(b, 3, 1.f, 19, 1)
  409. || test_interp_ref(b, 3, 2)
  410. || test_interp_ref(b, 3, 7)
  411. || test_interp_ref(b, 3, 19)
  412. || test_interp(c, 3, 2.f, 0)
  413. || test_interp(c, 3, 0.5f, 0)
  414. || test_interp(c, 3, 1.2f, 0)
  415. || test_interp(c, 3, 0.8f, 0)
  416. || test_interp(c, 3, 1.f, 12)
  417. || test_interp(c, 3, 1.f, 2)
  418. || test_interp(c, 3, 1.f, 7)
  419. || test_interp(c, 3, 1.f, 19)
  420. || test_interp_align_corner(c, 3, 2.f, 0, 1)
  421. || test_interp_align_corner(c, 3, 0.5f, 0, 1)
  422. || test_interp_align_corner(c, 3, 1.2f, 0, 1)
  423. || test_interp_align_corner(c, 3, 0.8f, 0, 1)
  424. || test_interp_align_corner(c, 3, 1.f, 12, 1)
  425. || test_interp_align_corner(c, 3, 1.f, 2, 1)
  426. || test_interp_align_corner(c, 3, 1.f, 7, 1)
  427. || test_interp_align_corner(c, 3, 1.f, 19, 1)
  428. || test_interp_ref(c, 3, 2)
  429. || test_interp_ref(c, 3, 7)
  430. || test_interp_ref(c, 3, 19);
  431. }
  432. static int test_interp_6()
  433. {
  434. ncnn::Mat a = RandomMat(17);
  435. ncnn::Mat b = RandomMat(20);
  436. ncnn::Mat c = RandomMat(48);
  437. return 0
  438. || test_interp(a, 1, 2.f, 3.f, 0, 0)
  439. || test_interp(a, 1, 1.f, 1.f, 10, 12)
  440. || test_interp(a, 1, 1.f, 1.f, 15, 16)
  441. || test_interp_ref(a, 1, 10, 12)
  442. || test_interp_ref(a, 1, 4, 4)
  443. || test_interp_ref(a, 1, 15, 16)
  444. || test_interp(b, 1, 4.f, 5.f, 0, 0)
  445. || test_interp(b, 1, 1.f, 1.f, 10, 12)
  446. || test_interp(b, 1, 1.f, 1.f, 14, 17)
  447. || test_interp_ref(b, 1, 5, 5)
  448. || test_interp_ref(b, 1, 14, 17)
  449. || test_interp(c, 1, 6.f, 7.f, 0, 0)
  450. || test_interp(c, 1, 1.f, 1.f, 10, 12)
  451. || test_interp(c, 1, 1.f, 1.f, 14, 17)
  452. || test_interp_ref(c, 1, 6, 6)
  453. || test_interp_ref(c, 1, 14, 17);
  454. }
  455. int main()
  456. {
  457. SRAND(7767517);
  458. return 0
  459. || test_interp_0()
  460. || test_interp_1()
  461. || test_interp_2()
  462. || test_interp_3()
  463. || test_interp_4()
  464. || test_interp_5()
  465. || test_interp_6();
  466. }