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

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