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_affine.h 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "megdnn/basic_types.h"
  3. #include "megdnn/opr_param_defs.h"
  4. #include "test/common/opr_proxy.h"
  5. #include <iostream>
  6. namespace megdnn {
  7. namespace test {
  8. namespace warp_affine {
  9. struct TestArg {
  10. param::WarpAffine param;
  11. TensorShape src;
  12. TensorShape trans;
  13. TensorShape dst;
  14. TestArg(param::WarpAffine param_, TensorShape src_, TensorShape trans_,
  15. TensorShape dst_)
  16. : param(param_), src(src_), trans(trans_), dst(dst_) {}
  17. };
  18. inline std::vector<TestArg> get_cv_args() {
  19. std::vector<TestArg> args;
  20. //! if the format of WarpAffine is NHWC, not support LINEAR and AREA
  21. using BorderMode = param::WarpAffine::BorderMode;
  22. using InterpolationMode = param::WarpAffine::InterpolationMode;
  23. param::WarpAffine cur_param;
  24. cur_param.format = param::WarpAffine::Format::NHWC;
  25. for (size_t i = 4; i <= 168; i *= 8) {
  26. for (size_t ic : {1, 2, 3}) {
  27. for (BorderMode bmode :
  28. {BorderMode::BORDER_REPLICATE, BorderMode::BORDER_REFLECT,
  29. BorderMode::BORDER_REFLECT_101, BorderMode::BORDER_WRAP,
  30. BorderMode::BORDER_CONSTANT}) {
  31. for (InterpolationMode imode :
  32. {InterpolationMode::LINEAR, InterpolationMode::INTER_NEAREST,
  33. InterpolationMode::INTER_CUBIC,
  34. InterpolationMode::INTER_LANCZOS4}) {
  35. cur_param.border_mode = bmode;
  36. cur_param.border_val = 1.1f;
  37. cur_param.imode = imode;
  38. args.emplace_back(
  39. cur_param, TensorShape{1, i, i, ic}, TensorShape{1, 2, 3},
  40. TensorShape{1, i, i, ic});
  41. args.emplace_back(
  42. cur_param, TensorShape{1, i, i * 2, ic},
  43. TensorShape{1, 2, 3}, TensorShape{1, i, i * 2, ic});
  44. args.emplace_back(
  45. cur_param, TensorShape{1, i * 3, i, ic},
  46. TensorShape{1, 2, 3}, TensorShape{1, i * 3, i, ic});
  47. args.emplace_back(
  48. cur_param, TensorShape{1, i, i, ic}, TensorShape{1, 2, 3},
  49. TensorShape{1, 8, 8, ic});
  50. args.emplace_back(
  51. cur_param, TensorShape{1, i, i * 2, ic},
  52. TensorShape{1, 2, 3}, TensorShape{1, 8, 8, ic});
  53. args.emplace_back(
  54. cur_param, TensorShape{1, i * 3, i, ic},
  55. TensorShape{1, 2, 3}, TensorShape{1, 8, 8, ic});
  56. }
  57. }
  58. }
  59. }
  60. return args;
  61. }
  62. } // namespace warp_affine
  63. } // namespace test
  64. } // namespace megdnn
  65. // vim: syntax=cpp.doxygen