Pooling.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #include "Pooling.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #include "arm_nnfunctions.h"
  5. #include "Test.h"
  6. void Pooling::test_avgpool_s8()
  7. {
  8. const q7_t *inp = input.ptr();
  9. q7_t *tmpin = tmpInput.ptr();
  10. q7_t *outp = output.ptr();
  11. q15_t *tempp = temp.ptr();
  12. memcpy(tmpin,inp,input.nbSamples());
  13. arm_avgpool_s8(
  14. DIM_IN_Y,
  15. DIM_IN_X,
  16. DIM_OUT_Y,
  17. DIM_OUT_X,
  18. STRIDE_Y,
  19. STRIDE_X,
  20. DIM_FILTER_Y,
  21. DIM_FILTER_X,
  22. PAD_HEIGHT,
  23. PAD_WIDTH,
  24. ACT_MIN,
  25. ACT_MAX,
  26. IN_CHANNEL,
  27. tmpin,
  28. tempp,
  29. outp);
  30. ASSERT_EQ(ref,output);
  31. }
  32. void Pooling::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr)
  33. {
  34. switch(id)
  35. {
  36. case Pooling::TEST_AVGPOOL_S8_1:
  37. input.reload(Pooling::INPUT1_S8_ID,mgr);
  38. ref.reload(Pooling::REF1_S8_ID,mgr);
  39. this->DIM_IN_X= 4;
  40. this->DIM_IN_Y= 2;
  41. this->DIM_OUT_X= 2;
  42. this->DIM_OUT_Y= 1;
  43. this->IN_CHANNEL= 101;
  44. this->DIM_FILTER_X= 2;
  45. this->DIM_FILTER_Y= 2;
  46. this->PAD_WIDTH= 0;
  47. this->PAD_HEIGHT= 0;
  48. this->STRIDE_X= 2;
  49. this->STRIDE_Y= 2;
  50. this->ACT_MIN= -128;
  51. this->ACT_MAX= 127;
  52. break;
  53. case Pooling::TEST_AVGPOOL_S8_2:
  54. input.reload(Pooling::INPUT2_S8_ID,mgr);
  55. ref.reload(Pooling::REF2_S8_ID,mgr);
  56. this->DIM_IN_X= 4;
  57. this->DIM_IN_Y= 2;
  58. this->DIM_OUT_X= 2;
  59. this->DIM_OUT_Y= 1;
  60. this->IN_CHANNEL= 1;
  61. this->DIM_FILTER_X= 2;
  62. this->DIM_FILTER_Y= 2;
  63. this->PAD_WIDTH= 0;
  64. this->PAD_HEIGHT= 0;
  65. this->STRIDE_X= 2;
  66. this->STRIDE_Y= 2;
  67. this->ACT_MIN= -128;
  68. this->ACT_MAX= 127;
  69. break;
  70. case Pooling::TEST_AVGPOOL_S8_3:
  71. input.reload(Pooling::INPUT3_S8_ID,mgr);
  72. ref.reload(Pooling::REF3_S8_ID,mgr);
  73. this->DIM_IN_X= 4;
  74. this->DIM_IN_Y= 2;
  75. this->DIM_OUT_X= 2;
  76. this->DIM_OUT_Y= 1;
  77. this->IN_CHANNEL= 1;
  78. this->DIM_FILTER_X= 2;
  79. this->DIM_FILTER_Y= 2;
  80. this->PAD_WIDTH= 0;
  81. this->PAD_HEIGHT= 0;
  82. this->STRIDE_X= 2;
  83. this->STRIDE_Y= 2;
  84. this->ACT_MIN= -8;
  85. this->ACT_MAX= 8;
  86. break;
  87. case Pooling::TEST_AVGPOOL_S8_4:
  88. input.reload(Pooling::INPUT4_S8_ID,mgr);
  89. ref.reload(Pooling::REF4_S8_ID,mgr);
  90. this->DIM_IN_X= 4;
  91. this->DIM_IN_Y= 2;
  92. this->DIM_OUT_X= 2;
  93. this->DIM_OUT_Y= 1;
  94. this->IN_CHANNEL= 1;
  95. this->DIM_FILTER_X= 2;
  96. this->DIM_FILTER_Y= 2;
  97. this->PAD_WIDTH= 0;
  98. this->PAD_HEIGHT= 0;
  99. this->STRIDE_X= 2;
  100. this->STRIDE_Y= 2;
  101. this->ACT_MIN= 0;
  102. this->ACT_MAX= 48;
  103. break;
  104. case Pooling::TEST_AVGPOOL_S8_5:
  105. input.reload(Pooling::INPUT5_S8_ID,mgr);
  106. ref.reload(Pooling::REF5_S8_ID,mgr);
  107. this->DIM_IN_X= 4;
  108. this->DIM_IN_Y= 2;
  109. this->DIM_OUT_X= 2;
  110. this->DIM_OUT_Y= 1;
  111. this->IN_CHANNEL= 1;
  112. this->DIM_FILTER_X= 2;
  113. this->DIM_FILTER_Y= 2;
  114. this->PAD_WIDTH= 0;
  115. this->PAD_HEIGHT= 0;
  116. this->STRIDE_X= 2;
  117. this->STRIDE_Y= 2;
  118. this->ACT_MIN= 0;
  119. this->ACT_MAX= 48;
  120. break;
  121. case Pooling::TEST_AVGPOOL_S8_6:
  122. input.reload(Pooling::INPUT6_S8_ID,mgr);
  123. ref.reload(Pooling::REF6_S8_ID,mgr);
  124. this->DIM_IN_X= 4;
  125. this->DIM_IN_Y= 2;
  126. this->DIM_OUT_X= 4;
  127. this->DIM_OUT_Y= 2;
  128. this->IN_CHANNEL= 1;
  129. this->DIM_FILTER_X= 2;
  130. this->DIM_FILTER_Y= 2;
  131. this->PAD_WIDTH= 0;
  132. this->PAD_HEIGHT= 0;
  133. this->STRIDE_X= 1;
  134. this->STRIDE_Y= 1;
  135. this->ACT_MIN= -128;
  136. this->ACT_MAX= 127;
  137. break;
  138. case Pooling::TEST_AVGPOOL_S8_7:
  139. input.reload(Pooling::INPUT7_S8_ID,mgr);
  140. ref.reload(Pooling::REF7_S8_ID,mgr);
  141. this->DIM_IN_X= 4;
  142. this->DIM_IN_Y= 2;
  143. this->DIM_OUT_X= 3;
  144. this->DIM_OUT_Y= 1;
  145. this->IN_CHANNEL= 1;
  146. this->DIM_FILTER_X= 2;
  147. this->DIM_FILTER_Y= 2;
  148. this->PAD_WIDTH= 0;
  149. this->PAD_HEIGHT= 0;
  150. this->STRIDE_X= 1;
  151. this->STRIDE_Y= 1;
  152. this->ACT_MIN= -128;
  153. this->ACT_MAX= 127;
  154. break;
  155. case Pooling::TEST_AVGPOOL_S8_8:
  156. input.reload(Pooling::INPUT8_S8_ID,mgr);
  157. ref.reload(Pooling::REF8_S8_ID,mgr);
  158. this->DIM_IN_X= 63;
  159. this->DIM_IN_Y= 63;
  160. this->DIM_OUT_X= 1;
  161. this->DIM_OUT_Y= 1;
  162. this->IN_CHANNEL= 1;
  163. this->DIM_FILTER_X= 63;
  164. this->DIM_FILTER_Y= 63;
  165. this->PAD_WIDTH= 0;
  166. this->PAD_HEIGHT= 0;
  167. this->STRIDE_X= 2;
  168. this->STRIDE_Y= 2;
  169. this->ACT_MIN= -128;
  170. this->ACT_MAX= 127;
  171. break;
  172. }
  173. temp.create(this->DIM_OUT_X * this->IN_CHANNEL,Pooling::TEMP_S8_ID,mgr);
  174. output.create(ref.nbSamples(),Pooling::OUTPUT_S8_ID,mgr);
  175. tmpInput.create(input.nbSamples(),Pooling::TEMPINPUT_S8_ID,mgr);
  176. }
  177. void Pooling::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  178. {
  179. output.dump(mgr);
  180. }