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.cpp 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include "test/naive/fixture.h"
  2. #include "megdnn/oprs/nn.h"
  3. #include "test/common/checker.h"
  4. using namespace megdnn;
  5. using namespace test;
  6. TEST_F(NAIVE, IMAGES2NEIBS_FORWARD) {
  7. Checker<Images2Neibs> checker(handle(), /* check_dispatch */ false);
  8. Images2Neibs::Param param(0, 0, 1, 1, 1, 1, 2, 2);
  9. checker.set_param(param).exect(
  10. Testcase{
  11. TensorValue(
  12. {1, 1, 3, 3}, dtype::Uint8(), {0, 1, 2, 3, 4, 5, 6, 7, 8}),
  13. {}},
  14. Testcase{
  15. {},
  16. TensorValue(
  17. {1, 1, 2, 2, 2, 2}, dtype::Uint8(),
  18. {0, 1, 3, 4, 1, 2, 4, 5, 3, 4, 6, 7, 4, 5, 7, 8})});
  19. param.pad_h = 1;
  20. param.pad_w = 1;
  21. param.stride_h = 2;
  22. param.stride_w = 2;
  23. param.dilate_h = 2;
  24. param.dilate_w = 2;
  25. param.window_h = 3;
  26. param.window_w = 3;
  27. checker.set_param(param).exect(
  28. Testcase{
  29. TensorValue(
  30. {1, 1, 6, 7}, dtype::Uint8(),
  31. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
  32. 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
  33. 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41}),
  34. {}},
  35. Testcase{
  36. {},
  37. TensorValue(
  38. {1, 1, 2, 3, 3, 3}, dtype::Uint8(),
  39. {0, 0, 0, 0, 8, 10, 0, 22, 24, 0, 0, 0, 8, 10,
  40. 12, 22, 24, 26, 0, 0, 0, 10, 12, 0, 24, 26, 0, 0,
  41. 8, 10, 0, 22, 24, 0, 36, 38, 8, 10, 12, 22, 24, 26,
  42. 36, 38, 40, 10, 12, 0, 24, 26, 0, 38, 40, 0})});
  43. }
  44. TEST_F(NAIVE, IMAGES2NEIBS_FORWARD_CD4) {
  45. Checker<Images2Neibs> checker(handle(), /* check_dispatch */ false);
  46. Images2Neibs::Param param(0, 0, 1, 1, 1, 1, 2, 2);
  47. checker.set_param(param).exect(
  48. Testcase{
  49. TensorValue(
  50. {1, 3, 1, 3, 4}, dtype::Uint8(),
  51. {0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0,
  52. 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0}),
  53. {}},
  54. Testcase{
  55. {},
  56. TensorValue(
  57. {1, 2, 1, 2, 2, 2, 4}, dtype::Uint8(),
  58. {0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0,
  59. 1, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0,
  60. 3, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0,
  61. 4, 0, 0, 0, 5, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0})});
  62. param.pad_h = 1;
  63. param.pad_w = 1;
  64. param.stride_h = 2;
  65. param.stride_w = 2;
  66. param.dilate_h = 2;
  67. param.dilate_w = 2;
  68. param.window_h = 3;
  69. param.window_w = 3;
  70. checker.set_param(param).exect(
  71. Testcase{
  72. TensorValue(
  73. {1, 6, 1, 7, 4}, dtype::Uint8(),
  74. {0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0,
  75. 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0,
  76. 8, 0, 0, 0, 9, 0, 0, 0, 10, 0, 0, 0, 11, 0, 0, 0,
  77. 12, 0, 0, 0, 13, 0, 0, 0, 14, 0, 0, 0, 15, 0, 0, 0,
  78. 16, 0, 0, 0, 17, 0, 0, 0, 18, 0, 0, 0, 19, 0, 0, 0,
  79. 20, 0, 0, 0, 21, 0, 0, 0, 22, 0, 0, 0, 23, 0, 0, 0,
  80. 24, 0, 0, 0, 25, 0, 0, 0, 26, 0, 0, 0, 27, 0, 0, 0,
  81. 28, 0, 0, 0, 29, 0, 0, 0, 30, 0, 0, 0, 31, 0, 0, 0,
  82. 32, 0, 0, 0, 33, 0, 0, 0, 34, 0, 0, 0, 35, 0, 0, 0,
  83. 36, 0, 0, 0, 37, 0, 0, 0, 38, 0, 0, 0, 39, 0, 0, 0,
  84. 40, 0, 0, 0, 41, 0, 0, 0}),
  85. {}},
  86. Testcase{
  87. {},
  88. TensorValue(
  89. {1, 2, 1, 3, 3, 3, 4}, dtype::Uint8(),
  90. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  91. 8, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0,
  92. 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  93. 8, 0, 0, 0, 10, 0, 0, 0, 12, 0, 0, 0, 22, 0, 0, 0,
  94. 24, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  95. 0, 0, 0, 0, 10, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
  96. 24, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  97. 8, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0,
  98. 24, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 38, 0, 0, 0,
  99. 8, 0, 0, 0, 10, 0, 0, 0, 12, 0, 0, 0, 22, 0, 0, 0,
  100. 24, 0, 0, 0, 26, 0, 0, 0, 36, 0, 0, 0, 38, 0, 0, 0,
  101. 40, 0, 0, 0, 10, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
  102. 24, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 38, 0, 0, 0,
  103. 40, 0, 0, 0, 0, 0, 0, 0})});
  104. }