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.

images2neibs.h 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma once
  2. #include <cstddef>
  3. #include "megdnn/basic_types.h"
  4. #include "megdnn/opr_param_defs.h"
  5. namespace megdnn {
  6. namespace test {
  7. namespace images2neibs {
  8. struct TestArg {
  9. param::Images2Neibs param;
  10. TensorShape ishape;
  11. TestArg(param::Images2Neibs param, TensorShape ishape)
  12. : param(param), ishape(ishape) {}
  13. };
  14. inline std::vector<TestArg> get_args() {
  15. std::vector<TestArg> args;
  16. // clang-format off
  17. for (uint32_t ph : {0, 1})
  18. for (uint32_t pw : {0, 1})
  19. for (uint32_t sh : {1, 2})
  20. for (uint32_t sw : {1, 2})
  21. for (uint32_t dh : {1, 2, 3})
  22. for (uint32_t dw : {1, 2, 3})
  23. for (uint32_t wh : {3, 4})
  24. for (uint32_t ww : {3, 4}) {
  25. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  26. TensorShape{2, 3, 19, 20});
  27. }
  28. // clang-format on
  29. // large window case
  30. args.emplace_back(
  31. param::Images2Neibs{0, 0, 1, 1, 1, 1, 32, 64}, TensorShape{2, 3, 96, 128});
  32. // large size
  33. args.emplace_back(
  34. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1}, TensorShape{128, 128, 28, 24});
  35. return args;
  36. }
  37. inline std::vector<TestArg> get_cd4_args() {
  38. std::vector<TestArg> args;
  39. // clang-format off
  40. for (uint32_t ph : {0, 1})
  41. for (uint32_t pw : {0, 1})
  42. for (uint32_t sh : {1, 2})
  43. for (uint32_t sw : {1, 2})
  44. for (uint32_t dh : {1, 2, 3})
  45. for (uint32_t dw : {1, 2, 3})
  46. for (uint32_t wh : {2, 3})
  47. for (uint32_t ww : {2, 3}) {
  48. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh,
  49. ww},
  50. TensorShape{2, 13, 1, 14, 4});
  51. }
  52. // clang-format on
  53. // large window case
  54. args.emplace_back(
  55. param::Images2Neibs{0, 0, 1, 1, 1, 1, 8, 14}, TensorShape{2, 16, 1, 16, 4});
  56. // large size
  57. args.emplace_back(
  58. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  59. TensorShape{256, 16, 64, 16, 4});
  60. return args;
  61. }
  62. inline std::vector<TestArg> get_benchmark_args() {
  63. std::vector<TestArg> args;
  64. // clang-format off
  65. for (uint32_t ph : {0, 1})
  66. for (uint32_t pw : {0, 1})
  67. for (uint32_t sh : {1, 2})
  68. for (uint32_t sw : {1, 2})
  69. for (uint32_t dh : {1, 2})
  70. for (uint32_t dw : {1, 2})
  71. for (uint32_t wh : {3, 4})
  72. for (uint32_t ww : {3, 4})
  73. for (uint32_t b : {1, 64})
  74. for (uint32_t c : {64, 128})
  75. for (uint32_t hw : {64, 128}) {
  76. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  77. TensorShape{b, c, hw, hw});
  78. }
  79. // clang-format on
  80. // large size
  81. args.emplace_back(
  82. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  83. TensorShape{1024, 128, 28, 24});
  84. return args;
  85. }
  86. inline std::vector<TestArg> get_benchmark_args_cd4() {
  87. std::vector<TestArg> args;
  88. // clang-format off
  89. for (uint32_t ph : {0, 1})
  90. for (uint32_t pw : {0, 1})
  91. for (uint32_t sh : {1, 2})
  92. for (uint32_t sw : {1, 2})
  93. for (uint32_t dh : {1, 2})
  94. for (uint32_t dw : {1, 2})
  95. for (uint32_t wh : {3, 4})
  96. for (uint32_t ww : {3, 4})
  97. for (uint32_t b : {1, 32})
  98. for (uint32_t c : {16, 32})
  99. for (uint32_t hw : {16, 32}) {
  100. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  101. TensorShape{b, hw, (c + 3) / 4, hw, 4});
  102. }
  103. // clang-format on
  104. // large size
  105. args.emplace_back(
  106. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  107. TensorShape{256, 28, 32, 24, 4});
  108. return args;
  109. }
  110. } // namespace images2neibs
  111. } // namespace test
  112. } // namespace megdnn
  113. // vim: syntax=cpp.doxygen