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.

warp_perspective.cpp 21 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. #include <string>
  2. #include <vector>
  3. #include "test/arm_common/fixture.h"
  4. #include "test/common/benchmarker.h"
  5. #include "test/common/checker.h"
  6. #include "test/common/random_state.h"
  7. #include "test/common/rng.h"
  8. #include "test/common/task_record_check.h"
  9. #include "test/common/warp_perspective.h"
  10. namespace megdnn {
  11. namespace test {
  12. TEST_F(ARM_COMMON, WARP_PERSPECTIVE_CV) {
  13. //! Just for the format NHWC
  14. Checker<WarpPerspective, WarpPerspectiveMatIdxProxy> checker(handle());
  15. param::WarpPerspective param;
  16. class ResizeMatRNG : public RNG {
  17. void gen(const TensorND& tensor_) override {
  18. auto& gen = RandomState::generator();
  19. std::uniform_real_distribution<dt_float32> pdist3(1.9f, 3.1f);
  20. std::uniform_real_distribution<dt_float32> pdist(0.9f, 1.1f);
  21. std::uniform_real_distribution<dt_float32> pdisth(0.4f, 0.6f);
  22. std::uniform_real_distribution<dt_float32> ndist(-1.1f, -0.9f);
  23. std::uniform_real_distribution<dt_float32> ndist3(-3.1f, -1.9f);
  24. std::uniform_real_distribution<dt_float32> ndisth(-0.6f, -0.4f);
  25. std::uniform_int_distribution<int> dice(0, 5);
  26. float* ptr = tensor_.ptr<dt_float32>();
  27. auto N = tensor_.layout.shape[0];
  28. for (size_t n = 0; n < N; ++n) {
  29. for (size_t i = 0; i < 9; ++i) {
  30. switch (dice(gen)) {
  31. case 0:
  32. ptr[i] = pdist3(gen);
  33. break;
  34. case 1:
  35. ptr[i] = pdist(gen);
  36. break;
  37. case 2:
  38. ptr[i] = pdisth(gen);
  39. break;
  40. case 3:
  41. ptr[i] = ndist(gen);
  42. break;
  43. case 4:
  44. ptr[i] = ndist3(gen);
  45. break;
  46. case 5:
  47. ptr[i] = ndisth(gen);
  48. break;
  49. }
  50. }
  51. // is resize?
  52. if (n & 1) {
  53. ptr[1] = 0;
  54. ptr[3] = 0;
  55. ptr[6] = ptr[7] = 0;
  56. }
  57. ptr += 9;
  58. }
  59. }
  60. } rng;
  61. using BMode = param::WarpPerspective::BorderMode;
  62. param.format = param::WarpPerspective::Format::NHWC;
  63. // add for nearest test
  64. param.imode = param::WarpPerspective::InterpolationMode::NEAREST;
  65. for (auto mode :
  66. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  67. BMode::CONSTANT}) {
  68. param.bmode = mode;
  69. param.border_val = 1.737;
  70. checker.set_param(param);
  71. UniformIntRNG rng(0, 9);
  72. checker.set_rng(2, &rng);
  73. checker.set_dtype(2, dtype::Int32());
  74. checker.exec({{10, 128, 108, 3}, {20, 3, 3}, {20}, {20, 56, 128, 3}});
  75. }
  76. // resize nan case
  77. UniformFloatRNG rng_zero(0, 0);
  78. checker.set_rng(1, &rng_zero);
  79. {
  80. param.bmode = BMode::CONSTANT;
  81. param.border_val = 1.737;
  82. checker.set_param(param);
  83. UniformIntRNG rng(0, 999);
  84. checker.set_rng(2, &rng);
  85. checker.set_dtype(2, dtype::Int32());
  86. checker.exec({{1000, 2, 10, 3}, {1000, 3, 3}, {1000}, {1000, 2, 12, 3}});
  87. }
  88. // add linear test
  89. param.imode = param::WarpPerspective::InterpolationMode::INTER_LINEAR;
  90. for (auto mode :
  91. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  92. BMode::CONSTANT}) {
  93. param.bmode = mode;
  94. param.border_val = 1.737;
  95. checker.set_param(param);
  96. UniformIntRNG rng(0, 9);
  97. checker.set_rng(2, &rng);
  98. checker.set_dtype(2, dtype::Int32());
  99. checker.exec({{10, 128, 108, 3}, {20, 3, 3}, {20}, {20, 56, 128, 3}});
  100. }
  101. // resize nan case
  102. checker.set_rng(1, &rng_zero);
  103. {
  104. param.bmode = BMode::CONSTANT;
  105. param.border_val = 1.737;
  106. checker.set_param(param);
  107. UniformIntRNG rng(0, 999);
  108. checker.set_rng(2, &rng);
  109. checker.set_dtype(2, dtype::Int32());
  110. checker.exec({{1000, 2, 10, 3}, {2000, 3, 3}, {2000}, {2000, 2, 12, 3}});
  111. }
  112. auto args = warp_perspective::get_cv_args();
  113. for (auto&& arg : args) {
  114. ConstValue rng(0.f);
  115. checker.set_param(arg.param)
  116. .set_rng(2, &rng)
  117. .set_dtype(0, dtype::Uint8())
  118. .set_dtype(1, dtype::Float32())
  119. .set_dtype(2, dtype::Int32())
  120. .set_dtype(3, dtype::Uint8())
  121. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  122. }
  123. for (auto&& arg : args) {
  124. ConstValue rng(0.f);
  125. checker.set_param(arg.param)
  126. .set_rng(2, &rng)
  127. .set_dtype(0, dtype::Float32())
  128. .set_dtype(1, dtype::Float32())
  129. .set_dtype(2, dtype::Int32())
  130. .set_dtype(3, dtype::Float32())
  131. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  132. }
  133. }
  134. TEST_F(ARM_COMMON, WARP_PERSPECTIVE_CV_RECORD) {
  135. //! Just for the format NHWC
  136. TaskRecordChecker<WarpPerspective, WarpPerspectiveMatIdxProxy> checker(0);
  137. param::WarpPerspective param;
  138. class ResizeMatRNG : public RNG {
  139. void gen(const TensorND& tensor_) override {
  140. auto& gen = RandomState::generator();
  141. std::uniform_real_distribution<dt_float32> pdist3(1.9f, 3.1f);
  142. std::uniform_real_distribution<dt_float32> pdist(0.9f, 1.1f);
  143. std::uniform_real_distribution<dt_float32> pdisth(0.4f, 0.6f);
  144. std::uniform_real_distribution<dt_float32> ndist(-1.1f, -0.9f);
  145. std::uniform_real_distribution<dt_float32> ndist3(-3.1f, -1.9f);
  146. std::uniform_real_distribution<dt_float32> ndisth(-0.6f, -0.4f);
  147. std::uniform_int_distribution<int> dice(0, 5);
  148. float* ptr = tensor_.ptr<dt_float32>();
  149. auto N = tensor_.layout.shape[0];
  150. for (size_t n = 0; n < N; ++n) {
  151. for (size_t i = 0; i < 9; ++i) {
  152. switch (dice(gen)) {
  153. case 0:
  154. ptr[i] = pdist3(gen);
  155. break;
  156. case 1:
  157. ptr[i] = pdist(gen);
  158. break;
  159. case 2:
  160. ptr[i] = pdisth(gen);
  161. break;
  162. case 3:
  163. ptr[i] = ndist(gen);
  164. break;
  165. case 4:
  166. ptr[i] = ndist3(gen);
  167. break;
  168. case 5:
  169. ptr[i] = ndisth(gen);
  170. break;
  171. }
  172. }
  173. // is resize?
  174. if (n & 1) {
  175. ptr[1] = 0;
  176. ptr[3] = 0;
  177. ptr[6] = ptr[7] = 0;
  178. }
  179. ptr += 9;
  180. }
  181. }
  182. } rng;
  183. using BMode = param::WarpPerspective::BorderMode;
  184. param.format = param::WarpPerspective::Format::NHWC;
  185. // add for nearest test
  186. param.imode = param::WarpPerspective::InterpolationMode::NEAREST;
  187. for (auto mode :
  188. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  189. BMode::CONSTANT}) {
  190. param.bmode = mode;
  191. param.border_val = 1.737;
  192. checker.set_param(param);
  193. UniformIntRNG rng(0, 9);
  194. checker.set_rng(2, &rng);
  195. checker.set_dtype(2, dtype::Int32());
  196. checker.exec({{10, 128, 108, 3}, {20, 3, 3}, {20}, {20, 56, 128, 3}});
  197. }
  198. // resize nan case
  199. UniformFloatRNG rng_zero(0, 0);
  200. checker.set_rng(1, &rng_zero);
  201. {
  202. param.bmode = BMode::CONSTANT;
  203. param.border_val = 1.737;
  204. checker.set_param(param);
  205. UniformIntRNG rng(0, 999);
  206. checker.set_rng(2, &rng);
  207. checker.set_dtype(2, dtype::Int32());
  208. checker.exec({{1000, 2, 10, 3}, {1000, 3, 3}, {1000}, {1000, 2, 12, 3}});
  209. }
  210. // add linear test
  211. param.imode = param::WarpPerspective::InterpolationMode::INTER_LINEAR;
  212. for (auto mode :
  213. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  214. BMode::CONSTANT}) {
  215. param.bmode = mode;
  216. param.border_val = 1.737;
  217. checker.set_param(param);
  218. UniformIntRNG rng(0, 9);
  219. checker.set_rng(2, &rng);
  220. checker.set_dtype(2, dtype::Int32());
  221. checker.exec({{10, 128, 108, 3}, {20, 3, 3}, {20}, {20, 56, 128, 3}});
  222. }
  223. // resize nan case
  224. checker.set_rng(1, &rng_zero);
  225. {
  226. param.bmode = BMode::CONSTANT;
  227. param.border_val = 1.737;
  228. checker.set_param(param);
  229. UniformIntRNG rng(0, 999);
  230. checker.set_rng(2, &rng);
  231. checker.set_dtype(2, dtype::Int32());
  232. checker.exec({{1000, 2, 10, 3}, {2000, 3, 3}, {2000}, {2000, 2, 12, 3}});
  233. }
  234. auto args = warp_perspective::get_cv_args();
  235. for (auto&& arg : args) {
  236. ConstValue rng(0.f);
  237. checker.set_param(arg.param)
  238. .set_rng(2, &rng)
  239. .set_dtype(0, dtype::Uint8())
  240. .set_dtype(1, dtype::Float32())
  241. .set_dtype(2, dtype::Int32())
  242. .set_dtype(3, dtype::Uint8())
  243. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  244. }
  245. for (auto&& arg : args) {
  246. ConstValue rng(0.f);
  247. checker.set_param(arg.param)
  248. .set_rng(2, &rng)
  249. .set_dtype(0, dtype::Float32())
  250. .set_dtype(1, dtype::Float32())
  251. .set_dtype(2, dtype::Int32())
  252. .set_dtype(3, dtype::Float32())
  253. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  254. }
  255. }
  256. TEST_F(ARM_COMMON_MULTI_THREADS, WARP_PERSPECTIVE_CV) {
  257. //! Just for the format NHWC
  258. Checker<WarpPerspective, WarpPerspectiveMatIdxProxy> checker(handle());
  259. param::WarpPerspective param;
  260. class ResizeMatRNG : public RNG {
  261. void gen(const TensorND& tensor_) override {
  262. auto& gen = RandomState::generator();
  263. std::uniform_real_distribution<dt_float32> pdist3(1.9f, 3.1f);
  264. std::uniform_real_distribution<dt_float32> pdist(0.9f, 1.1f);
  265. std::uniform_real_distribution<dt_float32> pdisth(0.4f, 0.6f);
  266. std::uniform_real_distribution<dt_float32> ndist(-1.1f, -0.9f);
  267. std::uniform_real_distribution<dt_float32> ndist3(-3.1f, -1.9f);
  268. std::uniform_real_distribution<dt_float32> ndisth(-0.6f, -0.4f);
  269. std::uniform_int_distribution<int> dice(0, 5);
  270. float* ptr = tensor_.ptr<dt_float32>();
  271. auto N = tensor_.layout.shape[0];
  272. for (size_t n = 0; n < N; ++n) {
  273. for (size_t i = 0; i < 9; ++i) {
  274. switch (dice(gen)) {
  275. case 0:
  276. ptr[i] = pdist3(gen);
  277. break;
  278. case 1:
  279. ptr[i] = pdist(gen);
  280. break;
  281. case 2:
  282. ptr[i] = pdisth(gen);
  283. break;
  284. case 3:
  285. ptr[i] = ndist(gen);
  286. break;
  287. case 4:
  288. ptr[i] = ndist3(gen);
  289. break;
  290. case 5:
  291. ptr[i] = ndisth(gen);
  292. break;
  293. }
  294. }
  295. // is resize?
  296. if (n & 1) {
  297. ptr[1] = 0;
  298. ptr[3] = 0;
  299. ptr[6] = ptr[7] = 0;
  300. }
  301. ptr += 9;
  302. }
  303. }
  304. } rng;
  305. using BMode = param::WarpPerspective::BorderMode;
  306. param.format = param::WarpPerspective::Format::NHWC;
  307. // add for nearest test
  308. param.imode = param::WarpPerspective::InterpolationMode::NEAREST;
  309. for (auto mode :
  310. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  311. BMode::CONSTANT}) {
  312. param.bmode = mode;
  313. param.border_val = 1.737;
  314. checker.set_param(param);
  315. UniformIntRNG rng(0, 9);
  316. checker.set_rng(2, &rng);
  317. checker.set_dtype(2, dtype::Int32());
  318. checker.exec({{10, 128, 108, 3}, {10, 3, 3}, {10}, {10, 56, 128, 3}});
  319. }
  320. // resize nan case
  321. UniformFloatRNG rng_zero(0, 0);
  322. checker.set_rng(1, &rng_zero);
  323. {
  324. param.bmode = BMode::CONSTANT;
  325. param.border_val = 1.737;
  326. checker.set_param(param);
  327. UniformIntRNG rng(0, 999);
  328. checker.set_rng(2, &rng);
  329. checker.set_dtype(2, dtype::Int32());
  330. checker.exec({{1000, 2, 10, 3}, {2000, 3, 3}, {2000}, {2000, 2, 12, 3}});
  331. }
  332. // add linear test
  333. param.imode = param::WarpPerspective::InterpolationMode::INTER_LINEAR;
  334. for (auto mode :
  335. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  336. BMode::CONSTANT}) {
  337. param.bmode = mode;
  338. param.border_val = 1.737;
  339. checker.set_param(param);
  340. UniformIntRNG rng(0, 9);
  341. checker.set_rng(2, &rng);
  342. checker.set_dtype(2, dtype::Int32());
  343. checker.exec({{10, 128, 108, 3}, {10, 3, 3}, {10}, {10, 56, 128, 3}});
  344. }
  345. // resize nan case
  346. checker.set_rng(1, &rng_zero);
  347. {
  348. param.bmode = BMode::CONSTANT;
  349. param.border_val = 1.737;
  350. checker.set_param(param);
  351. UniformIntRNG rng(0, 999);
  352. checker.set_rng(2, &rng);
  353. checker.set_dtype(2, dtype::Int32());
  354. checker.exec({{1000, 2, 10, 3}, {1000, 3, 3}, {1000}, {1000, 2, 12, 3}});
  355. }
  356. auto args = warp_perspective::get_cv_args();
  357. for (auto&& arg : args) {
  358. ConstValue rng(0.f);
  359. checker.set_param(arg.param)
  360. .set_rng(2, &rng)
  361. .set_dtype(0, dtype::Uint8())
  362. .set_dtype(1, dtype::Float32())
  363. .set_dtype(2, dtype::Int32())
  364. .set_dtype(3, dtype::Uint8())
  365. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  366. }
  367. for (auto&& arg : args) {
  368. ConstValue rng(0.f);
  369. checker.set_param(arg.param)
  370. .set_rng(2, &rng)
  371. .set_dtype(0, dtype::Float32())
  372. .set_dtype(1, dtype::Float32())
  373. .set_dtype(2, dtype::Int32())
  374. .set_dtype(3, dtype::Float32())
  375. .execs({arg.src, arg.trans, arg.mat_idx, arg.dst});
  376. }
  377. }
  378. #if MEGDNN_WITH_BENCHMARK
  379. TEST_F(ARM_COMMON, BENCHMARK_WARP_PERSPECTIVE_FORWARD) {
  380. Benchmarker<WarpPerspectiveForward> benchmarker(handle());
  381. auto handle_naive = create_cpu_handle(2);
  382. Benchmarker<WarpPerspectiveForward> benchmarker_naive(handle_naive.get());
  383. constexpr size_t NR_RUN = 50;
  384. using BMode = param::WarpPerspective::BorderMode;
  385. using IMode = param::WarpPerspective::InterpolationMode;
  386. WarpPerspective::Param param;
  387. param.border_val = 0.3f;
  388. param.format = param::WarpPerspective::Format::NHWC;
  389. auto run = [&](size_t N, size_t C, size_t IH, size_t IW, size_t OH, size_t OW,
  390. size_t scale) {
  391. printf("src={%zu, %zu, %zu, %zu}, dst={%zu, %zu, %zu, %zu}\n", N, IH, IW, C, N,
  392. OH, OW, C);
  393. auto time_ms =
  394. benchmarker.exec({{N, IH, IW, C}, {N, 3, 3}, {N, OH, OW, C}}) / NR_RUN;
  395. auto time_naive_ms =
  396. benchmarker_naive.exec({{N, IH, IW, C}, {N, 3, 3}, {N, OH, OW, C}}) /
  397. NR_RUN;
  398. auto bandwidth = N * C * (scale * OH * OW) * dtype::Float32().size();
  399. printf("aarch64: %.3f, perf: %.3f GBPS naive: %.3f, perf %.3f GBPS "
  400. "speedup: %f\n",
  401. time_ms, bandwidth / time_ms / 1e6, time_naive_ms,
  402. bandwidth / time_naive_ms / 1e6, time_naive_ms / time_ms);
  403. };
  404. std::vector<std::string> bmodestringmap = {
  405. "REPLICATE", "REFLECT", "REFLECT_101", "WARP", "CONSTANT"};
  406. std::vector<std::string> imodestringmap = {"NEAREST", "INTER_LINEAR"};
  407. size_t scales[2] = {2, 5};
  408. for (auto imode : {IMode::NEAREST, IMode::INTER_LINEAR}) {
  409. for (auto bmode :
  410. {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
  411. BMode::CONSTANT}) {
  412. param.imode = imode;
  413. param.bmode = bmode;
  414. benchmarker.set_param(param).set_display(false).set_times(NR_RUN);
  415. benchmarker_naive.set_param(param).set_display(false).set_times(NR_RUN);
  416. size_t scale = scales[(int)imode];
  417. printf("\n\n\n warpperspective InterpolationMode::%s "
  418. "BorderMode::%s start\n",
  419. imodestringmap[(int)imode].c_str(),
  420. bmodestringmap[(int)bmode].c_str());
  421. for (auto&& shape : std::vector<std::pair<size_t, size_t>>{
  422. {700, 490},
  423. {500, 334},
  424. {472, 342},
  425. {448, 306},
  426. {626, 412},
  427. {140, 144},
  428. {120, 128},
  429. {180, 176}}) {
  430. for (size_t ch : {1, 2, 3}) {
  431. run(1, ch, shape.first, shape.second, 256, 256, scale);
  432. }
  433. }
  434. }
  435. }
  436. }
  437. namespace {
  438. void benchmark_impl(
  439. const typename WarpPerspective::Param& param,
  440. std::vector<SmallVector<TensorShape>> shapes, size_t RUNS,
  441. TaskExecutorConfig&& multi_thread_config,
  442. TaskExecutorConfig&& single_thread_config) {
  443. std::vector<float> multi_thread_times, single_thread_times;
  444. {
  445. auto multi_thread_hanle = create_cpu_handle(0, true, &multi_thread_config);
  446. auto benchmarker = Benchmarker<WarpPerspective>(multi_thread_hanle.get());
  447. benchmarker.set_times(RUNS).set_display(false).set_param(param);
  448. for (auto shape : shapes) {
  449. multi_thread_times.push_back(benchmarker.exec(shape) / RUNS);
  450. }
  451. }
  452. {
  453. auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config);
  454. auto benchmarker = Benchmarker<WarpPerspective>(single_thread_handle.get());
  455. benchmarker.set_times(RUNS).set_display(false).set_param(param);
  456. for (auto shape : shapes) {
  457. single_thread_times.push_back(benchmarker.exec(shape) / RUNS);
  458. }
  459. }
  460. printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
  461. printf("core_ids:");
  462. for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
  463. printf("%zu ", multi_thread_config.affinity_core_set[i]);
  464. }
  465. printf(", Single thread core_id %zu\n", single_thread_config.affinity_core_set[0]);
  466. for (size_t i = 0; i < shapes.size(); i++) {
  467. auto shape = shapes[i];
  468. printf("Case: ");
  469. for (auto sh : shape)
  470. printf("%s ", sh.to_string().c_str());
  471. printf("%zu threads time: %f,\n single thread time: "
  472. "%f. spead up = %f, speedup/cores=%f\n",
  473. multi_thread_config.nr_thread, multi_thread_times[i],
  474. single_thread_times[i], single_thread_times[i] / multi_thread_times[i],
  475. single_thread_times[i] / multi_thread_times[i] /
  476. multi_thread_config.nr_thread);
  477. }
  478. }
  479. } // namespace
  480. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_WARP_PERSPECTIVE) {
  481. constexpr size_t RUNS = 50;
  482. using BMode = param::WarpPerspective::BorderMode;
  483. using IMode = param::WarpPerspective::InterpolationMode;
  484. WarpPerspective::Param param;
  485. param.border_val = 0.3f;
  486. param.format = param::WarpPerspective::Format::NHWC;
  487. param.imode = IMode::INTER_LINEAR;
  488. param.bmode = BMode::REPLICATE;
  489. std::vector<SmallVector<TensorShape>> shapes;
  490. auto bench_case = [&](size_t N, size_t H, size_t W, size_t C) {
  491. SmallVector<TensorShape> shape{{N, H, W, C}, {N, 3, 3}, {N, 224, 224, C}};
  492. shapes.push_back(shape);
  493. };
  494. bench_case(1, 700, 490, 1);
  495. bench_case(1, 700, 490, 2);
  496. bench_case(1, 700, 490, 3);
  497. bench_case(1, 500, 334, 1);
  498. bench_case(1, 500, 334, 2);
  499. bench_case(1, 500, 334, 3);
  500. bench_case(1, 140, 144, 1);
  501. bench_case(1, 140, 144, 2);
  502. bench_case(1, 140, 114, 3);
  503. printf("Benchmark warp perspective\n");
  504. benchmark_impl(param, shapes, RUNS, {4, {4, 5, 6, 7}}, {1, {4}});
  505. benchmark_impl(param, shapes, RUNS, {4, {4, 5, 6, 7}}, {1, {7}});
  506. benchmark_impl(param, shapes, RUNS, {2, {4, 5}}, {1, {4}});
  507. }
  508. #endif
  509. } // namespace test
  510. } // namespace megdnn
  511. // vim: syntax=cpp.doxygen