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 4.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * \file dnn/test/common/images2neibs.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied.
  11. */
  12. #pragma once
  13. #include <cstddef>
  14. #include "megdnn/basic_types.h"
  15. #include "megdnn/opr_param_defs.h"
  16. namespace megdnn {
  17. namespace test {
  18. namespace images2neibs {
  19. struct TestArg {
  20. param::Images2Neibs param;
  21. TensorShape ishape;
  22. TestArg(param::Images2Neibs param, TensorShape ishape)
  23. : param(param), ishape(ishape) {}
  24. };
  25. inline std::vector<TestArg> get_args() {
  26. std::vector<TestArg> args;
  27. // clang-format off
  28. for (uint32_t ph : {0, 1})
  29. for (uint32_t pw : {0, 1})
  30. for (uint32_t sh : {1, 2})
  31. for (uint32_t sw : {1, 2})
  32. for (uint32_t dh : {1, 2, 3})
  33. for (uint32_t dw : {1, 2, 3})
  34. for (uint32_t wh : {3, 4})
  35. for (uint32_t ww : {3, 4}) {
  36. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  37. TensorShape{2, 3, 19, 20});
  38. }
  39. // clang-format on
  40. // large window case
  41. args.emplace_back(
  42. param::Images2Neibs{0, 0, 1, 1, 1, 1, 32, 64}, TensorShape{2, 3, 96, 128});
  43. // large size
  44. args.emplace_back(
  45. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1}, TensorShape{128, 128, 28, 24});
  46. return args;
  47. }
  48. inline std::vector<TestArg> get_cd4_args() {
  49. std::vector<TestArg> args;
  50. // clang-format off
  51. for (uint32_t ph : {0, 1})
  52. for (uint32_t pw : {0, 1})
  53. for (uint32_t sh : {1, 2})
  54. for (uint32_t sw : {1, 2})
  55. for (uint32_t dh : {1, 2, 3})
  56. for (uint32_t dw : {1, 2, 3})
  57. for (uint32_t wh : {2, 3})
  58. for (uint32_t ww : {2, 3}) {
  59. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh,
  60. ww},
  61. TensorShape{2, 13, 1, 14, 4});
  62. }
  63. // clang-format on
  64. // large window case
  65. args.emplace_back(
  66. param::Images2Neibs{0, 0, 1, 1, 1, 1, 8, 14}, TensorShape{2, 16, 1, 16, 4});
  67. // large size
  68. args.emplace_back(
  69. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  70. TensorShape{256, 16, 64, 16, 4});
  71. return args;
  72. }
  73. inline std::vector<TestArg> get_benchmark_args() {
  74. std::vector<TestArg> args;
  75. // clang-format off
  76. for (uint32_t ph : {0, 1})
  77. for (uint32_t pw : {0, 1})
  78. for (uint32_t sh : {1, 2})
  79. for (uint32_t sw : {1, 2})
  80. for (uint32_t dh : {1, 2})
  81. for (uint32_t dw : {1, 2})
  82. for (uint32_t wh : {3, 4})
  83. for (uint32_t ww : {3, 4})
  84. for (uint32_t b : {1, 64})
  85. for (uint32_t c : {64, 128})
  86. for (uint32_t hw : {64, 128}) {
  87. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  88. TensorShape{b, c, hw, hw});
  89. }
  90. // clang-format on
  91. // large size
  92. args.emplace_back(
  93. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  94. TensorShape{1024, 128, 28, 24});
  95. return args;
  96. }
  97. inline std::vector<TestArg> get_benchmark_args_cd4() {
  98. std::vector<TestArg> args;
  99. // clang-format off
  100. for (uint32_t ph : {0, 1})
  101. for (uint32_t pw : {0, 1})
  102. for (uint32_t sh : {1, 2})
  103. for (uint32_t sw : {1, 2})
  104. for (uint32_t dh : {1, 2})
  105. for (uint32_t dw : {1, 2})
  106. for (uint32_t wh : {3, 4})
  107. for (uint32_t ww : {3, 4})
  108. for (uint32_t b : {1, 32})
  109. for (uint32_t c : {16, 32})
  110. for (uint32_t hw : {16, 32}) {
  111. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  112. TensorShape{b, hw, (c + 3) / 4, hw, 4});
  113. }
  114. // clang-format on
  115. // large size
  116. args.emplace_back(
  117. param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  118. TensorShape{256, 28, 32, 24, 4});
  119. return args;
  120. }
  121. } // namespace images2neibs
  122. } // namespace test
  123. } // namespace megdnn
  124. // vim: syntax=cpp.doxygen