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.

local.h 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 local {
  8. struct TestArg {
  9. param::Convolution param;
  10. size_t n, ic, ih, iw, oc, oh, ow, fh, fw;
  11. TestArg(param::Convolution param, size_t n, size_t ic, size_t ih, size_t iw,
  12. size_t oc, size_t oh, size_t ow, size_t fh, size_t fw)
  13. : param(param),
  14. n(n),
  15. ic(ic),
  16. ih(ih),
  17. iw(iw),
  18. oc(oc),
  19. oh(oh),
  20. ow(ow),
  21. fh(fh),
  22. fw(fw) {}
  23. TensorShape sshape() const { return {n, ic, ih, iw}; }
  24. TensorShape fshape() const { return {oh, ow, ic, fh, fw, oc}; }
  25. TensorShape dshape() { return {n, oc, oh, ow}; }
  26. };
  27. static inline std::vector<TestArg> get_args_for_cuda() {
  28. std::vector<TestArg> test_args;
  29. // clang-format off
  30. for (size_t N: {32, 64})
  31. for (size_t IC: {1, 3, 8, 32, 33, 65})
  32. for (size_t OC: {1, 3, 8, 32, 33, 65}) {
  33. test_args.emplace_back(
  34. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION,
  35. 0, 0, 1, 1},
  36. N, IC, 7, 7, OC, 5, 5, 3, 3);
  37. }
  38. // clang-format on
  39. return test_args;
  40. }
  41. static inline std::vector<TestArg> get_args_for_intel_gpu() {
  42. std::vector<TestArg> test_args;
  43. // clang-format off
  44. for (size_t N: {32, 64})
  45. for (size_t IC: {1, 3, 8, 32, 33, 65})
  46. for (size_t OC : {1, 3, 8, 32, 33, 65}) {
  47. test_args.emplace_back(
  48. param::Convolution{
  49. param::Convolution::Mode::CROSS_CORRELATION, 0, 0,
  50. 1, 1},
  51. N, IC, 7, 7, OC, 5, 5, 3, 3);
  52. }
  53. // clang-format on
  54. return test_args;
  55. }
  56. static inline std::vector<TestArg> get_args_for_opencl() {
  57. std::vector<TestArg> test_args;
  58. for (size_t N : {32, 64})
  59. for (size_t IC : {1, 3, 32})
  60. for (size_t OC : {1, 3, 32}) {
  61. test_args.emplace_back(
  62. param::Convolution{
  63. param::Convolution::Mode::CROSS_CORRELATION, 0, 0, 1,
  64. 1},
  65. N, IC, 7, 7, OC, 5, 5, 3, 3);
  66. test_args.emplace_back(
  67. param::Convolution{
  68. param::Convolution::Mode::CROSS_CORRELATION, 1, 1, 1,
  69. 1},
  70. N, IC, 7, 7, OC, 7, 7, 3, 3);
  71. }
  72. return test_args;
  73. }
  74. static inline std::vector<TestArg> get_args_bwd_data_for_cuda() {
  75. std::vector<TestArg> test_args;
  76. // clang-format off
  77. for (size_t N: {32, 64})
  78. for (size_t IC: {1, 3, 8, 32, 64})
  79. for (size_t OC : {1, 3, 8, 32, 33, 65}) {
  80. test_args.emplace_back(
  81. param::Convolution{
  82. param::Convolution::Mode::CROSS_CORRELATION, 0, 0,
  83. 1, 1},
  84. N, IC, 7, 7, OC, 5, 5, 3, 3);
  85. }
  86. // clang-format on
  87. return test_args;
  88. }
  89. static inline std::vector<TestArg> get_args_bwd_filter_for_cuda() {
  90. std::vector<TestArg> test_args;
  91. // clang-format off
  92. for (size_t N: {32, 64})
  93. for (size_t IC: {1, 3, 8, 32, 56, 80})
  94. for (size_t OC : {1, 3, 8, 32, 33, 65}) {
  95. test_args.emplace_back(
  96. param::Convolution{
  97. param::Convolution::Mode::CROSS_CORRELATION, 0, 0,
  98. 1, 1},
  99. N, IC, 7, 7, OC, 5, 5, 3, 3);
  100. }
  101. // clang-format on
  102. return test_args;
  103. }
  104. static inline std::vector<TestArg> get_args_for_fp16() {
  105. std::vector<TestArg> test_args;
  106. test_args.emplace_back(
  107. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 1, 1, 1, 1},
  108. 64, 16, 8, 7, 16, 8, 7, 3, 3);
  109. test_args.emplace_back(
  110. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 0, 0, 1, 1},
  111. 15, 15, 7, 7, 16, 5, 5, 3, 3);
  112. test_args.emplace_back(
  113. param::Convolution{param::Convolution::Mode::CONVOLUTION, 0, 0, 1, 1}, 15,
  114. 15, 7, 7, 16, 5, 5, 3, 3);
  115. test_args.emplace_back(
  116. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 1, 1, 1, 1},
  117. 15, 15, 5, 5, 16, 5, 5, 3, 3);
  118. test_args.emplace_back(
  119. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 0, 0, 2, 2},
  120. 15, 15, 7, 7, 16, 3, 3, 3, 3);
  121. /*! \warning: this operator need reduce values along the axis of IC, so this
  122. * will results in large error in fp16 situation. so in the test cases, we
  123. * use small IC values.
  124. */
  125. // clang-format off
  126. for (size_t N: {1, 2})
  127. for (size_t OC : {16, 32, 48, 64}) {
  128. test_args.emplace_back(
  129. param::Convolution{
  130. param::Convolution::Mode::CROSS_CORRELATION, 0, 0,
  131. 1, 1},
  132. N, 16, 7, 7, OC, 5, 5, 3, 3);
  133. test_args.emplace_back(
  134. param::Convolution{param::Convolution::Mode::CONVOLUTION, 0,
  135. 0, 1, 1},
  136. N, 32, 7, 7, OC, 5, 5, 3, 3);
  137. }
  138. // clang-format on
  139. return test_args;
  140. }
  141. static inline std::vector<TestArg> get_args() {
  142. std::vector<TestArg> test_args;
  143. test_args.emplace_back(
  144. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 1, 1, 1, 1},
  145. 64, 16, 8, 7, 16, 8, 7, 3, 3);
  146. test_args.emplace_back(
  147. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 0, 0, 1, 1},
  148. 15, 15, 7, 7, 16, 5, 5, 3, 3);
  149. test_args.emplace_back(
  150. param::Convolution{param::Convolution::Mode::CONVOLUTION, 0, 0, 1, 1}, 15,
  151. 15, 7, 7, 16, 5, 5, 3, 3);
  152. test_args.emplace_back(
  153. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 1, 1, 1, 1},
  154. 15, 15, 5, 5, 16, 5, 5, 3, 3);
  155. test_args.emplace_back(
  156. param::Convolution{param::Convolution::Mode::CROSS_CORRELATION, 0, 0, 2, 2},
  157. 15, 15, 7, 7, 16, 3, 3, 3, 3);
  158. for (size_t N : {1, 2})
  159. // clang-format off
  160. for (size_t OC : {16, 32, 48, 64}) {
  161. test_args.emplace_back(
  162. param::Convolution{
  163. param::Convolution::Mode::CROSS_CORRELATION, 0, 0,
  164. 1, 1},
  165. N, 32, 7, 7, OC, 5, 5, 3, 3);
  166. test_args.emplace_back(
  167. param::Convolution{param::Convolution::Mode::CONVOLUTION, 0,
  168. 0, 1, 1},
  169. N, 32, 7, 7, OC, 5, 5, 3, 3);
  170. }
  171. // clang-format on
  172. return test_args;
  173. }
  174. } // namespace local
  175. } // namespace test
  176. } // namespace megdnn
  177. // vim: syntax=cpp.doxygen