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

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