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.

conv_bias_multi_thread_benchmark.cpp 88 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058
  1. /**
  2. * \file dnn/test/arm_common/conv_bias_multi_thread_benchmark.cpp
  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. #include "test/arm_common/fixture.h"
  13. #include "test/common/benchmarker.h"
  14. #include "test/common/conv_bias.h"
  15. using namespace megdnn;
  16. using namespace test;
  17. using namespace conv_bias;
  18. #if MEGDNN_WITH_BENCHMARK
  19. namespace {
  20. void benchmark_impl(const param::ConvBias param,
  21. std::vector<std::pair<SmallVector<TensorShape>, float>>&
  22. shapes_and_computation,
  23. const std::string algo_name, size_t RUNS,
  24. TaskExecutorConfig&& multi_thread_config,
  25. TaskExecutorConfig&& single_thread_config,
  26. std::vector<DType>& data_type) {
  27. std::vector<float> multi_thread_times, single_thread_times;
  28. {
  29. auto multi_thread_hanle =
  30. create_cpu_handle(0, true, &multi_thread_config);
  31. auto benchmarker = Benchmarker<ConvBias>(multi_thread_hanle.get());
  32. benchmarker.set_times(RUNS)
  33. .set_display(false)
  34. .set_param(param)
  35. .set_dtype(0, data_type[0])
  36. .set_dtype(1, data_type[1])
  37. .set_dtype(2, data_type[2])
  38. .set_dtype(4, data_type[3])
  39. .set_before_exec_callback(
  40. conv_bias::ConvBiasAlgoChecker<ConvBias>(
  41. algo_name.c_str()));
  42. for (auto shape : shapes_and_computation) {
  43. multi_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
  44. }
  45. }
  46. {
  47. auto single_thread_handle =
  48. create_cpu_handle(0, true, &single_thread_config);
  49. auto benchmarker = Benchmarker<ConvBias>(single_thread_handle.get());
  50. benchmarker.set_times(RUNS)
  51. .set_display(false)
  52. .set_param(param)
  53. .set_dtype(0, data_type[0])
  54. .set_dtype(1, data_type[1])
  55. .set_dtype(2, data_type[2])
  56. .set_dtype(4, data_type[3])
  57. .set_before_exec_callback(
  58. conv_bias::ConvBiasAlgoChecker<ConvBias>(
  59. algo_name.c_str()));
  60. for (auto shape : shapes_and_computation) {
  61. single_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
  62. }
  63. }
  64. printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
  65. printf("core_ids:");
  66. for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
  67. printf("%zu ", multi_thread_config.affinity_core_set[i]);
  68. }
  69. printf(", Single thread core_id %zu\n",
  70. single_thread_config.affinity_core_set[0]);
  71. for (size_t i = 0; i < shapes_and_computation.size(); i++) {
  72. auto shapes = shapes_and_computation[i];
  73. printf("Bench case: ");
  74. for (auto&& shape : shapes.first) {
  75. printf("%s ", shape.to_string().c_str());
  76. }
  77. float computations = shapes.second;
  78. printf("%zu threads gflops: %f,\n single thread gflops: "
  79. "%f. spead up = %f, speedup/cores=%f\n",
  80. multi_thread_config.nr_thread,
  81. computations / multi_thread_times[i],
  82. computations / single_thread_times[i],
  83. single_thread_times[i] / multi_thread_times[i],
  84. single_thread_times[i] / multi_thread_times[i] /
  85. multi_thread_config.nr_thread);
  86. }
  87. }
  88. } // namespace
  89. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32) {
  90. constexpr size_t RUNS = 50;
  91. param::ConvBias param;
  92. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  93. param.pad_h = 1;
  94. param.pad_w = 1;
  95. param.stride_h = 1;
  96. param.stride_w = 1;
  97. param.sparse = param::ConvBias::Sparse::GROUP;
  98. std::vector<std::pair<SmallVector<TensorShape>, float>>
  99. shapes_and_computation;
  100. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  101. size_t FS, size_t group) {
  102. SmallVector<TensorShape> shapes{{N, IC, H, W},
  103. {group, OC / group, IC / group, FS, FS},
  104. {1, OC, 1, 1},
  105. {},
  106. {N, OC, H, W}};
  107. TensorShape dst{N, OC, H, W};
  108. float computations =
  109. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  110. dst.total_nr_elems()) *
  111. 1e-6;
  112. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  113. };
  114. bench_case(1, 32, 32, 200, 200, 3, 4);
  115. bench_case(1, 32, 32, 200, 200, 3, 32);
  116. bench_case(1, 32, 32, 128, 128, 3, 4);
  117. bench_case(1, 32, 32, 128, 128, 3, 32);
  118. bench_case(1, 32, 32, 100, 100, 3, 4);
  119. bench_case(1, 32, 32, 100, 100, 3, 32);
  120. bench_case(1, 32, 32, 80, 80, 3, 4);
  121. bench_case(1, 32, 32, 80, 80, 3, 32);
  122. std::string algo_name = "F32DIRECT";
  123. printf("Benchmark F32DIRECT_LARGE_GROUP algo\n");
  124. std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
  125. dtype::Float32(), dtype::Float32()};
  126. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  127. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  128. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  129. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  130. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  131. {1, {4}}, data_type);
  132. shapes_and_computation.clear();
  133. algo_name = "F32DIRECT";
  134. printf("Benchmark F32DIRECT_SMALL_GROUP algo\n");
  135. bench_case(1, 32, 32, 200, 200, 3, 1);
  136. bench_case(1, 32, 32, 128, 128, 3, 1);
  137. bench_case(1, 32, 32, 100, 100, 3, 1);
  138. bench_case(1, 32, 32, 80, 80, 3, 1);
  139. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  140. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  141. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  142. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  143. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  144. {1, {4}}, data_type);
  145. }
  146. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32_STR1) {
  147. constexpr size_t RUNS = 50;
  148. param::ConvBias param;
  149. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  150. param.pad_h = 1;
  151. param.pad_w = 1;
  152. param.stride_h = 1;
  153. param.stride_w = 1;
  154. param.sparse = param::ConvBias::Sparse::GROUP;
  155. std::vector<std::pair<SmallVector<TensorShape>, float>>
  156. shapes_and_computation;
  157. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  158. size_t FS, size_t group) {
  159. SmallVector<TensorShape> shapes{{N, IC, H, W},
  160. {group, OC / group, IC / group, FS, FS},
  161. {1, OC, 1, 1},
  162. {},
  163. {N, OC, H, W}};
  164. TensorShape dst{N, OC, H, W};
  165. float computations =
  166. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  167. dst.total_nr_elems()) *
  168. 1e-6;
  169. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  170. };
  171. bench_case(1, 32, 32, 200, 200, 3, 4);
  172. bench_case(1, 32, 32, 200, 200, 3, 32);
  173. bench_case(1, 32, 32, 128, 128, 3, 4);
  174. bench_case(1, 32, 32, 128, 128, 3, 32);
  175. bench_case(1, 32, 32, 100, 100, 3, 4);
  176. bench_case(1, 32, 32, 100, 100, 3, 32);
  177. bench_case(1, 32, 32, 80, 80, 3, 4);
  178. bench_case(1, 32, 32, 80, 80, 3, 32);
  179. std::string algo_name = "F32STRD1";
  180. printf("Benchmark F32STRD1_LARGE_GROUP algo\n");
  181. std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
  182. dtype::Float32(), dtype::Float32()};
  183. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  184. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  185. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  186. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  187. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  188. {1, {4}}, data_type);
  189. shapes_and_computation.clear();
  190. algo_name = "F32STRD1";
  191. printf("Benchmark F32STRD1_SMALL_GROUP algo\n");
  192. bench_case(1, 32, 32, 200, 200, 3, 1);
  193. bench_case(1, 32, 32, 128, 128, 3, 1);
  194. bench_case(1, 32, 32, 100, 100, 3, 1);
  195. bench_case(1, 32, 32, 80, 80, 3, 1);
  196. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  197. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  198. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  199. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  200. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  201. {1, {4}}, data_type);
  202. }
  203. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32_STR2) {
  204. constexpr size_t RUNS = 50;
  205. param::ConvBias param;
  206. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  207. param.pad_h = 1;
  208. param.pad_w = 1;
  209. param.stride_h = 2;
  210. param.stride_w = 2;
  211. param.sparse = param::ConvBias::Sparse::GROUP;
  212. std::vector<std::pair<SmallVector<TensorShape>, float>>
  213. shapes_and_computation;
  214. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  215. size_t FS, size_t group, size_t P, size_t S) {
  216. SmallVector<TensorShape> shapes{
  217. {N, IC, H, W},
  218. {group, OC / group, IC / group, FS, FS},
  219. {1, OC, 1, 1},
  220. {},
  221. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  222. TensorShape dst{N, OC, H, W};
  223. float computations =
  224. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  225. dst.total_nr_elems()) *
  226. 1e-6;
  227. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  228. };
  229. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
  230. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
  231. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
  232. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
  233. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
  234. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
  235. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
  236. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
  237. std::string algo_name = "F32STRD2";
  238. printf("Benchmark F32STRD2_LARGE_GROUP algo\n");
  239. std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
  240. dtype::Float32(), dtype::Float32()};
  241. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  242. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  243. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  244. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  245. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  246. {1, {4}}, data_type);
  247. shapes_and_computation.clear();
  248. algo_name = "F32STRD2";
  249. printf("Benchmark F32STRD2_SMALL_GROUP algo\n");
  250. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
  251. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
  252. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
  253. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
  254. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  255. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  256. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  257. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  258. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  259. {1, {4}}, data_type);
  260. }
  261. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  262. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF16) {
  263. constexpr size_t RUNS = 50;
  264. param::ConvBias param;
  265. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  266. param.pad_h = 1;
  267. param.pad_w = 1;
  268. param.stride_h = 1;
  269. param.stride_w = 1;
  270. param.sparse = param::ConvBias::Sparse::GROUP;
  271. std::vector<std::pair<SmallVector<TensorShape>, float>>
  272. shapes_and_computation;
  273. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  274. size_t FS, size_t group) {
  275. SmallVector<TensorShape> shapes{{N, IC, H, W},
  276. {group, OC / group, IC / group, FS, FS},
  277. {1, OC, 1, 1},
  278. {},
  279. {N, OC, H, W}};
  280. TensorShape dst{N, OC, H, W};
  281. float computations =
  282. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  283. dst.total_nr_elems()) *
  284. 1e-6;
  285. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  286. };
  287. bench_case(1, 32, 32, 200, 200, 3, 4);
  288. bench_case(1, 32, 32, 200, 200, 3, 32);
  289. bench_case(1, 32, 32, 128, 128, 3, 4);
  290. bench_case(1, 32, 32, 128, 128, 3, 32);
  291. bench_case(1, 32, 32, 100, 100, 3, 4);
  292. bench_case(1, 32, 32, 100, 100, 3, 32);
  293. bench_case(1, 32, 32, 80, 80, 3, 4);
  294. bench_case(1, 32, 32, 80, 80, 3, 32);
  295. std::string algo_name = "F16DIRECT";
  296. printf("Benchmark F16DIRECT_LARGE_GROUP algo\n");
  297. std::vector<DType> data_type = {dtype::Float16(), dtype::Float16(),
  298. dtype::Float16(), dtype::Float16()};
  299. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  300. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  301. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  302. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  303. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  304. {1, {4}}, data_type);
  305. shapes_and_computation.clear();
  306. algo_name = "F16DIRECT";
  307. printf("Benchmark F16DIRECT_SMALL_GROUP algo\n");
  308. bench_case(1, 32, 32, 200, 200, 3, 1);
  309. bench_case(1, 32, 32, 128, 128, 3, 1);
  310. bench_case(1, 32, 32, 100, 100, 3, 1);
  311. bench_case(1, 32, 32, 80, 80, 3, 1);
  312. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  313. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  314. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  315. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  316. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  317. {1, {4}}, data_type);
  318. }
  319. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF16_STR1) {
  320. constexpr size_t RUNS = 50;
  321. param::ConvBias param;
  322. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  323. param.pad_h = 1;
  324. param.pad_w = 1;
  325. param.stride_h = 1;
  326. param.stride_w = 1;
  327. param.sparse = param::ConvBias::Sparse::GROUP;
  328. std::vector<std::pair<SmallVector<TensorShape>, float>>
  329. shapes_and_computation;
  330. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  331. size_t FS, size_t group) {
  332. SmallVector<TensorShape> shapes{{N, IC, H, W},
  333. {group, OC / group, IC / group, FS, FS},
  334. {1, OC, 1, 1},
  335. {},
  336. {N, OC, H, W}};
  337. TensorShape dst{N, OC, H, W};
  338. float computations =
  339. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  340. dst.total_nr_elems()) *
  341. 1e-6;
  342. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  343. };
  344. bench_case(1, 32, 32, 200, 200, 3, 4);
  345. bench_case(1, 32, 32, 200, 200, 3, 32);
  346. bench_case(1, 32, 32, 128, 128, 3, 4);
  347. bench_case(1, 32, 32, 128, 128, 3, 32);
  348. bench_case(1, 32, 32, 100, 100, 3, 4);
  349. bench_case(1, 32, 32, 100, 100, 3, 32);
  350. bench_case(1, 32, 32, 80, 80, 3, 4);
  351. bench_case(1, 32, 32, 80, 80, 3, 32);
  352. std::string algo_name = "F16STRD1";
  353. printf("Benchmark F16STRD1_LARGE_GROUP algo\n");
  354. std::vector<DType> data_type = {dtype::Float16(), dtype::Float16(),
  355. dtype::Float16(), dtype::Float16()};
  356. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  357. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  358. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  359. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  360. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  361. {1, {4}}, data_type);
  362. shapes_and_computation.clear();
  363. algo_name = "F16STRD1";
  364. printf("Benchmark F16STRD1_SMALL_GROUP algo\n");
  365. bench_case(1, 32, 32, 200, 200, 3, 1);
  366. bench_case(1, 32, 32, 128, 128, 3, 1);
  367. bench_case(1, 32, 32, 100, 100, 3, 1);
  368. bench_case(1, 32, 32, 80, 80, 3, 1);
  369. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  370. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  371. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  372. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  373. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  374. {1, {4}}, data_type);
  375. }
  376. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_F16_NCHW88) {
  377. constexpr size_t RUNS = 50;
  378. std::string algo_name = "F16_CHANNEL_WISE_NCHW88";
  379. printf("Benchmarker F16_CHANNEL_WISE_NCHW88 algo\n");
  380. std::vector<DType> data_type = {dtype::Float16(), dtype::Float16(),
  381. dtype::Float16(), dtype::Float16()};
  382. auto bench_case = [&](size_t N, size_t IC, size_t H, size_t W, size_t FS,
  383. size_t P, size_t S) {
  384. param::ConvBias param;
  385. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  386. param.pad_h = P;
  387. param.pad_w = P;
  388. param.stride_h = S;
  389. param.stride_w = S;
  390. param.sparse = param::ConvBias::Sparse::GROUP;
  391. param.format = param::ConvBias::Format::NCHW88;
  392. size_t group = IC;
  393. size_t OC = IC;
  394. SmallVector<TensorShape> shapes{
  395. {N, IC, H, W, 8},
  396. {group, 1, 1, FS, FS, 8},
  397. {1, OC, 1, 1, 8},
  398. {},
  399. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 8}};
  400. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  401. (W + 2 * P - FS) / S + 1, 8};
  402. float computations =
  403. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  404. dst.total_nr_elems()) *
  405. 1e-6;
  406. std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
  407. std::make_pair(shapes, computations)};
  408. benchmark_impl(param, shape_arg, algo_name, RUNS, {4, {4, 5, 6, 7}},
  409. {1, {7}}, data_type);
  410. };
  411. bench_case(1, 64, 100, 100, 5, 2, 1);
  412. bench_case(1, 64, 56, 56, 5, 2, 1);
  413. bench_case(1, 64, 28, 28, 5, 2, 1);
  414. bench_case(1, 64, 100, 100, 5, 2, 2);
  415. bench_case(1, 64, 56, 56, 5, 2, 2);
  416. bench_case(1, 64, 28, 28, 5, 2, 2);
  417. bench_case(1, 64, 100, 100, 3, 1, 1);
  418. bench_case(1, 64, 56, 56, 3, 1, 1);
  419. bench_case(1, 64, 28, 28, 3, 1, 1);
  420. bench_case(1, 64, 100, 100, 3, 1, 2);
  421. bench_case(1, 64, 56, 56, 3, 1, 2);
  422. bench_case(1, 64, 28, 28, 3, 1, 2);
  423. bench_case(1, 64, 100, 100, 2, 0, 1);
  424. bench_case(1, 64, 56, 56, 2, 0, 1);
  425. bench_case(1, 64, 28, 28, 2, 0, 1);
  426. bench_case(1, 64, 100, 100, 2, 0, 2);
  427. bench_case(1, 64, 56, 56, 2, 0, 2);
  428. bench_case(1, 64, 28, 28, 2, 0, 2);
  429. }
  430. #endif
  431. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  432. BENCHMARK_CONVBIAS_DIRECT_INT8x8x16) {
  433. constexpr size_t RUNS = 50;
  434. param::ConvBias param;
  435. param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
  436. param.pad_h = 1;
  437. param.pad_w = 1;
  438. param.stride_h = 1;
  439. param.stride_w = 1;
  440. param.sparse = param::ConvBias::Sparse::GROUP;
  441. std::vector<std::pair<SmallVector<TensorShape>, float>>
  442. shapes_and_computation;
  443. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  444. size_t FS, size_t group) {
  445. SmallVector<TensorShape> shapes{{N, IC, H, W},
  446. {group, OC / group, IC / group, FS, FS},
  447. {},
  448. {},
  449. {N, OC, H, W}};
  450. TensorShape dst{N, OC, H, W};
  451. float computations =
  452. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  453. dst.total_nr_elems()) *
  454. 1e-6;
  455. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  456. };
  457. bench_case(1, 32, 32, 200, 200, 3, 4);
  458. bench_case(1, 32, 32, 200, 200, 3, 32);
  459. bench_case(1, 32, 32, 128, 128, 3, 4);
  460. bench_case(1, 32, 32, 128, 128, 3, 32);
  461. bench_case(1, 32, 32, 100, 100, 3, 4);
  462. bench_case(1, 32, 32, 100, 100, 3, 32);
  463. bench_case(1, 32, 32, 80, 80, 3, 4);
  464. bench_case(1, 32, 32, 80, 80, 3, 32);
  465. std::string algo_name = "I8816DIRECT";
  466. printf("Benchmark I8816DIRECT_LARGE_GROUP algo\n");
  467. std::vector<DType> data_type = {dtype::Int8(), dtype::Int8(),
  468. dtype::Int16(), dtype::Int16()};
  469. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  470. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  471. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  472. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  473. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  474. {1, {4}}, data_type);
  475. shapes_and_computation.clear();
  476. algo_name = "I8816DIRECT";
  477. printf("Benchmark I8816DIRECT_SMALL_GROUP algo\n");
  478. bench_case(1, 32, 32, 200, 200, 3, 1);
  479. bench_case(1, 32, 32, 128, 128, 3, 1);
  480. bench_case(1, 32, 32, 100, 100, 3, 1);
  481. bench_case(1, 32, 32, 80, 80, 3, 1);
  482. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  483. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  484. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  485. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  486. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  487. {1, {4}}, data_type);
  488. }
  489. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  490. BENCHMARK_CONVBIAS_DIRECT_INT8x8x16_STR2) {
  491. constexpr size_t RUNS = 50;
  492. param::ConvBias param;
  493. param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
  494. param.pad_h = 1;
  495. param.pad_w = 1;
  496. param.stride_h = 2;
  497. param.stride_w = 2;
  498. param.sparse = param::ConvBias::Sparse::GROUP;
  499. std::vector<std::pair<SmallVector<TensorShape>, float>>
  500. shapes_and_computation;
  501. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  502. size_t FS, size_t group, size_t P, size_t S) {
  503. SmallVector<TensorShape> shapes{
  504. {N, IC, H, W},
  505. {group, OC / group, IC / group, FS, FS},
  506. {},
  507. {},
  508. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  509. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  510. (W + 2 * P - FS) / S + 1};
  511. float computations =
  512. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  513. dst.total_nr_elems()) *
  514. 1e-6;
  515. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  516. };
  517. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
  518. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
  519. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
  520. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
  521. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
  522. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
  523. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
  524. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
  525. std::string algo_name = "I8816STRD2";
  526. printf("Benchmark I8816STRD2_LARGE_GROUP algo\n");
  527. std::vector<DType> data_type = {dtype::Int8(), dtype::Int8(),
  528. dtype::Int16(), dtype::Int16()};
  529. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  530. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  531. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  532. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  533. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  534. {1, {4}}, data_type);
  535. shapes_and_computation.clear();
  536. algo_name = "I8816STRD2";
  537. printf("Benchmark I8816STRD2_SMALL_GROUP algo\n");
  538. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
  539. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
  540. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
  541. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
  542. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  543. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  544. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  545. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  546. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  547. {1, {4}}, data_type);
  548. }
  549. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  550. BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE1) {
  551. constexpr size_t RUNS = 50;
  552. param::ConvBias param;
  553. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  554. param.pad_h = 1;
  555. param.pad_w = 1;
  556. param.stride_h = 1;
  557. param.stride_w = 1;
  558. param.sparse = param::ConvBias::Sparse::GROUP;
  559. std::vector<std::pair<SmallVector<TensorShape>, float>>
  560. shapes_and_computation;
  561. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  562. size_t FS, size_t group, size_t P, size_t S) {
  563. SmallVector<TensorShape> shapes{
  564. {N, IC, H, W},
  565. {group, OC / group, IC / group, FS, FS},
  566. {1, OC, 1, 1},
  567. {},
  568. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  569. TensorShape dst{N, OC, H, W};
  570. float computations =
  571. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  572. dst.total_nr_elems()) *
  573. 1e-6;
  574. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  575. };
  576. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
  577. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
  578. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
  579. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
  580. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
  581. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
  582. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
  583. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
  584. std::string algo_name = "S8STRD1";
  585. printf("Benchmark S8STRD1_LARGE_GROUP algo\n");
  586. std::vector<DType> data_type = {
  587. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  588. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  589. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  590. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  591. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  592. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  593. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  594. {1, {4}}, data_type);
  595. shapes_and_computation.clear();
  596. algo_name = "S8STRD1";
  597. printf("Benchmark S8STRD1_SMALL_GROUP algo\n");
  598. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
  599. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
  600. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
  601. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
  602. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  603. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  604. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  605. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  606. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  607. {1, {4}}, data_type);
  608. }
  609. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_INT8_NCHW44) {
  610. constexpr size_t RUNS = 40;
  611. std::vector<DType> data_type = {
  612. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  613. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  614. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  615. size_t FS, size_t group, size_t P, size_t S,
  616. bool is_nchw = false) {
  617. param::ConvBias param;
  618. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  619. param.pad_h = P;
  620. param.pad_w = P;
  621. param.stride_h = S;
  622. param.stride_w = S;
  623. param.sparse = param::ConvBias::Sparse::DENSE;
  624. param.format = param::ConvBias::Format::NCHW44;
  625. auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
  626. auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
  627. TensorShape src = {N, IC / 4, H, W, 4};
  628. TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
  629. if (group > 1) {
  630. filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
  631. param.sparse = param::ConvBias::Sparse::GROUP;
  632. }
  633. if (is_nchw) {
  634. src = {N, IC, H, W};
  635. filter = {OC / 4, FS, FS, IC, 4};
  636. }
  637. TensorShape bias = {1, OC / 4, 1, 1, 4};
  638. TensorShape dst = {N, OC / 4, OH, OW, 4};
  639. SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
  640. float computations =
  641. (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
  642. dst.total_nr_elems()) *
  643. 1e-6;
  644. std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
  645. std::make_pair(shapes, computations)};
  646. benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
  647. {1, {7}}, data_type);
  648. };
  649. bench_case(1, 2, 64, 160, 160, 1, 1, 0, 1, true);
  650. bench_case(1, 3, 64, 224, 224, 7, 1, 3, 2, true);
  651. bench_case(1, 64, 64, 56, 56, 3, 1, 1, 1);
  652. bench_case(1, 128, 128, 28, 28, 3, 1, 1, 1);
  653. bench_case(1, 256, 256, 14, 14, 3, 1, 1, 1);
  654. bench_case(1, 512, 512, 7, 7, 3, 1, 1, 1);
  655. bench_case(1, 64, 64, 56, 56, 3, 4, 1, 1);
  656. bench_case(1, 128, 128, 28, 28, 3, 4, 1, 1);
  657. bench_case(1, 256, 256, 14, 14, 3, 4, 1, 1);
  658. bench_case(1, 512, 512, 7, 7, 3, 4, 1, 1);
  659. bench_case(1, 4, 64, 224, 224, 7, 1, 1, 2);
  660. bench_case(1, 256, 128, 56, 56, 3, 1, 1, 2);
  661. bench_case(1, 512, 256, 28, 28, 3, 1, 1, 2);
  662. bench_case(1, 4, 32, 224, 224, 3, 1, 1, 2);
  663. bench_case(1, 256, 128, 56, 56, 3, 4, 1, 2);
  664. bench_case(1, 512, 256, 28, 28, 3, 4, 1, 2);
  665. }
  666. #if MGB_ENABLE_DOT
  667. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_INT8_NCHW44_DOT) {
  668. constexpr size_t RUNS = 40;
  669. std::vector<DType> data_type = {
  670. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  671. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  672. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  673. size_t FS, size_t group, size_t P, size_t S,
  674. bool is_nchw = false) {
  675. param::ConvBias param;
  676. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  677. param.pad_h = P;
  678. param.pad_w = P;
  679. param.stride_h = S;
  680. param.stride_w = S;
  681. param.sparse = param::ConvBias::Sparse::DENSE;
  682. param.format = param::ConvBias::Format::NCHW44_DOT;
  683. auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
  684. auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
  685. TensorShape src = {N, IC / 4, H, W, 4};
  686. TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
  687. if (group > 1) {
  688. filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
  689. param.sparse = param::ConvBias::Sparse::GROUP;
  690. }
  691. if (is_nchw) {
  692. src = {N, IC, H, W};
  693. filter = {OC / 4, FS, FS, IC, 4};
  694. }
  695. TensorShape bias = {1, OC / 4, 1, 1, 4};
  696. TensorShape dst = {N, OC / 4, OH, OW, 4};
  697. SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
  698. float computations =
  699. (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
  700. dst.total_nr_elems()) *
  701. 1e-6;
  702. std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
  703. std::make_pair(shapes, computations)};
  704. benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
  705. {1, {7}}, data_type);
  706. };
  707. bench_case(1, 64, 64, 56, 56, 3, 1, 1, 1);
  708. bench_case(1, 128, 128, 28, 28, 3, 1, 1, 1);
  709. bench_case(1, 256, 256, 14, 14, 3, 1, 1, 1);
  710. bench_case(1, 512, 512, 7, 7, 3, 1, 1, 1);
  711. bench_case(1, 64, 64, 56, 56, 3, 4, 1, 1);
  712. bench_case(1, 128, 128, 28, 28, 3, 4, 1, 1);
  713. bench_case(1, 256, 256, 14, 14, 3, 4, 1, 1);
  714. bench_case(1, 512, 512, 7, 7, 3, 4, 1, 1);
  715. }
  716. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_INT8_NCHW44_DOT_S2) {
  717. constexpr size_t RUNS = 40;
  718. std::vector<DType> data_type = {
  719. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  720. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  721. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  722. size_t FS, size_t group, size_t P, size_t S,
  723. bool is_nchw = false) {
  724. param::ConvBias param;
  725. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  726. param.pad_h = P;
  727. param.pad_w = P;
  728. param.stride_h = S;
  729. param.stride_w = S;
  730. param.sparse = param::ConvBias::Sparse::DENSE;
  731. param.format = param::ConvBias::Format::NCHW44_DOT;
  732. auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
  733. auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
  734. TensorShape src = {N, IC / 4, H, W, 4};
  735. TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
  736. if (group > 1) {
  737. filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
  738. param.sparse = param::ConvBias::Sparse::GROUP;
  739. }
  740. if (is_nchw) {
  741. src = {N, IC, H, W};
  742. filter = {OC / 4, FS, FS, IC, 4};
  743. }
  744. TensorShape bias = {1, OC / 4, 1, 1, 4};
  745. TensorShape dst = {N, OC / 4, OH, OW, 4};
  746. SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
  747. float computations =
  748. (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
  749. dst.total_nr_elems()) *
  750. 1e-6;
  751. std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
  752. std::make_pair(shapes, computations)};
  753. benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
  754. {1, {7}}, data_type);
  755. };
  756. bench_case(1, 64, 64, 56, 56, 3, 1, 1, 2);
  757. bench_case(1, 64, 64, 128, 128, 3, 1, 1, 2);
  758. bench_case(1, 64, 64, 256, 256, 3, 1, 1, 2);
  759. bench_case(1, 64, 64, 156, 156, 3, 1, 1, 2);
  760. bench_case(1, 128, 128, 28, 28, 3, 1, 1, 2);
  761. bench_case(1, 256, 256, 14, 14, 3, 1, 1, 2);
  762. bench_case(1, 512, 512, 7, 7, 3, 1, 1, 2);
  763. bench_case(1, 64, 64, 56, 56, 3, 4, 1, 2);
  764. bench_case(1, 128, 128, 28, 28, 3, 4, 1, 2);
  765. bench_case(1, 256, 256, 14, 14, 3, 4, 1, 2);
  766. bench_case(1, 512, 512, 7, 7, 3, 4, 1, 2);
  767. }
  768. #endif
  769. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_FLOAT_NCHW44) {
  770. constexpr size_t RUNS = 40;
  771. std::vector<DType> data_type = {
  772. dtype::Float32(), dtype::Float32(),
  773. dtype::Float32(), dtype::Float32()};
  774. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  775. size_t FS, size_t group, size_t P, size_t S,
  776. bool is_nchw = false) {
  777. param::ConvBias param;
  778. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  779. param.pad_h = P;
  780. param.pad_w = P;
  781. param.stride_h = S;
  782. param.stride_w = S;
  783. param.sparse = param::ConvBias::Sparse::DENSE;
  784. param.format = param::ConvBias::Format::NCHW44;
  785. auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
  786. auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
  787. TensorShape src = {N, IC / 4, H, W, 4};
  788. TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
  789. if (group > 1) {
  790. filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
  791. param.sparse = param::ConvBias::Sparse::GROUP;
  792. }
  793. if (is_nchw) {
  794. src = {N, IC, H, W};
  795. filter = {OC / 4, FS, FS, IC, 4};
  796. }
  797. TensorShape bias = {1, OC / 4, 1, 1, 4};
  798. TensorShape dst = {N, OC / 4, OH, OW, 4};
  799. SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
  800. float computations =
  801. (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
  802. dst.total_nr_elems()) *
  803. 1e-6;
  804. std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
  805. std::make_pair(shapes, computations)};
  806. benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
  807. {1, {7}}, data_type);
  808. };
  809. bench_case(1, 64, 64, 56, 56, 3, 1, 1, 2);
  810. bench_case(1, 128, 128, 28, 28, 3, 1, 1, 2);
  811. bench_case(1, 256, 256, 14, 14, 3, 1, 1, 2);
  812. bench_case(1, 512, 512, 7, 7, 3, 1, 1, 2);
  813. bench_case(1, 64, 64, 56, 56, 3, 4, 1, 2);
  814. bench_case(1, 128, 128, 28, 28, 3, 4, 1, 2);
  815. bench_case(1, 256, 256, 14, 14, 3, 4, 1, 2);
  816. bench_case(1, 512, 512, 7, 7, 3, 4, 1, 2);
  817. bench_case(1, 64, 64, 56*2, 56*2, 3, 4, 1, 2);
  818. bench_case(1, 128, 128, 28*2, 28*2, 3, 4, 1, 2);
  819. bench_case(1, 256, 256, 14*2, 14*2, 3, 4, 1, 2);
  820. bench_case(1, 512, 512, 7*2, 7*2, 3, 4, 1, 2);
  821. }
  822. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  823. BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE2) {
  824. constexpr size_t RUNS = 50;
  825. param::ConvBias param;
  826. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  827. param.pad_h = 1;
  828. param.pad_w = 1;
  829. param.stride_h = 2;
  830. param.stride_w = 2;
  831. param.sparse = param::ConvBias::Sparse::GROUP;
  832. std::vector<std::pair<SmallVector<TensorShape>, float>>
  833. shapes_and_computation;
  834. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  835. size_t FS, size_t group, size_t P, size_t S) {
  836. SmallVector<TensorShape> shapes{
  837. {N, IC, H, W},
  838. {group, OC / group, IC / group, FS, FS},
  839. {1, OC, 1, 1},
  840. {},
  841. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  842. TensorShape dst{N, OC, H, W};
  843. float computations =
  844. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  845. dst.total_nr_elems()) *
  846. 1e-6;
  847. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  848. };
  849. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
  850. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
  851. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
  852. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
  853. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
  854. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
  855. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
  856. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
  857. std::string algo_name = "S8STRD2";
  858. printf("Benchmark S8STRD2_LARGE_GROUP algo\n");
  859. std::vector<DType> data_type = {
  860. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  861. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  862. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  863. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  864. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  865. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  866. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  867. {1, {4}}, data_type);
  868. shapes_and_computation.clear();
  869. algo_name = "S8STRD2";
  870. printf("Benchmark S8STRD2_SMALL_GROUP algo\n");
  871. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
  872. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
  873. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
  874. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
  875. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  876. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  877. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  878. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  879. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  880. {1, {4}}, data_type);
  881. }
  882. #if MGB_ENABLE_DOT
  883. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  884. BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE1_WITHDOTPROD) {
  885. constexpr size_t RUNS = 50;
  886. param::ConvBias param;
  887. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  888. param.pad_h = 1;
  889. param.pad_w = 1;
  890. param.stride_h = 1;
  891. param.stride_w = 1;
  892. param.sparse = param::ConvBias::Sparse::GROUP;
  893. std::vector<std::pair<SmallVector<TensorShape>, float>>
  894. shapes_and_computation;
  895. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  896. size_t FS, size_t group, size_t P, size_t S) {
  897. SmallVector<TensorShape> shapes{
  898. {N, IC, H, W},
  899. {group, OC / group, IC / group, FS, FS},
  900. {1, OC, 1, 1},
  901. {},
  902. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  903. TensorShape dst{N, OC, H, W};
  904. float computations =
  905. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  906. dst.total_nr_elems()) *
  907. 1e-6;
  908. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  909. };
  910. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
  911. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
  912. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
  913. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
  914. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
  915. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
  916. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
  917. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
  918. std::string algo_name = "ARMDOTS8STRD1";
  919. printf("Benchmark ARMDOTS8STRD1_LARGE_GROUP algo\n");
  920. std::vector<DType> data_type = {
  921. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  922. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  923. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  924. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  925. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  926. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  927. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  928. {1, {4}}, data_type);
  929. shapes_and_computation.clear();
  930. algo_name = "ARMDOTS8STRD1";
  931. printf("Benchmark ARMDOTS8STRD1_SMALL_GROUP algo\n");
  932. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
  933. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
  934. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
  935. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
  936. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  937. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  938. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  939. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  940. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  941. {1, {4}}, data_type);
  942. }
  943. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  944. BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE2_WITHDOTPROD) {
  945. constexpr size_t RUNS = 50;
  946. param::ConvBias param;
  947. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  948. param.pad_h = 1;
  949. param.pad_w = 1;
  950. param.stride_h = 2;
  951. param.stride_w = 2;
  952. param.sparse = param::ConvBias::Sparse::GROUP;
  953. std::vector<std::pair<SmallVector<TensorShape>, float>>
  954. shapes_and_computation;
  955. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  956. size_t FS, size_t group, size_t P, size_t S) {
  957. SmallVector<TensorShape> shapes{
  958. {N, IC, H, W},
  959. {group, OC / group, IC / group, FS, FS},
  960. {1, OC, 1, 1},
  961. {},
  962. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  963. TensorShape dst{N, OC, H, W};
  964. float computations =
  965. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  966. dst.total_nr_elems()) *
  967. 1e-6;
  968. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  969. };
  970. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
  971. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
  972. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
  973. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
  974. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
  975. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
  976. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
  977. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
  978. std::string algo_name = "ARMDOTS8STRD2";
  979. printf("Benchmark ARMDOTS8STRD2_LARGE_GROUP algo\n");
  980. std::vector<DType> data_type = {
  981. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  982. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  983. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  984. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  985. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  986. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  987. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  988. {1, {4}}, data_type);
  989. shapes_and_computation.clear();
  990. algo_name = "ARMDOTS8STRD2";
  991. printf("Benchmark ARMDOTS8STRD2_SMALL_GROUP algo\n");
  992. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
  993. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
  994. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
  995. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
  996. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  997. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  998. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  999. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1000. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1001. {1, {4}}, data_type);
  1002. }
  1003. #endif
  1004. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1005. BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE1) {
  1006. constexpr size_t RUNS = 50;
  1007. param::ConvBias param;
  1008. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1009. param.pad_h = 1;
  1010. param.pad_w = 1;
  1011. param.stride_h = 1;
  1012. param.stride_w = 1;
  1013. param.sparse = param::ConvBias::Sparse::GROUP;
  1014. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1015. shapes_and_computation;
  1016. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1017. size_t FS, size_t group, size_t P, size_t S) {
  1018. SmallVector<TensorShape> shapes{
  1019. {N, IC, H, W},
  1020. {group, OC / group, IC / group, FS, FS},
  1021. {1, OC, 1, 1},
  1022. {},
  1023. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  1024. TensorShape dst{N, OC, H, W};
  1025. float computations =
  1026. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1027. dst.total_nr_elems()) *
  1028. 1e-6;
  1029. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1030. };
  1031. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
  1032. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
  1033. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
  1034. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
  1035. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
  1036. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
  1037. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
  1038. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
  1039. std::string algo_name = "QU8STRD1";
  1040. printf("Benchmark QU8STRD1_LARGE_GROUP algo\n");
  1041. std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
  1042. dtype::Quantized8Asymm(0.2f, 120),
  1043. dtype::QuantizedS32(0.04f),
  1044. dtype::Quantized8Asymm(1.4f, 110)};
  1045. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1046. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1047. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1048. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1049. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1050. {1, {4}}, data_type);
  1051. shapes_and_computation.clear();
  1052. algo_name = "QU8STRD1";
  1053. printf("Benchmark QU8STRD1_SMALL_GROUP algo\n");
  1054. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
  1055. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
  1056. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
  1057. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
  1058. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1059. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1060. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1061. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1062. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1063. {1, {4}}, data_type);
  1064. }
  1065. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1066. BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE2) {
  1067. constexpr size_t RUNS = 50;
  1068. param::ConvBias param;
  1069. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1070. param.pad_h = 1;
  1071. param.pad_w = 1;
  1072. param.stride_h = 2;
  1073. param.stride_w = 2;
  1074. param.sparse = param::ConvBias::Sparse::GROUP;
  1075. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1076. shapes_and_computation;
  1077. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1078. size_t FS, size_t group, size_t P, size_t S) {
  1079. SmallVector<TensorShape> shapes{
  1080. {N, IC, H, W},
  1081. {group, OC / group, IC / group, FS, FS},
  1082. {1, OC, 1, 1},
  1083. {},
  1084. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  1085. TensorShape dst{N, OC, H, W};
  1086. float computations =
  1087. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1088. dst.total_nr_elems()) *
  1089. 1e-6;
  1090. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1091. };
  1092. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
  1093. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
  1094. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
  1095. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
  1096. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
  1097. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
  1098. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
  1099. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
  1100. std::string algo_name = "QU8STRD2";
  1101. printf("Benchmark QU8STRD2_LARGE_GROUP algo\n");
  1102. std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
  1103. dtype::Quantized8Asymm(0.2f, 120),
  1104. dtype::QuantizedS32(0.04f),
  1105. dtype::Quantized8Asymm(1.4f, 110)};
  1106. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1107. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1108. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1109. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1110. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1111. {1, {4}}, data_type);
  1112. shapes_and_computation.clear();
  1113. algo_name = "QU8STRD2";
  1114. printf("Benchmark QU8STRD2_SMALL_GROUP algo\n");
  1115. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
  1116. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
  1117. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
  1118. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
  1119. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1120. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1121. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1122. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1123. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1124. {1, {4}}, data_type);
  1125. }
  1126. #if MGB_ENABLE_DOT
  1127. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1128. BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE1_WITHDOTPROD) {
  1129. constexpr size_t RUNS = 50;
  1130. param::ConvBias param;
  1131. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1132. param.pad_h = 1;
  1133. param.pad_w = 1;
  1134. param.stride_h = 1;
  1135. param.stride_w = 1;
  1136. param.sparse = param::ConvBias::Sparse::GROUP;
  1137. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1138. shapes_and_computation;
  1139. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1140. size_t FS, size_t group, size_t P, size_t S) {
  1141. SmallVector<TensorShape> shapes{
  1142. {N, IC, H, W},
  1143. {group, OC / group, IC / group, FS, FS},
  1144. {1, OC, 1, 1},
  1145. {},
  1146. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  1147. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  1148. (W + 2 * P - FS) / S + 1};
  1149. float computations =
  1150. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1151. dst.total_nr_elems()) *
  1152. 1e-6;
  1153. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1154. };
  1155. bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
  1156. bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
  1157. bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
  1158. bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
  1159. bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
  1160. bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
  1161. bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
  1162. bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
  1163. std::string algo_name = "ARMDOTU8STRD1";
  1164. printf("Benchmark ARMDOTU8STRD1_LARGE_GROUP algo\n");
  1165. std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
  1166. dtype::Quantized8Asymm(0.2f, 120),
  1167. dtype::QuantizedS32(0.04f),
  1168. dtype::Quantized8Asymm(1.4f, 110)};
  1169. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1170. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1171. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1172. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1173. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1174. {1, {4}}, data_type);
  1175. shapes_and_computation.clear();
  1176. algo_name = "ARMDOTU8STRD1";
  1177. printf("Benchmark ARMDOTS8STRD1_SMALL_GROUP algo\n");
  1178. bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
  1179. bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
  1180. bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
  1181. bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
  1182. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1183. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1184. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1185. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1186. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1187. {1, {4}}, data_type);
  1188. }
  1189. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1190. BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE2_WITHDOTPROD) {
  1191. constexpr size_t RUNS = 50;
  1192. param::ConvBias param;
  1193. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1194. param.pad_h = 1;
  1195. param.pad_w = 1;
  1196. param.stride_h = 2;
  1197. param.stride_w = 2;
  1198. param.sparse = param::ConvBias::Sparse::GROUP;
  1199. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1200. shapes_and_computation;
  1201. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1202. size_t FS, size_t group, size_t P, size_t S) {
  1203. SmallVector<TensorShape> shapes{
  1204. {N, IC, H, W},
  1205. {group, OC / group, IC / group, FS, FS},
  1206. {1, OC, 1, 1},
  1207. {},
  1208. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
  1209. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  1210. (W + 2 * P - FS) / S + 1};
  1211. float computations =
  1212. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1213. dst.total_nr_elems()) *
  1214. 1e-6;
  1215. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1216. };
  1217. bench_case(1, 32, 32, 200, 200, 5, 4, 1, 2);
  1218. bench_case(1, 32, 32, 200, 200, 5, 32, 1, 2);
  1219. bench_case(1, 32, 32, 128, 128, 5, 4, 1, 2);
  1220. bench_case(1, 32, 32, 128, 128, 5, 32, 1, 2);
  1221. bench_case(1, 32, 32, 100, 100, 5, 4, 1, 2);
  1222. bench_case(1, 32, 32, 100, 100, 5, 32, 1, 2);
  1223. bench_case(1, 32, 32, 80, 80, 5, 4, 1, 2);
  1224. bench_case(1, 32, 32, 80, 80, 5, 32, 1, 2);
  1225. std::string algo_name = "ARMDOTU8STRD2";
  1226. printf("Benchmark ARMDOTU8STRD2_LARGE_GROUP algo\n");
  1227. std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
  1228. dtype::Quantized8Asymm(0.2f, 120),
  1229. dtype::QuantizedS32(0.04f),
  1230. dtype::Quantized8Asymm(1.4f, 110)};
  1231. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1232. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1233. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1234. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1235. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1236. {1, {4}}, data_type);
  1237. shapes_and_computation.clear();
  1238. algo_name = "ARMDOTU8STRD2";
  1239. printf("Benchmark ARMDOTU8STRD2_SMALL_GROUP algo\n");
  1240. bench_case(1, 32, 32, 200, 200, 5, 1, 1, 2);
  1241. bench_case(1, 32, 32, 128, 128, 5, 1, 1, 2);
  1242. bench_case(1, 32, 32, 100, 100, 5, 1, 1, 2);
  1243. bench_case(1, 32, 32, 80, 80, 5, 1, 1, 2);
  1244. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1245. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1246. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1247. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1248. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1249. {1, {4}}, data_type);
  1250. }
  1251. #endif
  1252. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_WINOGRAD_F32) {
  1253. constexpr size_t RUNS = 50;
  1254. param::ConvBias param;
  1255. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1256. param.pad_h = 1;
  1257. param.pad_w = 1;
  1258. param.stride_h = 1;
  1259. param.stride_w = 1;
  1260. param.sparse = param::ConvBias::Sparse::GROUP;
  1261. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1262. shapes_and_computation;
  1263. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1264. size_t FS, size_t group) {
  1265. SmallVector<TensorShape> shapes{{N, IC, H, W},
  1266. {group, OC / group, IC / group, FS, FS},
  1267. {1, OC, 1, 1},
  1268. {},
  1269. {N, OC, H, W}};
  1270. TensorShape dst{N, OC, H, W};
  1271. float computations =
  1272. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1273. dst.total_nr_elems()) *
  1274. 1e-6;
  1275. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1276. };
  1277. bench_case(1, 32, 32, 200, 200, 3, 4);
  1278. bench_case(1, 32, 32, 200, 200, 3, 1);
  1279. bench_case(1, 32, 32, 128, 128, 3, 4);
  1280. bench_case(1, 32, 32, 128, 128, 3, 1);
  1281. bench_case(1, 32, 32, 100, 100, 3, 4);
  1282. bench_case(1, 32, 32, 100, 100, 3, 1);
  1283. bench_case(1, 32, 32, 80, 80, 3, 4);
  1284. bench_case(1, 512, 512, 14, 14, 3, 1);
  1285. bench_case(1, 512, 256, 14, 14, 3, 1);
  1286. bench_case(1, 512, 128, 14, 14, 3, 1);
  1287. bench_case(1, 512, 64, 14, 14, 3, 1);
  1288. bench_case(1, 512, 512, 7, 7, 3, 1);
  1289. bench_case(1, 512, 256, 7, 7, 3, 1);
  1290. bench_case(1, 512, 128, 7, 7, 3, 1);
  1291. bench_case(1, 512, 64, 7, 7, 3, 1);
  1292. std::string algo_name;
  1293. #if MEGDNN_AARCH64
  1294. algo_name = "WINOGRAD:AARCH64_F32_MK4_4x16:4:2";
  1295. #else
  1296. algo_name = "WINOGRAD:ARMV7_F32_MK4_4x8:4:2";
  1297. #endif
  1298. std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
  1299. dtype::Float32(), dtype::Float32()};
  1300. printf("Benchmark WINOGRAD_F32_MK4 algo\n");
  1301. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1302. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1303. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1304. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1305. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1306. {1, {4}}, data_type);
  1307. }
  1308. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_WINOGRAD_INT8) {
  1309. constexpr size_t RUNS = 50;
  1310. param::ConvBias param;
  1311. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1312. param.pad_h = 1;
  1313. param.pad_w = 1;
  1314. param.stride_h = 1;
  1315. param.stride_w = 1;
  1316. param.sparse = param::ConvBias::Sparse::GROUP;
  1317. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1318. shapes_and_computation;
  1319. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1320. size_t FS, size_t group) {
  1321. SmallVector<TensorShape> shapes{{N, IC, H, W},
  1322. {group, OC / group, IC / group, FS, FS},
  1323. {1, OC, 1, 1},
  1324. {},
  1325. {N, OC, H, W}};
  1326. TensorShape dst{N, OC, H, W};
  1327. float computations =
  1328. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1329. dst.total_nr_elems()) *
  1330. 1e-6;
  1331. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1332. };
  1333. bench_case(1, 32, 32, 200, 200, 3, 4);
  1334. bench_case(1, 32, 32, 200, 200, 3, 1);
  1335. bench_case(1, 32, 32, 128, 128, 3, 4);
  1336. bench_case(1, 32, 32, 128, 128, 3, 1);
  1337. bench_case(1, 32, 32, 100, 100, 3, 4);
  1338. bench_case(1, 32, 32, 100, 100, 3, 1);
  1339. bench_case(1, 32, 32, 80, 80, 3, 4);
  1340. bench_case(1, 512, 512, 14, 14, 3, 1);
  1341. bench_case(1, 512, 256, 14, 14, 3, 1);
  1342. bench_case(1, 512, 128, 14, 14, 3, 1);
  1343. bench_case(1, 512, 64, 14, 14, 3, 1);
  1344. bench_case(1, 512, 512, 7, 7, 3, 1);
  1345. bench_case(1, 512, 256, 7, 7, 3, 1);
  1346. bench_case(1, 512, 128, 7, 7, 3, 1);
  1347. bench_case(1, 512, 64, 7, 7, 3, 1);
  1348. std::string algo_name;
  1349. #if MEGDNN_AARCH64
  1350. algo_name = "WINOGRAD:AARCH64_INT16X16X32_MK8_8X8:8:2:32";
  1351. #else
  1352. algo_name = "WINOGRAD:ARMV7_INT16X16X32_MK8_4X8:8:2:32";
  1353. #endif
  1354. std::vector<DType> data_type = {dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  1355. dtype::QuantizedS32(6.25f) ,dtype::QuantizedS8(60.25f) };
  1356. printf("Benchmark WINOGRAD_IN8_MK8 algo\n");
  1357. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1358. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1359. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1360. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1361. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1362. {1, {4}}, data_type);
  1363. }
  1364. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1365. BENCHMARK_CONVBIAS_WINOGRAD_NCHW44_INT8_MK8) {
  1366. constexpr size_t RUNS = 50;
  1367. param::ConvBias param;
  1368. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1369. param.pad_h = 1;
  1370. param.pad_w = 1;
  1371. param.stride_h = 1;
  1372. param.stride_w = 1;
  1373. param.sparse = param::ConvBias::Sparse::DENSE;
  1374. param.format = param::ConvBias::Format::NCHW44;
  1375. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1376. shapes_and_computation;
  1377. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1378. size_t FS, size_t group) {
  1379. SmallVector<TensorShape> shapes{{N, IC / 4, H, W, 4},
  1380. {OC / 4, IC / 4, FS, FS, 4, 4},
  1381. {1, OC / 4, 1, 1, 4},
  1382. {},
  1383. {N, OC / 4, H, W, 4}};
  1384. TensorShape dst{N, OC, H, W};
  1385. float computations =
  1386. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1387. dst.total_nr_elems()) *
  1388. 1e-6;
  1389. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1390. };
  1391. bench_case(1, 32, 32, 200, 200, 3, 1);
  1392. bench_case(1, 32, 32, 128, 128, 3, 1);
  1393. bench_case(1, 32, 32, 100, 100, 3, 1);
  1394. bench_case(1, 512, 512, 14, 14, 3, 1);
  1395. bench_case(1, 512, 256, 14, 14, 3, 1);
  1396. bench_case(1, 512, 128, 14, 14, 3, 1);
  1397. bench_case(1, 512, 64, 14, 14, 3, 1);
  1398. bench_case(1, 512, 512, 7, 7, 3, 1);
  1399. bench_case(1, 512, 256, 7, 7, 3, 1);
  1400. bench_case(1, 512, 128, 7, 7, 3, 1);
  1401. bench_case(1, 512, 64, 7, 7, 3, 1);
  1402. std::string algo_name;
  1403. #if MEGDNN_AARCH64
  1404. algo_name = "WINOGRAD_NCHW44:AARCH64_INT16X16X32_MK8_8X8:8:2:32";
  1405. #else
  1406. algo_name = "WINOGRAD_NCHW44:ARMV7_INT16X16X32_MK8_4X8:8:2:32";
  1407. #endif
  1408. std::vector<DType> data_type = {
  1409. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  1410. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  1411. printf("Benchmark WINOGRAD_INT8_MK8 algo\n");
  1412. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1413. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1414. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1415. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1416. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1417. {1, {4}}, data_type);
  1418. }
  1419. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1420. BENCHMARK_CONVBIAS_WINOGRAD_NCHW44_INT8_COMP_F32) {
  1421. constexpr size_t RUNS = 50;
  1422. param::ConvBias param;
  1423. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1424. param.pad_h = 1;
  1425. param.pad_w = 1;
  1426. param.stride_h = 1;
  1427. param.stride_w = 1;
  1428. param.sparse = param::ConvBias::Sparse::DENSE; // GROUP;
  1429. param.format = param::ConvBias::Format::NCHW44;
  1430. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1431. shapes_and_computation;
  1432. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1433. size_t FS, size_t group) {
  1434. SmallVector<TensorShape> shapes{{N, IC / 4, H, W, 4},
  1435. {OC / 4, IC / 4, FS, FS, 4, 4},
  1436. {1, OC / 4, 1, 1, 4},
  1437. {},
  1438. {N, OC / 4, H, W, 4}};
  1439. TensorShape dst{N, OC, H, W};
  1440. float computations =
  1441. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1442. dst.total_nr_elems()) *
  1443. 1e-6;
  1444. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1445. };
  1446. bench_case(1, 32, 32, 200, 200, 3, 1);
  1447. bench_case(1, 32, 32, 128, 128, 3, 1);
  1448. bench_case(1, 32, 32, 100, 100, 3, 1);
  1449. bench_case(1, 512, 512, 14, 14, 3, 1);
  1450. bench_case(1, 512, 256, 14, 14, 3, 1);
  1451. bench_case(1, 512, 128, 14, 14, 3, 1);
  1452. bench_case(1, 512, 64, 14, 14, 3, 1);
  1453. bench_case(1, 512, 512, 7, 7, 3, 1);
  1454. bench_case(1, 512, 256, 7, 7, 3, 1);
  1455. bench_case(1, 512, 128, 7, 7, 3, 1);
  1456. bench_case(1, 512, 64, 7, 7, 3, 1);
  1457. std::string algo_name;
  1458. #if MEGDNN_AARCH64
  1459. algo_name = "WINOGRAD_NCHW44:AARCH64_F32_MK4_4x16:4:2:32";
  1460. #else
  1461. algo_name = "WINOGRAD_NCHW44:ARMV7_F32_MK4_4x8:4:2:32";
  1462. #endif
  1463. std::vector<DType> data_type = {
  1464. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  1465. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  1466. printf("Benchmark WINOGRAD_INT8_NCHW44_MK4_COMP_F32 algo\n");
  1467. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1468. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1469. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1470. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1471. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1472. {1, {4}}, data_type);
  1473. }
  1474. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_IM2COL_FP32) {
  1475. constexpr size_t RUNS = 50;
  1476. param::ConvBias param;
  1477. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1478. param.pad_h = 1;
  1479. param.pad_w = 1;
  1480. param.stride_h = 1;
  1481. param.stride_w = 1;
  1482. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1483. shapes_and_computation;
  1484. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1485. size_t FS, size_t group) {
  1486. SmallVector<TensorShape> shapes{{N, IC, H, W},
  1487. {OC, IC / group, FS, FS},
  1488. {1, OC, 1, 1},
  1489. {},
  1490. {N, OC, H, W}};
  1491. TensorShape dst{N, OC, H, W};
  1492. float computations =
  1493. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1494. dst.total_nr_elems()) *
  1495. 1e-6;
  1496. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1497. };
  1498. std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
  1499. dtype::Float32(), dtype::Float32()};
  1500. bench_case(1, 32, 32, 300, 300, 3, 1);
  1501. bench_case(1, 32, 32, 400, 400, 3, 1);
  1502. bench_case(1, 32, 32, 100, 100, 3, 1);
  1503. bench_case(1, 32, 32, 80, 80, 3, 1);
  1504. bench_case(1, 32, 64, 200, 200, 3, 1);
  1505. bench_case(1, 32, 64, 128, 128, 3, 1);
  1506. bench_case(1, 32, 64, 100, 100, 3, 1);
  1507. bench_case(1, 32, 64, 80, 80, 3, 1);
  1508. bench_case(1, 32, 128, 200, 200, 3, 1);
  1509. bench_case(1, 32, 128, 128, 128, 3, 1);
  1510. bench_case(1, 32, 128, 100, 100, 3, 1);
  1511. bench_case(1, 32, 128, 80, 80, 3, 1);
  1512. bench_case(1, 64, 32, 7, 7, 3, 1);
  1513. bench_case(1, 64, 64, 7, 7, 3, 1);
  1514. bench_case(1, 64, 128, 7, 7, 3, 1);
  1515. bench_case(1, 64, 256, 7, 7, 3, 1);
  1516. bench_case(1, 64, 512, 7, 7, 3, 1);
  1517. bench_case(1, 64, 1024, 7, 7, 3, 1);
  1518. bench_case(1, 64, 32, 14, 14, 3, 1);
  1519. bench_case(1, 64, 64, 14, 14, 3, 1);
  1520. bench_case(1, 64, 128, 14, 14, 3, 1);
  1521. bench_case(1, 64, 256, 14, 14, 3, 1);
  1522. bench_case(1, 64, 512, 14, 14, 3, 1);
  1523. bench_case(1, 64, 1024, 14, 14, 3, 1);
  1524. bench_case(1, 128, 128, 14, 14, 3, 1);
  1525. bench_case(1, 128, 256, 14, 14, 3, 1);
  1526. bench_case(1, 512, 512, 14, 14, 3, 1);
  1527. bench_case(1, 256, 512, 14, 14, 3, 1);
  1528. bench_case(1, 512, 1024, 14, 14, 3, 1);
  1529. bench_case(1, 1024, 1024, 14, 14, 3, 1);
  1530. std::string algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:96";
  1531. printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:96\n");
  1532. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1533. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1534. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1535. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1536. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1537. {1, {4}}, data_type);
  1538. algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:192";
  1539. printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:192\n");
  1540. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1541. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1542. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1543. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1544. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1545. {1, {4}}, data_type);
  1546. algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:384";
  1547. printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:384\n");
  1548. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1549. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1550. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1551. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1552. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1553. {1, {4}}, data_type);
  1554. shapes_and_computation.clear();
  1555. }
  1556. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1557. BENCHMARK_CHANNEL_WISE_INT8_INT8_INT8_STRIDE1) {
  1558. constexpr size_t RUNS = 50;
  1559. param::ConvBias param;
  1560. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1561. param.pad_h = 1;
  1562. param.pad_w = 1;
  1563. param.stride_h = 1;
  1564. param.stride_w = 1;
  1565. param.sparse = param::ConvBias::Sparse::GROUP;
  1566. param.format = param::ConvBias::Format::NCHW44;
  1567. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1568. shapes_and_computation;
  1569. auto bench_case = [&](size_t N, size_t IC, size_t H, size_t W, size_t FS,
  1570. size_t P) {
  1571. size_t group = IC;
  1572. size_t OC = IC;
  1573. size_t S = 1;
  1574. SmallVector<TensorShape> shapes{
  1575. {N, IC, H, W, 4},
  1576. {group, 1, 1, FS, FS, 4},
  1577. {1, OC, 1, 1, 4},
  1578. {},
  1579. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 4}};
  1580. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  1581. (W + 2 * P - FS) / S + 1, 4};
  1582. float computations =
  1583. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1584. dst.total_nr_elems()) *
  1585. 1e-6;
  1586. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1587. };
  1588. bench_case(1, 128, 200, 200, 3, 1);
  1589. bench_case(1, 128, 128, 128, 3, 1);
  1590. bench_case(1, 128, 100, 100, 3, 1);
  1591. bench_case(1, 128, 80, 80, 3, 1);
  1592. bench_case(1, 128, 56, 56, 3, 1);
  1593. bench_case(1, 128, 28, 28, 3, 1);
  1594. bench_case(1, 128, 14, 14, 3, 1);
  1595. bench_case(1, 64, 200, 200, 3, 1);
  1596. bench_case(1, 64, 128, 128, 3, 1);
  1597. bench_case(1, 64, 100, 100, 3, 1);
  1598. bench_case(1, 64, 80, 80, 3, 1);
  1599. bench_case(1, 64, 56, 56, 3, 1);
  1600. bench_case(1, 64, 28, 28, 3, 1);
  1601. bench_case(1, 64, 14, 14, 3, 1);
  1602. bench_case(1, 32, 200, 200, 3, 1);
  1603. bench_case(1, 32, 128, 128, 3, 1);
  1604. bench_case(1, 32, 100, 100, 3, 1);
  1605. bench_case(1, 32, 80, 80, 3, 1);
  1606. bench_case(1, 32, 56, 56, 3, 1);
  1607. bench_case(1, 32, 28, 28, 3, 1);
  1608. bench_case(1, 32, 14, 14, 3, 1);
  1609. std::string algo_name = "S8_CHAN_WISE_STRD1_NCHW44";
  1610. printf("Benchmarker S8_CHAN_WISE_STRD1_NCHW44 algo\n");
  1611. std::vector<DType> data_type = {
  1612. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  1613. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
  1614. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1615. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1616. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1617. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1618. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1619. {1, {4}}, data_type);
  1620. }
  1621. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1622. BENCHMARK_CHANNEL_WISE_INT8_INT8_INT16_STRIDE1) {
  1623. constexpr size_t RUNS = 50;
  1624. param::ConvBias param;
  1625. param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
  1626. param.pad_h = 1;
  1627. param.pad_w = 1;
  1628. param.stride_h = 1;
  1629. param.stride_w = 1;
  1630. param.sparse = param::ConvBias::Sparse::GROUP;
  1631. param.format = param::ConvBias::Format::NCHW44;
  1632. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1633. shapes_and_computation;
  1634. auto bench_case = [&](size_t N, size_t IC, size_t H, size_t W, size_t FS,
  1635. size_t P) {
  1636. size_t group = IC;
  1637. size_t OC = IC;
  1638. size_t S = 1;
  1639. SmallVector<TensorShape> shapes{
  1640. {N, IC, H, W, 4},
  1641. {group, 1, 1, FS, FS, 4},
  1642. {1, OC, 1, 1, 4},
  1643. {},
  1644. {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 4}};
  1645. TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
  1646. (W + 2 * P - FS) / S + 1, 4};
  1647. float computations =
  1648. ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1649. dst.total_nr_elems()) *
  1650. 1e-6;
  1651. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1652. };
  1653. bench_case(1, 128, 200, 200, 3, 1);
  1654. bench_case(1, 128, 128, 128, 3, 1);
  1655. bench_case(1, 128, 100, 100, 3, 1);
  1656. bench_case(1, 128, 80, 80, 3, 1);
  1657. bench_case(1, 128, 56, 56, 3, 1);
  1658. bench_case(1, 128, 28, 28, 3, 1);
  1659. bench_case(1, 128, 14, 14, 3, 1);
  1660. bench_case(1, 64, 200, 200, 3, 1);
  1661. bench_case(1, 64, 128, 128, 3, 1);
  1662. bench_case(1, 64, 100, 100, 3, 1);
  1663. bench_case(1, 64, 80, 80, 3, 1);
  1664. bench_case(1, 64, 56, 56, 3, 1);
  1665. bench_case(1, 64, 28, 28, 3, 1);
  1666. bench_case(1, 64, 14, 14, 3, 1);
  1667. bench_case(1, 32, 200, 200, 3, 1);
  1668. bench_case(1, 32, 128, 128, 3, 1);
  1669. bench_case(1, 32, 100, 100, 3, 1);
  1670. bench_case(1, 32, 80, 80, 3, 1);
  1671. bench_case(1, 32, 56, 56, 3, 1);
  1672. bench_case(1, 32, 28, 28, 3, 1);
  1673. bench_case(1, 32, 14, 14, 3, 1);
  1674. std::string algo_name = "S8x8x16_CHAN_WISE_STRD1_STRD2_NCHW44";
  1675. printf("Benchmarker S8x8x16_CHAN_WISE_STRD1_STRD2_NCHW44 algo\n");
  1676. std::vector<DType> data_type = {dtype::Int8(), dtype::Int8(),
  1677. dtype::Int16(), dtype::Int16()};
  1678. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1679. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1680. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1681. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1682. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1683. {1, {4}}, data_type);
  1684. }
  1685. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1686. BENCHMARK_IM2COL_NCHW44_INT8x8x32_STRIDE1) {
  1687. constexpr size_t RUNS = 50;
  1688. param::ConvBias param;
  1689. param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
  1690. param.pad_h = 1;
  1691. param.pad_w = 1;
  1692. param.stride_h = 1;
  1693. param.stride_w = 1;
  1694. param.sparse = param::ConvBias::Sparse::DENSE;
  1695. param.format = param::ConvBias::Format::NCHW44;
  1696. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1697. shapes_and_computation;
  1698. auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
  1699. size_t FS, size_t group=1) {
  1700. SmallVector<TensorShape> shapes{{N, IC, H, W,4},
  1701. {OC, IC / group, FS, FS,4,4},
  1702. {/*1, OC, 1, 1*/},
  1703. {},
  1704. {N, OC, H, W,4}};
  1705. TensorShape dst{N, OC, H, W,4};
  1706. float computations =
  1707. ((4 * IC / group) * FS * FS * dst.total_nr_elems() * 2 +
  1708. dst.total_nr_elems()) *
  1709. 1e-6;
  1710. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1711. };
  1712. bench_case(1, 32, 32, 300, 300, 3, 1);
  1713. bench_case(1, 32, 32, 400, 400, 3, 1);
  1714. bench_case(1, 32, 32, 100, 100, 3, 1);
  1715. bench_case(1, 32, 32, 80, 80, 3, 1);
  1716. bench_case(1, 32, 64, 200, 200, 3, 1);
  1717. bench_case(1, 32, 64, 128, 128, 3, 1);
  1718. bench_case(1, 32, 64, 100, 100, 3, 1);
  1719. bench_case(1, 32, 64, 80, 80, 3, 1);
  1720. bench_case(1, 32, 128, 200, 200, 3, 1);
  1721. bench_case(1, 32, 128, 128, 128, 3, 1);
  1722. bench_case(1, 32, 128, 100, 100, 3, 1);
  1723. bench_case(1, 32, 128, 80, 80, 3, 1);
  1724. #if 1
  1725. bench_case(1, 64, 32, 7, 7, 3, 1);
  1726. bench_case(1, 64, 64, 7, 7, 3, 1);
  1727. bench_case(1, 64, 128, 7, 7, 3, 1);
  1728. bench_case(1, 64, 256, 7, 7, 3, 1);
  1729. bench_case(1, 64, 512, 7, 7, 3, 1);
  1730. bench_case(1, 64, 1024, 7, 7, 3, 1);
  1731. bench_case(1, 64, 32, 14, 14, 3, 1);
  1732. bench_case(1, 64, 64, 14, 14, 3, 1);
  1733. bench_case(1, 64, 128, 14, 14, 3, 1);
  1734. bench_case(1, 64, 256, 14, 14, 3, 1);
  1735. bench_case(1, 64, 512, 14, 14, 3, 1);
  1736. bench_case(1, 64, 1024, 14, 14, 3, 1);
  1737. bench_case(1, 128, 128, 14, 14, 3, 1);
  1738. bench_case(1, 128, 256, 14, 14, 3, 1);
  1739. bench_case(1, 512, 512, 14, 14, 3, 1);
  1740. bench_case(1, 256, 512, 14, 14, 3, 1);
  1741. bench_case(1, 512, 1024, 14, 14, 3, 1);
  1742. bench_case(1, 1024, 1024, 14, 14, 3, 1);
  1743. #endif
  1744. std::string algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96";
  1745. printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96 algo\n");
  1746. std::vector<DType> data_type = {
  1747. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  1748. dtype::QuantizedS32(6.25f), {}};
  1749. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1750. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1751. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1752. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1753. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1754. {1, {4}}, data_type);
  1755. algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:192";
  1756. printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:192 algo\n");
  1757. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1758. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1759. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1760. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1761. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1762. {1, {4}}, data_type);
  1763. algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:384";
  1764. printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:384 algo\n");
  1765. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1766. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1767. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1768. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1769. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1770. {1, {4}}, data_type);
  1771. }
  1772. #endif
  1773. /*================== BENCHMARK MULTITHREAD CONV1X1 =====================*/
  1774. #if MEGDNN_WITH_BENCHMARK
  1775. namespace {
  1776. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1777. get_conv1x1_multithread_benchmark_args() {
  1778. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1779. shapes_and_computation;
  1780. auto bench_case = [&](size_t IC, size_t OC, size_t H, size_t W) {
  1781. SmallVector<TensorShape> shapes{{1, IC, H, W},
  1782. {OC, IC, 1, 1},
  1783. {1, OC, 1, 1},
  1784. {},
  1785. {1, OC, H, W}};
  1786. TensorShape dst{1, OC, H, W};
  1787. float computations =
  1788. (IC * dst.total_nr_elems() * 2 + dst.total_nr_elems()) * 1e-6;
  1789. shapes_and_computation.push_back(std::make_pair(shapes, computations));
  1790. };
  1791. bench_case(32, 32, 300, 300);
  1792. bench_case(32, 32, 400, 400);
  1793. bench_case(32, 32, 100, 100);
  1794. bench_case(32, 32, 80, 80);
  1795. bench_case(32, 64, 200, 200);
  1796. bench_case(32, 64, 128, 128);
  1797. bench_case(32, 64, 100, 100);
  1798. bench_case(32, 64, 80, 80);
  1799. bench_case(32, 128, 200, 200);
  1800. bench_case(32, 128, 128, 128);
  1801. bench_case(32, 128, 100, 100);
  1802. bench_case(32, 128, 80, 80);
  1803. bench_case(64, 32, 7, 7);
  1804. bench_case(64, 64, 7, 7);
  1805. bench_case(64, 128, 7, 7);
  1806. bench_case(64, 256, 7, 7);
  1807. bench_case(64, 512, 7, 7);
  1808. bench_case(64, 1024, 7, 7);
  1809. bench_case(64, 32, 14, 14);
  1810. bench_case(64, 64, 14, 14);
  1811. bench_case(64, 128, 14, 14);
  1812. bench_case(64, 256, 14, 14);
  1813. bench_case(64, 512, 14, 14);
  1814. bench_case(64, 1024, 14, 14);
  1815. bench_case(128, 128, 14, 14);
  1816. bench_case(128, 256, 14, 14);
  1817. bench_case(512, 512, 14, 14);
  1818. bench_case(256, 512, 14, 14);
  1819. bench_case(512, 1024, 14, 14);
  1820. bench_case(1024, 1024, 14, 14);
  1821. return shapes_and_computation;
  1822. }
  1823. void conv1x1_multithread_benchmark(const char* algo_name, DType stype,
  1824. DType ftype, DType btype, DType dtype) {
  1825. constexpr size_t RUNS = 50;
  1826. std::vector<std::pair<SmallVector<TensorShape>, float>>
  1827. shapes_and_computation = get_conv1x1_multithread_benchmark_args();
  1828. std::vector<DType> data_type = {stype, ftype, btype, dtype};
  1829. param::ConvBias param;
  1830. param.nonlineMode = param::ConvBias::NonlineMode::RELU;
  1831. param.pad_h = 0;
  1832. param.pad_w = 0;
  1833. param.stride_h = 1;
  1834. param.stride_w = 1;
  1835. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1836. {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
  1837. benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
  1838. {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
  1839. benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
  1840. {1, {4}}, data_type);
  1841. shapes_and_computation.clear();
  1842. }
  1843. } // namespace
  1844. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_CONV1X1_S1_FP32) {
  1845. #if MEGDNN_AARCH64
  1846. conv1x1_multithread_benchmark("CONV1x1:AARCH64_F32K8X12X1:8",
  1847. dtype::Float32(), dtype::Float32(),
  1848. dtype::Float32(), dtype::Float32());
  1849. #else
  1850. conv1x1_multithread_benchmark("CONV1x1:ARMV7_F32:8", dtype::Float32(),
  1851. dtype::Float32(), dtype::Float32(),
  1852. dtype::Float32());
  1853. #endif
  1854. }
  1855. TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
  1856. BENCHMARK_CONVBIAS_CONV1X1_S1_QUANTIZEDASYM) {
  1857. dtype::Quantized8Asymm stype(0.2f, 100);
  1858. dtype::Quantized8Asymm ftype(0.2f, 120);
  1859. dtype::QuantizedS32 btype(0.04f);
  1860. dtype::Quantized8Asymm dtype(1.4f, 110);
  1861. #if MEGDNN_AARCH64
  1862. #if MGB_ENABLE_DOT
  1863. conv1x1_multithread_benchmark("CONV1x1:AARCH64_QUINT8_K8X8X4_DOTPROD:8",
  1864. stype, ftype, btype, dtype);
  1865. #else
  1866. conv1x1_multithread_benchmark("CONV1x1:AARCH64_QUINT8_K8X8X8:8", stype,
  1867. ftype, btype, dtype);
  1868. #endif
  1869. #else
  1870. conv1x1_multithread_benchmark("CONV1x1:ARMV7_QUINT8_K4X8X8:8", stype, ftype,
  1871. btype, dtype);
  1872. #endif
  1873. }
  1874. #endif
  1875. // vim: syntax=cpp.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台