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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029
  1. /**
  2. * \file dnn/test/arm_common/conv_bias_multi_thread.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 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. std::vector<conv_bias::TestArg> get_int8_quint8_conv_bias_args(
  19. std::vector<size_t> kernel, size_t stride, bool no_pad, bool no_bias,
  20. bool no_nonlinemode) {
  21. using namespace conv_bias;
  22. using Param = param::ConvBias;
  23. using NLMode = param::ConvBias::NonlineMode;
  24. std::vector<TestArg> args;
  25. auto pack = [&](size_t n, size_t oc, size_t ic, size_t w, size_t h,
  26. size_t kernel, size_t stride, NLMode nlmode) {
  27. Param param;
  28. param.stride_h = stride;
  29. param.stride_w = stride;
  30. if (!no_pad) {
  31. param.pad_h = kernel / 2;
  32. param.pad_w = kernel / 2;
  33. } else {
  34. param.pad_h = 0;
  35. param.pad_w = 0;
  36. }
  37. param.nonlineMode = nlmode;
  38. args.emplace_back(param, TensorShape{n, ic, h, w},
  39. TensorShape{oc, ic, kernel, kernel}, TensorShape{});
  40. if (!no_bias) {
  41. args.emplace_back(param, TensorShape{n, ic, h, w},
  42. TensorShape{oc, ic, kernel, kernel},
  43. TensorShape{1, oc, 1, 1});
  44. }
  45. };
  46. std::vector<NLMode> nonlinemode = {NLMode::IDENTITY};
  47. if (!no_nonlinemode) {
  48. nonlinemode.emplace_back(NLMode::RELU);
  49. nonlinemode.emplace_back(NLMode::H_SWISH);
  50. }
  51. for (size_t n : {1, 2}) {
  52. for (auto nlmode : nonlinemode) {
  53. for (size_t ic : {1, 3, 7}) {
  54. for (size_t oc : {1, 3, 7}) {
  55. for (size_t size : {4, 6, 8, 14, 16, 18}) {
  56. for (size_t kern : kernel) {
  57. pack(n, oc, ic, size, size, kern, stride, nlmode);
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. return args;
  65. }
  66. std::vector<conv_bias::TestArg> get_nchw44_conv_bias_args(
  67. std::vector<size_t> kernel_vec, size_t stride, bool no_pad = false,
  68. bool no_bias = false, bool no_nonlinemode = false,
  69. bool is_input_nchw = false, bool is_nchw44_dot = false,
  70. bool support_full_bias = false, bool support_sigmoid = false,
  71. bool only_no_bias = false) {
  72. using namespace conv_bias;
  73. using NLMode = param::ConvBias::NonlineMode;
  74. std::vector<TestArg> args;
  75. MEGDNN_MARK_USED_VAR(no_pad);
  76. auto pack = [&](size_t n, size_t oc, size_t ic, size_t h, size_t w,
  77. size_t kernel, size_t stride, size_t group, NLMode nlmode,
  78. megdnn::BiasMode bias_mode, int any_pad = -1) {
  79. constexpr int pack_c = 4;
  80. const size_t pad = any_pad >= 0 ? any_pad : kernel / 2;
  81. auto oc_per_group = oc / group;
  82. auto ic_per_group = ic / group;
  83. bool ok_group = (oc % group == 0 && ic % group == 0) &&
  84. oc_per_group % pack_c == 0 && oc_per_group > 0 &&
  85. ic_per_group > 0;
  86. bool nchw_disable = group > 1 || ic_per_group >= 4;
  87. bool nchw44_disable = ic_per_group % pack_c != 0;
  88. bool invalid_pad = (w + 2 * pad < kernel) || (h + 2 * pad < kernel);
  89. if (!(ok_group) || invalid_pad) {
  90. return;
  91. }
  92. if ((is_input_nchw && nchw_disable) ||
  93. (!is_input_nchw && nchw44_disable)) {
  94. return;
  95. }
  96. size_t kernel_h = kernel;
  97. size_t kernel_w = kernel;
  98. param::ConvBias param;
  99. if (!is_nchw44_dot) {
  100. param.format = param::ConvBias::Format::NCHW44;
  101. } else {
  102. param.format = param::ConvBias::Format::NCHW44_DOT;
  103. }
  104. param.stride_h = stride;
  105. param.stride_w = stride;
  106. param.pad_h = pad;
  107. param.pad_w = pad;
  108. param.nonlineMode = nlmode;
  109. auto src_tensor_shape = TensorShape{n, ic / pack_c, h, w, pack_c};
  110. auto weight_tensor_shape = TensorShape{
  111. oc / pack_c, ic / pack_c, kernel_h, kernel_w, pack_c, pack_c};
  112. auto bias_tensor_shape = TensorShape{};
  113. if (bias_mode == megdnn::BiasMode::BROADCAST_CHANNEL_BIAS) {
  114. bias_tensor_shape = {1, oc / pack_c, 1, 1, pack_c};
  115. } else if (bias_mode == megdnn::BiasMode::BIAS) {
  116. bias_tensor_shape = {n, oc / pack_c,
  117. (h + 2 * pad - kernel) / stride + 1,
  118. (w + 2 * pad - kernel) / stride + 1, pack_c};
  119. }
  120. if (group == 1) {
  121. param.sparse = param::ConvBias::Sparse::DENSE;
  122. } else if (group > 1 && ic / group == 1 && oc / group == 1) {
  123. megdnn_assert(0, "not support channel wise");
  124. param.sparse = param::ConvBias::Sparse::GROUP;
  125. weight_tensor_shape = TensorShape{group / pack_c, 1, 1,
  126. kernel_h, kernel_w, pack_c};
  127. } else if (group > 1 && oc_per_group % pack_c == 0 && oc / group > 0 &&
  128. ic_per_group % pack_c == 0 && ic / group > 0) {
  129. param.sparse = param::ConvBias::Sparse::GROUP;
  130. weight_tensor_shape = TensorShape{group,
  131. oc_per_group / pack_c,
  132. ic_per_group / pack_c,
  133. kernel_h,
  134. kernel_w,
  135. pack_c,
  136. pack_c};
  137. }
  138. if (is_input_nchw) {
  139. src_tensor_shape = TensorShape{n, ic, h, w};
  140. weight_tensor_shape =
  141. TensorShape{oc / pack_c, kernel_h, kernel_w, ic, pack_c};
  142. }
  143. args.emplace_back(param, src_tensor_shape, weight_tensor_shape,
  144. bias_tensor_shape);
  145. };
  146. std::vector<NLMode> nonlinemode = {NLMode::IDENTITY};
  147. if (!no_nonlinemode) {
  148. nonlinemode.emplace_back(NLMode::RELU);
  149. nonlinemode.emplace_back(NLMode::H_SWISH);
  150. }
  151. if (support_sigmoid) {
  152. nonlinemode.emplace_back(NLMode::SIGMOID);
  153. }
  154. std::vector<megdnn::BiasMode> bias_mode;
  155. if (!only_no_bias) {
  156. bias_mode.emplace_back(megdnn::BiasMode::BROADCAST_CHANNEL_BIAS);
  157. if (no_bias) {
  158. bias_mode.emplace_back(megdnn::BiasMode::NO_BIAS);
  159. }
  160. } else {
  161. bias_mode.emplace_back(megdnn::BiasMode::NO_BIAS);
  162. }
  163. if (support_full_bias) {
  164. bias_mode.emplace_back(megdnn::BiasMode::BIAS);
  165. }
  166. for (auto bias : bias_mode)
  167. for (auto nlmode : nonlinemode)
  168. for (size_t n : {1, 2})
  169. for (size_t kernel : kernel_vec)
  170. for (size_t oc : {4, 12})
  171. for (size_t ic : {1, 3, 4, 12})
  172. for (size_t h : {1, 3, 12})
  173. for (size_t w : {1, 16, 23}) {
  174. for (size_t group = 1;
  175. group <=
  176. std::min(std::min(oc, ic), 4_z);
  177. ++group) {
  178. if (kernel != 1 && (h == 1 || w == 1)) {
  179. continue;
  180. }
  181. pack(n, oc, ic, h, w, kernel, stride,
  182. group, nlmode, bias);
  183. }
  184. }
  185. return args;
  186. }
  187. std::vector<conv_bias::TestArg> get_nchw44_channel_wise_args(
  188. std::vector<size_t> kernel, size_t stride, bool no_bias,
  189. bool no_nonlinemode, bool no_full_bias) {
  190. using namespace conv_bias;
  191. using Param = param::ConvBias;
  192. using NLMode = param::ConvBias::NonlineMode;
  193. std::vector<TestArg> args;
  194. auto pack = [&](size_t n, size_t group, size_t w, size_t h, size_t kernel,
  195. size_t stride, NLMode nlmode, bool pad) {
  196. Param param;
  197. param.stride_h = stride;
  198. param.stride_w = stride;
  199. if (pad) {
  200. param.pad_h = kernel / 2;
  201. param.pad_w = kernel / 2;
  202. } else {
  203. param.pad_h = 0;
  204. param.pad_w = 0;
  205. }
  206. param.nonlineMode = nlmode;
  207. param.format = param::ConvBias::Format::NCHW44;
  208. param.sparse = param::ConvBias::Sparse::GROUP;
  209. args.emplace_back(param, TensorShape{n, group, h, w, 4},
  210. TensorShape{group, 1, 1, kernel, kernel, 4},
  211. TensorShape{});
  212. if (!no_bias) {
  213. args.emplace_back(param, TensorShape{n, group, h, w, 4},
  214. TensorShape{group, 1, 1, kernel, kernel, 4},
  215. TensorShape{1, group, 1, 1, 4});
  216. }
  217. if (!no_full_bias) {
  218. args.emplace_back(
  219. param, TensorShape{n, group, h, w, 4},
  220. TensorShape{group, 1, 1, kernel, kernel, 4},
  221. TensorShape{n, group,
  222. (h + 2 * param.pad_w - kernel) / stride + 1,
  223. (w + 2 * param.pad_w - kernel) / stride + 1,
  224. 4});
  225. }
  226. };
  227. std::vector<NLMode> nonlinemode = {NLMode::IDENTITY};
  228. if (!no_nonlinemode) {
  229. nonlinemode.emplace_back(NLMode::RELU);
  230. nonlinemode.emplace_back(NLMode::H_SWISH);
  231. }
  232. for (size_t n : {1, 2}) {
  233. for (auto nlmode : nonlinemode) {
  234. for (bool pad : {true}) {
  235. for (size_t group : {1, 2, 4, 7, 128}) {
  236. for (size_t size : {4, 6, 7, 9, 15, 40}) {
  237. for (size_t kern : kernel) {
  238. pack(n, group, size, size, kern, stride, nlmode,
  239. pad);
  240. }
  241. }
  242. }
  243. }
  244. for (bool pad : {false}) {
  245. for (size_t group : {1, 2, 7, 128}) {
  246. for (size_t size : {7, 9, 15, 40}) {
  247. for (size_t kern : kernel) {
  248. pack(n, group, size, size, kern, stride, nlmode,
  249. pad);
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. return args;
  257. }
  258. void checker_conv_bias_qint8x8x8(std::vector<conv_bias::TestArg> args,
  259. Handle* handle, const char* algo_name) {
  260. Checker<ConvBias> checker(handle);
  261. checker.set_before_exec_callback(
  262. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  263. #if MEGDNN_ARMV7
  264. checker.set_epsilon(1);
  265. #endif
  266. UniformIntRNG rng{-50, 50};
  267. checker.set_dtype(0, dtype::QuantizedS8(0.41113496f))
  268. .set_dtype(1, dtype::QuantizedS8(0.01887994f))
  269. .set_dtype(2, dtype::QuantizedS32(0.41113496f * 0.01887994f))
  270. .set_dtype(4, dtype::QuantizedS8(0.49550694f))
  271. .set_rng(0, &rng)
  272. .set_rng(1, &rng)
  273. .set_rng(2, &rng);
  274. for (auto&& arg : args) {
  275. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  276. }
  277. }
  278. void checker_conv_bias_qint8x8x32(std::vector<conv_bias::TestArg> args,
  279. Handle* handle, const char* algo_name) {
  280. Checker<ConvBias> checker(handle);
  281. UniformIntRNG rng{-50, 50};
  282. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  283. .set_dtype(1, dtype::QuantizedS8(2.5f))
  284. .set_dtype(2, dtype::QuantizedS32(6.25f))
  285. .set_dtype(4, {});
  286. checker.set_before_exec_callback(
  287. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  288. for (auto&& arg : args) {
  289. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  290. }
  291. }
  292. void checker_conv_bias_quint8x8x8(std::vector<conv_bias::TestArg> args,
  293. Handle* handle, const char* algo_name) {
  294. Checker<ConvBias> checker(handle);
  295. checker.set_before_exec_callback(
  296. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  297. UniformIntRNG rng(0, 255);
  298. checker.set_dtype(0, dtype::Quantized8Asymm(0.2f, 100))
  299. .set_dtype(1, dtype::Quantized8Asymm(0.2f, 120))
  300. .set_dtype(2, dtype::QuantizedS32(0.04f))
  301. .set_dtype(4, dtype::Quantized8Asymm(1.4f, 110))
  302. .set_rng(0, &rng)
  303. .set_rng(1, &rng)
  304. .set_rng(2, &rng);
  305. for (auto&& arg : args) {
  306. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  307. }
  308. }
  309. void checker_conv_bias_quint8x8x32(std::vector<conv_bias::TestArg> args,
  310. Handle* handle, const char* algo_name) {
  311. Checker<ConvBias> checker(handle);
  312. checker.set_before_exec_callback(
  313. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  314. NormalRNG rng(128.f);
  315. checker.set_rng(0, &rng).set_rng(1, &rng);
  316. checker.set_dtype(0, dtype::Quantized8Asymm(1.2f, (uint8_t)127))
  317. .set_dtype(1, dtype::Quantized8Asymm(1.3f, (uint8_t)129))
  318. .set_dtype(2, dtype::QuantizedS32(1.2 * 1.3))
  319. .set_dtype(4, {});
  320. for (auto&& arg : args) {
  321. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  322. }
  323. }
  324. void checker_conv_bias_int8x8x32_multi(std::vector<conv_bias::TestArg> args,
  325. Handle* handle, const char* algo_name) {
  326. Checker<ConvBias> checker(handle);
  327. checker.set_before_exec_callback(
  328. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  329. checker.set_dtype(0, dtype::Int8());
  330. checker.set_dtype(1, dtype::Int8());
  331. checker.set_dtype(2, dtype::Int32());
  332. checker.set_dtype(4, dtype::Int32());
  333. for (auto&& arg : args) {
  334. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  335. }
  336. }
  337. /**********************************F32 direct************************/
  338. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32) {
  339. check_conv_bias(
  340. get_conv_bias_args({1, 2, 3, 4, 5, 6, 7}, 1, false, false, false),
  341. handle(), "F32DIRECT");
  342. }
  343. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_NCHW44_S1_K7) {
  344. check_conv_bias(get_nchw44_conv_bias_args({7}, 1, false, true, true, false,
  345. false, false),
  346. handle(), "F32_CONV_NCHW44_DIRECT");
  347. }
  348. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_NCHW44_S1_K2K3) {
  349. check_conv_bias(get_nchw44_conv_bias_args({2, 3}, 1, false, false, false,
  350. false, false, true, true),
  351. handle(), "F32_CONV_NCHW44_DIRECT");
  352. }
  353. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_NCHW44_S1_K5) {
  354. check_conv_bias(get_nchw44_conv_bias_args({5}, 1, false, false, false,
  355. false, false, true, true),
  356. handle(), "F32_CONV_NCHW44_DIRECT");
  357. }
  358. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_NCHW44_S2) {
  359. check_conv_bias(get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false,
  360. false, false, false, true, true),
  361. handle(), "F32_CONV_NCHW44_DIRECT");
  362. }
  363. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_STR1) {
  364. check_conv_bias(get_conv_bias_args({2, 3, 5, 7}, 1, false, false, false),
  365. handle(), "F32STRD1");
  366. }
  367. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP32_STR2) {
  368. check_conv_bias(get_conv_bias_args({2, 3, 5, 7}, 2, false, false, false),
  369. handle(), "F32STRD2");
  370. }
  371. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_NCHW_NCHW44_F32_S2) {
  372. check_conv_bias(get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false,
  373. false, true),
  374. handle(), "F32_CONV_NCHW_NCHW44");
  375. }
  376. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_NCHW_NCHW44_F32_S1) {
  377. check_conv_bias(get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, false,
  378. false, true),
  379. handle(), "F32_CONV_NCHW_NCHW44");
  380. }
  381. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_CHANNEL_WISE_STRIDE1_FP32_NCHW44_1) {
  382. check_conv_bias(
  383. get_nchw44_channel_wise_args({2, 3}, 1, false, false, false),
  384. handle(), "F32_CHANNEL_WISE_NCHW44");
  385. }
  386. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_CHANNEL_WISE_STRIDE1_FP32_NCHW44_2) {
  387. check_conv_bias(get_nchw44_channel_wise_args({5}, 1, false, false, false),
  388. handle(), "F32_CHANNEL_WISE_NCHW44");
  389. }
  390. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_CHANNEL_WISE_STRIDE2_FP32_NCHW44) {
  391. check_conv_bias(
  392. get_nchw44_channel_wise_args({2, 3, 5}, 2, false, false, false),
  393. handle(), "F32_CHANNEL_WISE_NCHW44");
  394. }
  395. /**********************************F16 direct************************/
  396. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  397. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP16) {
  398. NormalRNG rng(1);
  399. checker_conv_bias_f16(
  400. get_conv_bias_args({1, 2, 3, 4, 5, 6, 7}, 1, false, false, false),
  401. handle(), rng, "F16DIRECT", 0.03);
  402. }
  403. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_DIRECT_FP16_STR1) {
  404. NormalRNG rng(1);
  405. checker_conv_bias_f16(get_conv_bias_args({2, 3, 5}, 1, false, false, false),
  406. handle(), rng, "F16STRD1", 0.03);
  407. }
  408. #endif
  409. /**********************************algo 8816 direct************************/
  410. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_INT8_INT16_DIRECT) {
  411. checker_conv_bias_int8x8x16(
  412. get_conv_bias_args({2, 3, 5}, 1, false, true, true), handle(),
  413. "I8816DIRECT");
  414. }
  415. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_INT8_INT16_STRIDE2) {
  416. checker_conv_bias_int8x8x16(
  417. get_conv_bias_args({2, 3, 5}, 2, false, true, true), handle(),
  418. "I8816STRD2");
  419. }
  420. /**********************************algo 8-8-32 direct************************/
  421. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_INT8_INT32_STRIDE1) {
  422. checker_conv_bias_int8x8x32_multi(
  423. get_conv_bias_args({2, 3, 5, 7}, 1, false, true, true), handle(),
  424. "S8STRD1");
  425. }
  426. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_INT8_INT32_STRIDE2) {
  427. checker_conv_bias_int8x8x32_multi(
  428. get_conv_bias_args({2, 3, 5, 7}, 2, false, true, true), handle(),
  429. "S8STRD2");
  430. }
  431. TEST_F(ARM_COMMON_MULTI_THREADS,
  432. CONV_BIAS_INT8_INT8_INT32_CHANNEL_WISE_DIRECT1_NCHW44) {
  433. checker_conv_bias_int8x8x32_multi(
  434. get_nchw44_channel_wise_args({2, 3, 5}, 1, false, true, true),
  435. handle(), "S8_CHAN_WISE_STRD1_NCHW44");
  436. }
  437. TEST_F(ARM_COMMON_MULTI_THREADS,
  438. CONV_BIAS_INT8_INT8_INT32_CHANNEL_WISE_DIRECT2_NCHW44) {
  439. checker_conv_bias_int8x8x32_multi(
  440. get_nchw44_channel_wise_args({2, 3, 5}, 2, false, true, true),
  441. handle(), "S8_CHAN_WISE_STRD2_NCHW44");
  442. }
  443. /********************************qint8 direct******************************/
  444. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE1) {
  445. checker_conv_bias_qint8x8x8(get_int8_quint8_conv_bias_args(
  446. {2, 3, 5, 7}, 1, false, false, false),
  447. handle(), "S8STRD1");
  448. }
  449. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE2) {
  450. checker_conv_bias_qint8x8x8(get_int8_quint8_conv_bias_args(
  451. {2, 3, 5, 7}, 2, false, false, false),
  452. handle(), "S8STRD2");
  453. }
  454. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE1_NCHW44) {
  455. checker_conv_bias_qint8x8x8(
  456. get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, false, false),
  457. handle(), "S8_NCHW44_DIRECT");
  458. }
  459. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE1_NCHW44_8832) {
  460. checker_conv_bias_qint8x8x32(
  461. get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, false, true),
  462. handle(), "S8_NCHW44_DIRECT");
  463. }
  464. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE2_NCHW44_8832) {
  465. checker_conv_bias_qint8x8x32(
  466. get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false, true),
  467. handle(), "S8_NCHW44_DIRECT");
  468. }
  469. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE2_NCHW44) {
  470. checker_conv_bias_qint8x8x8(
  471. get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false, false),
  472. handle(), "S8_NCHW44_DIRECT");
  473. }
  474. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QS8_CHANNEL_WISE_DIRECT1_NCHW44) {
  475. checker_conv_bias_qint8x8x8(
  476. get_nchw44_channel_wise_args({2, 3, 5}, 1, false, false, true),
  477. handle(), "S8_CHAN_WISE_STRD1_NCHW44");
  478. }
  479. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QS8_CHANNEL_WISE_DIRECT2_NCHW44) {
  480. checker_conv_bias_qint8x8x8(
  481. get_nchw44_channel_wise_args({2, 3, 5}, 2, false, false, true),
  482. handle(), "S8_CHAN_WISE_STRD2_NCHW44");
  483. }
  484. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_NCHW_NCHW44_S1) {
  485. checker_conv_bias_qint8x8x8(
  486. get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, false, false,
  487. true),
  488. handle(), "S8_CONV_NCHW_NCHW44");
  489. }
  490. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_NCHW_NCHW44_S2) {
  491. checker_conv_bias_qint8x8x8(
  492. get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false, false,
  493. true),
  494. handle(), "S8_CONV_NCHW_NCHW44");
  495. }
  496. /*****************************quint8 direct****************************/
  497. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QUINT8_STRIDE1) {
  498. checker_conv_bias_quint8x8x8(get_int8_quint8_conv_bias_args(
  499. {2, 3, 5, 7}, 1, false, false, false),
  500. handle(), "QU8STRD1");
  501. }
  502. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QUINT8_STRIDE2) {
  503. checker_conv_bias_quint8x8x8(get_int8_quint8_conv_bias_args(
  504. {2, 3, 5, 7}, 2, false, false, false),
  505. handle(), "QU8STRD2");
  506. }
  507. /****************************dot qint8 direct*************************/
  508. #if __ARM_FEATURE_DOTPROD
  509. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_DOT_NCHW_NCHW44) {
  510. auto args = get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, false, false,
  511. true);
  512. for (auto&& arg : args) {
  513. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  514. }
  515. checker_conv_bias_qint8x8x8(args, handle(), "ARMDOTS8_NCHW_NCHW44");
  516. args = get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, false, false,
  517. true);
  518. for (auto&& arg : args) {
  519. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  520. }
  521. checker_conv_bias_qint8x8x8(args, handle(), "ARMDOTS8_NCHW_NCHW44");
  522. }
  523. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE1_WITHDOTPROD) {
  524. checker_conv_bias_qint8x8x8(get_int8_quint8_conv_bias_args(
  525. {2, 3, 5, 7}, 1, false, false, false),
  526. handle(), "ARMDOTS8STRD1");
  527. }
  528. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_INT8_STRIDE2_WITHDOTPROD) {
  529. checker_conv_bias_qint8x8x8(get_int8_quint8_conv_bias_args(
  530. {2, 3, 5, 7}, 2, false, false, false),
  531. handle(), "ARMDOTS8STRD2");
  532. }
  533. /****************************dot 8-8-32 direct*************************/
  534. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_I8832STRD1_WITHDOT) {
  535. checker_conv_bias_qint8x8x32(
  536. get_conv_bias_args({2, 3, 5, 7}, 1, false, true, true), handle(),
  537. "ARMDOTS8STRD1");
  538. }
  539. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_I8832STRD2_WITHDOT) {
  540. checker_conv_bias_qint8x8x32(
  541. get_conv_bias_args({2, 3, 5, 7}, 2, false, true, true), handle(),
  542. "ARMDOTS8STRD2");
  543. }
  544. /******************************dot quint8*****************************/
  545. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QUINT8_STRIDE1_WITHDOTPROD) {
  546. checker_conv_bias_quint8x8x8(get_int8_quint8_conv_bias_args(
  547. {2, 3, 5, 7}, 1, false, false, false),
  548. handle(), "ARMDOTU8STRD1");
  549. }
  550. //! TODO: this test without test kernel size=3, add it will case buss error now
  551. //! in armv7
  552. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_QUINT8_STRIDE2_WITHDOTPROD) {
  553. checker_conv_bias_quint8x8x8(
  554. get_int8_quint8_conv_bias_args({2, 5, 7}, 2, false, false, false),
  555. handle(), "ARMDOTU8STRD2");
  556. }
  557. /******************************dot quint8x8x32***********************/
  558. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_QUINT8_DIRECT_STRIDE1) {
  559. checker_conv_bias_quint8x8x32(
  560. get_conv_bias_args({2, 3, 5, 7}, 1, false, true, true), handle(),
  561. "ARMDOTU8STRD1");
  562. }
  563. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_QUINT8_DIRECT_STRIDE2) {
  564. checker_conv_bias_quint8x8x32(
  565. get_conv_bias_args({2, 3, 5, 7}, 2, false, true, true), handle(),
  566. "ARMDOTU8STRD2");
  567. }
  568. /******************************dot int8x8x8 nchw44 ***********************/
  569. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S1_Q8x8x8) {
  570. using namespace conv_bias;
  571. std::vector<TestArg> args = get_nchw44_conv_bias_args({2, 3, 5, 7}, 1);
  572. for (auto&& arg : args)
  573. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  574. checker_conv_bias_qint8x8x8(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  575. }
  576. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S1_Q8x8x32) {
  577. using namespace conv_bias;
  578. std::vector<TestArg> args =
  579. get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, true, true);
  580. for (auto&& arg : args)
  581. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  582. checker_conv_bias_qint8x8x32(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  583. }
  584. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S1_8x8x32) {
  585. using namespace conv_bias;
  586. std::vector<TestArg> args =
  587. get_nchw44_conv_bias_args({2, 3, 5, 7}, 1, false, true, true);
  588. for (auto&& arg : args)
  589. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  590. checker_conv_bias_int8x8x32_multi(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  591. }
  592. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S2_Q8x8x8) {
  593. using namespace conv_bias;
  594. //! test qint8x8x8
  595. std::vector<TestArg> args = get_nchw44_conv_bias_args({2, 3, 5, 7}, 2);
  596. for (auto&& arg : args)
  597. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  598. checker_conv_bias_qint8x8x8(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  599. }
  600. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S2_Q8x8x32) {
  601. using namespace conv_bias;
  602. //! test qint8x8x8
  603. std::vector<TestArg> args =
  604. get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, true, true);
  605. for (auto&& arg : args)
  606. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  607. checker_conv_bias_qint8x8x32(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  608. }
  609. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_INT8_DIRECT_DOT_NCHW44_S2_8x8x32) {
  610. using namespace conv_bias;
  611. //! test qint8x8x8
  612. std::vector<TestArg> args =
  613. get_nchw44_conv_bias_args({2, 3, 5, 7}, 2, false, true, true);
  614. for (auto&& arg : args)
  615. arg.param.format = param::ConvBias::Format::NCHW44_DOT;
  616. checker_conv_bias_int8x8x32_multi(args, handle(), "ARMDOTS8DIRECT_NCHW44");
  617. }
  618. #endif
  619. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F23_4) {
  620. using namespace conv_bias;
  621. std::vector<TestArg> args = get_winograd_mk_packed_args();
  622. Checker<ConvBiasForward> checker(handle());
  623. check_winograd("4:2:32", checker, args, param::MatrixMul::Format::MK4);
  624. }
  625. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F23_4_WEIGHT_PREPROCESS) {
  626. using namespace conv_bias;
  627. std::vector<TestArg> args = get_winograd_mk_packed_args();
  628. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  629. handle());
  630. check_winograd("4:2:32", checker, args, param::MatrixMul::Format::MK4);
  631. }
  632. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F23_4_NCHW44) {
  633. using namespace conv_bias;
  634. std::vector<TestArg> args = get_nchw44_conv_bias_args({3}, 1);
  635. Checker<ConvBiasForward> checker(handle());
  636. check_winograd("4:2:32", checker, args, param::MatrixMul::Format::MK4,
  637. param::ConvBias::Format::NCHW44);
  638. }
  639. TEST_F(ARM_COMMON_MULTI_THREADS,
  640. CONV_BIAS_WINOGRAD_F23_4_NCHW44_WEIGHT_PREPROCESS) {
  641. using namespace conv_bias;
  642. std::vector<TestArg> args = get_nchw44_conv_bias_args({3}, 1);
  643. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  644. handle());
  645. check_winograd("4:2:32", checker, args, param::MatrixMul::Format::MK4,
  646. param::ConvBias::Format::NCHW44);
  647. }
  648. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F63) {
  649. using namespace conv_bias;
  650. std::vector<TestArg> args = get_winograd_args(3);
  651. Checker<ConvBiasForward> checker(handle());
  652. check_winograd("1:6:32", checker, args);
  653. }
  654. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F63_WEIGHT_PREPROCESS) {
  655. using namespace conv_bias;
  656. std::vector<TestArg> args = get_winograd_args(3);
  657. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  658. handle());
  659. check_winograd("1:6:32", checker, args);
  660. }
  661. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F63_4) {
  662. using namespace conv_bias;
  663. std::vector<TestArg> args = get_winograd_mk_packed_args();
  664. Checker<ConvBiasForward> checker(handle());
  665. check_winograd("4:6:16", checker, args, param::MatrixMul::Format::MK4);
  666. }
  667. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F63_4_WEIGHT_PREPROCESS) {
  668. using namespace conv_bias;
  669. std::vector<TestArg> args = get_winograd_mk_packed_args();
  670. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  671. handle());
  672. check_winograd("4:6:16", checker, args, param::MatrixMul::Format::MK4);
  673. }
  674. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F63_4_NCHW44) {
  675. using namespace conv_bias;
  676. std::vector<TestArg> args = get_nchw44_conv_bias_args({3}, 1);
  677. Checker<ConvBiasForward> checker(handle());
  678. check_winograd("4:6:16", checker, args, param::MatrixMul::Format::MK4,
  679. param::ConvBias::Format::NCHW44);
  680. }
  681. TEST_F(ARM_COMMON_MULTI_THREADS,
  682. CONV_BIAS_WINOGRAD_F63_4_NCHW44_WEIGHT_PREPROCESS) {
  683. using namespace conv_bias;
  684. std::vector<TestArg> args = get_nchw44_conv_bias_args({3}, 1);
  685. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  686. handle());
  687. check_winograd("4:6:16", checker, args, param::MatrixMul::Format::MK4,
  688. param::ConvBias::Format::NCHW44);
  689. }
  690. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F54) {
  691. using namespace conv_bias;
  692. std::vector<TestArg> args = get_winograd_args(4);
  693. Checker<ConvBiasForward> checker(handle());
  694. check_winograd("1:5:32", checker, args);
  695. }
  696. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F54_WEIGHT_PREPROCESS) {
  697. using namespace conv_bias;
  698. std::vector<TestArg> args = get_winograd_args(4);
  699. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  700. handle());
  701. check_winograd("1:5:32", checker, args);
  702. }
  703. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F45) {
  704. using namespace conv_bias;
  705. std::vector<TestArg> args = get_winograd_args(5);
  706. Checker<ConvBiasForward> checker(handle());
  707. check_winograd("1:4:32", checker, args);
  708. }
  709. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F45_WEIGHT_PREPROCESS) {
  710. using namespace conv_bias;
  711. std::vector<TestArg> args = get_winograd_args(5);
  712. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  713. handle());
  714. check_winograd("1:4:32", checker, args);
  715. }
  716. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD) {
  717. using namespace conv_bias;
  718. std::vector<TestArg> args = get_winograd_args(3);
  719. Checker<ConvBiasForward> checker(handle());
  720. auto extra_impl = [](const TensorNDArray& tensors, uint32_t m,
  721. param::ConvBias param, Handle* handle) {
  722. megdnn_assert(param.format == param::ConvBias::Format::NCHW);
  723. auto winograd_preprocess_opr =
  724. handle->create_operator<WinogradFilterPreprocess>();
  725. winograd_preprocess_opr->param().output_block_size = m;
  726. TensorLayout filter_transform_layout;
  727. winograd_preprocess_opr->deduce_layout(tensors[1].layout,
  728. filter_transform_layout);
  729. size_t winograd_preprocess_workspace_in_bytes =
  730. winograd_preprocess_opr->get_workspace_in_bytes(
  731. tensors[1].layout, filter_transform_layout);
  732. auto conv_bias_opr = handle->create_operator<ConvBias>();
  733. conv_bias_opr->param() = param;
  734. conv_bias_opr->param().format = param::ConvBias::Format::NCHW_WINOGRAD;
  735. conv_bias_opr->param().output_block_size = m;
  736. size_t conv_bias_workspace_in_bytes =
  737. conv_bias_opr->get_workspace_in_bytes(
  738. tensors[0].layout, filter_transform_layout,
  739. tensors[2].layout, tensors[3].layout, tensors[4].layout,
  740. nullptr);
  741. WorkspaceBundle wb(nullptr, {filter_transform_layout.span().dist_byte(),
  742. conv_bias_workspace_in_bytes,
  743. winograd_preprocess_workspace_in_bytes});
  744. wb.set(malloc(wb.total_size_in_bytes()));
  745. TensorND filter_transform_tensor(wb.get(0),
  746. std::move(filter_transform_layout));
  747. winograd_preprocess_opr->exec(tensors[1], filter_transform_tensor,
  748. wb.get_workspace(2));
  749. conv_bias_opr->exec(tensors[0], filter_transform_tensor, tensors[2],
  750. tensors[3], tensors[4], nullptr,
  751. wb.get_workspace(1));
  752. free(wb.ptr());
  753. };
  754. auto run = [&checker, &extra_impl](
  755. Handle* handle, const std::vector<TestArg>& args,
  756. const std::vector<size_t>& out_size, DType A_dtype,
  757. DType B_dtype, DType C_dtype, DType D_dtype,
  758. const float eps) {
  759. for (auto&& arg : args) {
  760. for (uint32_t m : out_size) {
  761. checker.set_extra_opr_impl(std::bind(extra_impl,
  762. std::placeholders::_1, m,
  763. arg.param, handle));
  764. checker.set_dtype(0, A_dtype)
  765. .set_dtype(1, B_dtype)
  766. .set_dtype(2, C_dtype)
  767. .set_dtype(4, D_dtype)
  768. .set_epsilon(eps)
  769. .set_param(arg.param)
  770. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  771. }
  772. }
  773. };
  774. run(handle(), args, {6}, dtype::Float32(), dtype::Float32(),
  775. dtype::Float32(), dtype::Float32(), 1e-3f);
  776. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  777. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  778. checker.set_rng(0, rng).set_rng(1, rng).set_rng(2, rng);
  779. run(handle(), args, {6}, dtype::Float16(), dtype::Float16(),
  780. dtype::Float16(), dtype::Float16(), 0.35f);
  781. #endif
  782. }
  783. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_PREPROCESS_NCHW44) {
  784. using namespace conv_bias;
  785. std::vector<TestArg> nchw44_args = get_nchw44_conv_bias_args({3}, 1);
  786. Checker<ConvBiasForward> checker(handle());
  787. auto extra_impl = [](const TensorNDArray& tensors, uint32_t m,
  788. param::ConvBias param, Handle* handle) {
  789. megdnn_assert(param.format == param::ConvBias::Format::NCHW44);
  790. auto winograd_preprocess_opr =
  791. handle->create_operator<WinogradFilterPreprocess>();
  792. winograd_preprocess_opr->param().output_block_size = m;
  793. winograd_preprocess_opr->param().format = param::MatrixMul::Format::MK4;
  794. TensorLayout filter_transform_layout;
  795. winograd_preprocess_opr->deduce_layout(tensors[1].layout,
  796. filter_transform_layout);
  797. size_t winograd_preprocess_workspace_in_bytes =
  798. winograd_preprocess_opr->get_workspace_in_bytes(
  799. tensors[1].layout, filter_transform_layout);
  800. auto conv_bias_opr = handle->create_operator<ConvBias>();
  801. conv_bias_opr->param() = param;
  802. conv_bias_opr->param().format =
  803. param::ConvBias::Format::NCHW44_WINOGRAD;
  804. conv_bias_opr->param().output_block_size = m;
  805. size_t conv_bias_workspace_in_bytes =
  806. conv_bias_opr->get_workspace_in_bytes(
  807. tensors[0].layout, filter_transform_layout,
  808. tensors[2].layout, tensors[3].layout, tensors[4].layout,
  809. nullptr);
  810. WorkspaceBundle wb(nullptr, {filter_transform_layout.span().dist_byte(),
  811. conv_bias_workspace_in_bytes,
  812. winograd_preprocess_workspace_in_bytes});
  813. wb.set(malloc(wb.total_size_in_bytes()));
  814. TensorND filter_transform_tensor(wb.get(0),
  815. std::move(filter_transform_layout));
  816. winograd_preprocess_opr->exec(tensors[1], filter_transform_tensor,
  817. wb.get_workspace(2));
  818. conv_bias_opr->exec(tensors[0], filter_transform_tensor, tensors[2],
  819. tensors[3], tensors[4], nullptr,
  820. wb.get_workspace(1));
  821. free(wb.ptr());
  822. };
  823. auto run = [&checker, &extra_impl](
  824. Handle* handle, const std::vector<TestArg>& args,
  825. const std::vector<size_t>& out_size, DType A_dtype,
  826. DType B_dtype, DType C_dtype, DType D_dtype,
  827. const float eps) {
  828. for (auto&& arg : args) {
  829. for (uint32_t m : out_size) {
  830. checker.set_extra_opr_impl(std::bind(extra_impl,
  831. std::placeholders::_1, m,
  832. arg.param, handle));
  833. checker.set_dtype(0, A_dtype)
  834. .set_dtype(1, B_dtype)
  835. .set_dtype(2, C_dtype)
  836. .set_dtype(4, D_dtype)
  837. .set_epsilon(eps)
  838. .set_param(arg.param)
  839. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  840. }
  841. }
  842. };
  843. run(handle(), nchw44_args, {2, 6}, dtype::Float32(), dtype::Float32(),
  844. dtype::Float32(), dtype::Float32(), 1e-3f);
  845. }
  846. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_MK_PACKED_F32_1) {
  847. using namespace conv_bias;
  848. Checker<ConvBiasForward> checker(handle());
  849. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  850. const std::vector<size_t>& out_size, DType A_dtype,
  851. DType B_dtype, DType C_dtype, DType D_dtype,
  852. param::MatrixMul::Format format, float eps) {
  853. for (auto&& arg : args) {
  854. for (uint32_t m : out_size) {
  855. checker.set_extra_opr_impl(std::bind(
  856. winograd_algo_extra_impl, std::placeholders::_1, m,
  857. arg.param, handle, format));
  858. checker.set_dtype(0, A_dtype)
  859. .set_dtype(1, B_dtype)
  860. .set_dtype(2, C_dtype)
  861. .set_dtype(4, D_dtype)
  862. .set_epsilon(eps)
  863. .set_param(arg.param)
  864. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  865. }
  866. }
  867. };
  868. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  869. std::vector<TestArg> args_first_half(args.begin(),
  870. args.begin() + args.size() / 2);
  871. run(handle(), args_first_half, {2, 6}, dtype::Float32{}, dtype::Float32{},
  872. dtype::Float32{}, dtype::Float32{}, param::MatrixMul::Format::MK4,
  873. 1e-3f);
  874. }
  875. TEST_F(ARM_COMMON_MULTI_THREADS,
  876. CONV_BIAS_WINOGRAD_MK_PACKED_F32_1_WEIGHT_PREPROCESS) {
  877. using namespace conv_bias;
  878. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  879. handle());
  880. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  881. const std::vector<size_t>& out_size, DType A_dtype,
  882. DType B_dtype, DType C_dtype, DType D_dtype,
  883. param::MatrixMul::Format format, float eps) {
  884. for (auto&& arg : args) {
  885. for (uint32_t m : out_size) {
  886. checker.set_extra_opr_impl(std::bind(
  887. winograd_algo_extra_impl, std::placeholders::_1, m,
  888. arg.param, handle, format));
  889. checker.set_dtype(0, A_dtype)
  890. .set_dtype(1, B_dtype)
  891. .set_dtype(2, C_dtype)
  892. .set_dtype(4, D_dtype)
  893. .set_epsilon(eps)
  894. .set_param(arg.param)
  895. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  896. }
  897. }
  898. };
  899. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  900. std::vector<TestArg> args_first_half(args.begin(),
  901. args.begin() + args.size() / 2);
  902. run(handle(), args_first_half, {2, 6}, dtype::Float32{}, dtype::Float32{},
  903. dtype::Float32{}, dtype::Float32{}, param::MatrixMul::Format::MK4,
  904. 1e-3f);
  905. }
  906. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_MK_PACKED_F32_2) {
  907. using namespace conv_bias;
  908. Checker<ConvBiasForward> checker(handle());
  909. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  910. const std::vector<size_t>& out_size, DType A_dtype,
  911. DType B_dtype, DType C_dtype, DType D_dtype,
  912. param::MatrixMul::Format format, float eps) {
  913. for (auto&& arg : args) {
  914. for (uint32_t m : out_size) {
  915. checker.set_extra_opr_impl(std::bind(
  916. winograd_algo_extra_impl, std::placeholders::_1, m,
  917. arg.param, handle, format));
  918. checker.set_dtype(0, A_dtype)
  919. .set_dtype(1, B_dtype)
  920. .set_dtype(2, C_dtype)
  921. .set_dtype(4, D_dtype)
  922. .set_epsilon(eps)
  923. .set_param(arg.param)
  924. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  925. }
  926. }
  927. };
  928. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  929. std::vector<TestArg> args_second_half(args.begin() + args.size() / 2,
  930. args.end());
  931. run(handle(), args_second_half, {2, 6}, dtype::Float32{}, dtype::Float32{},
  932. dtype::Float32{}, dtype::Float32{}, param::MatrixMul::Format::MK4,
  933. 1e-3f);
  934. }
  935. TEST_F(ARM_COMMON_MULTI_THREADS,
  936. CONV_BIAS_WINOGRAD_MK_PACKED_F32_2_WEIGHT_PREPROCESS) {
  937. using namespace conv_bias;
  938. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  939. handle());
  940. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  941. const std::vector<size_t>& out_size, DType A_dtype,
  942. DType B_dtype, DType C_dtype, DType D_dtype,
  943. param::MatrixMul::Format format, float eps) {
  944. for (auto&& arg : args) {
  945. for (uint32_t m : out_size) {
  946. checker.set_extra_opr_impl(std::bind(
  947. winograd_algo_extra_impl, std::placeholders::_1, m,
  948. arg.param, handle, format));
  949. checker.set_dtype(0, A_dtype)
  950. .set_dtype(1, B_dtype)
  951. .set_dtype(2, C_dtype)
  952. .set_dtype(4, D_dtype)
  953. .set_epsilon(eps)
  954. .set_param(arg.param)
  955. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  956. }
  957. }
  958. };
  959. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  960. std::vector<TestArg> args_second_half(args.begin() + args.size() / 2,
  961. args.end());
  962. run(handle(), args_second_half, {2, 6}, dtype::Float32{}, dtype::Float32{},
  963. dtype::Float32{}, dtype::Float32{}, param::MatrixMul::Format::MK4,
  964. 1e-3f);
  965. }
  966. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  967. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_MK_PACKED_F16) {
  968. using namespace conv_bias;
  969. Checker<ConvBiasForward> checker(handle());
  970. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  971. const std::vector<size_t>& out_size, DType A_dtype,
  972. DType B_dtype, DType C_dtype, DType D_dtype,
  973. param::MatrixMul::Format format, float eps) {
  974. for (auto&& arg : args) {
  975. for (uint32_t m : out_size) {
  976. checker.set_extra_opr_impl(std::bind(
  977. winograd_algo_extra_impl, std::placeholders::_1, m,
  978. arg.param, handle, format));
  979. checker.set_dtype(0, A_dtype)
  980. .set_dtype(1, B_dtype)
  981. .set_dtype(2, C_dtype)
  982. .set_dtype(4, D_dtype)
  983. .set_epsilon(eps)
  984. .set_param(arg.param)
  985. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  986. }
  987. }
  988. };
  989. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  990. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  991. checker.set_rng(0, rng).set_rng(1, rng).set_rng(2, rng);
  992. run(handle(), args, {2}, dtype::Float16{}, dtype::Float16{},
  993. dtype::Float16{}, dtype::Float16{}, param::MatrixMul::Format::MK8,
  994. 0.25);
  995. }
  996. TEST_F(ARM_COMMON_MULTI_THREADS,
  997. CONV_BIAS_WINOGRAD_MK_PACKED_F16_WEIGHT_PREPROCESS) {
  998. using namespace conv_bias;
  999. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1000. handle());
  1001. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1002. const std::vector<size_t>& out_size, DType A_dtype,
  1003. DType B_dtype, DType C_dtype, DType D_dtype,
  1004. param::MatrixMul::Format format, float eps) {
  1005. for (auto&& arg : args) {
  1006. for (uint32_t m : out_size) {
  1007. checker.set_extra_opr_impl(std::bind(
  1008. winograd_algo_extra_impl, std::placeholders::_1, m,
  1009. arg.param, handle, format));
  1010. checker.set_dtype(0, A_dtype)
  1011. .set_dtype(1, B_dtype)
  1012. .set_dtype(2, C_dtype)
  1013. .set_dtype(4, D_dtype)
  1014. .set_epsilon(eps)
  1015. .set_param(arg.param)
  1016. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1017. }
  1018. }
  1019. };
  1020. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  1021. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1022. checker.set_rng(0, rng).set_rng(1, rng).set_rng(2, rng);
  1023. run(handle(), args, {2}, dtype::Float16{}, dtype::Float16{},
  1024. dtype::Float16{}, dtype::Float16{}, param::MatrixMul::Format::MK8,
  1025. 0.25);
  1026. }
  1027. #endif
  1028. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_MK_PACKED_INT8) {
  1029. using namespace conv_bias;
  1030. Checker<ConvBiasForward> checker(handle());
  1031. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1032. const std::vector<size_t>& out_size, DType A_dtype,
  1033. DType B_dtype, DType C_dtype, DType D_dtype,
  1034. param::MatrixMul::Format format, float eps) {
  1035. for (auto&& arg : args) {
  1036. for (uint32_t m : out_size) {
  1037. checker.set_extra_opr_impl(std::bind(
  1038. winograd_algo_extra_impl, std::placeholders::_1, m,
  1039. arg.param, handle, format));
  1040. checker.set_dtype(0, A_dtype)
  1041. .set_dtype(1, B_dtype)
  1042. .set_dtype(2, C_dtype)
  1043. .set_dtype(4, D_dtype)
  1044. .set_epsilon(eps)
  1045. .set_param(arg.param)
  1046. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1047. }
  1048. }
  1049. };
  1050. #if MEGDNN_AARCH64
  1051. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1052. #else
  1053. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1054. #endif
  1055. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1056. ssprintf("WINOGRAD:%s:8:2:32", matmul_name).c_str()));
  1057. std::vector<TestArg> quantized_args =
  1058. get_quantized_winograd_mk_packed_args(8);
  1059. UniformIntRNG int_rng{-50, 50};
  1060. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1061. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1062. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1063. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1064. }
  1065. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8) {
  1066. using namespace conv_bias;
  1067. Checker<ConvBiasForward> checker(handle());
  1068. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1069. const std::vector<size_t>& out_size, DType A_dtype,
  1070. DType B_dtype, DType C_dtype, DType D_dtype,
  1071. param::MatrixMul::Format format, float eps) {
  1072. for (auto&& arg : args) {
  1073. for (uint32_t m : out_size) {
  1074. checker.set_extra_opr_impl(std::bind(
  1075. winograd_algo_extra_impl, std::placeholders::_1, m,
  1076. arg.param, handle, format));
  1077. checker.set_dtype(0, A_dtype)
  1078. .set_dtype(1, B_dtype)
  1079. .set_dtype(2, C_dtype)
  1080. .set_dtype(4, D_dtype)
  1081. .set_epsilon(eps)
  1082. .set_param(arg.param)
  1083. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1084. }
  1085. }
  1086. };
  1087. #if MEGDNN_AARCH64
  1088. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1089. #else
  1090. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1091. #endif
  1092. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1093. ssprintf("WINOGRAD_NCHW44:%s:8:2:32", matmul_name).c_str()));
  1094. std::vector<TestArg> quantized_args = get_int8_nchw44_args(3, 4);
  1095. UniformIntRNG int_rng{-50, 50};
  1096. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1097. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1098. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1099. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1100. }
  1101. TEST_F(ARM_COMMON_MULTI_THREADS,
  1102. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_GROUPMODE) {
  1103. using namespace conv_bias;
  1104. Checker<ConvBiasForward> checker(handle());
  1105. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1106. const std::vector<size_t>& out_size, DType A_dtype,
  1107. DType B_dtype, DType C_dtype, DType D_dtype,
  1108. param::MatrixMul::Format format, float eps) {
  1109. for (auto&& arg : args) {
  1110. for (uint32_t m : out_size) {
  1111. checker.set_extra_opr_impl(std::bind(
  1112. winograd_algo_extra_impl, std::placeholders::_1, m,
  1113. arg.param, handle, format));
  1114. checker.set_dtype(0, A_dtype)
  1115. .set_dtype(1, B_dtype)
  1116. .set_dtype(2, C_dtype)
  1117. .set_dtype(4, D_dtype)
  1118. .set_epsilon(eps)
  1119. .set_param(arg.param)
  1120. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1121. }
  1122. }
  1123. };
  1124. #if MEGDNN_AARCH64
  1125. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1126. #else
  1127. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1128. #endif
  1129. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1130. ssprintf("WINOGRAD_NCHW44:%s:8:2:32", matmul_name).c_str()));
  1131. std::vector<TestArg> quantized_args =
  1132. get_int8_nchw44_args(3, 4, false, true);
  1133. UniformIntRNG int_rng{-50, 50};
  1134. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1135. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1136. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1137. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1138. }
  1139. TEST_F(ARM_COMMON_MULTI_THREADS,
  1140. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_COMP_F32) {
  1141. using namespace conv_bias;
  1142. Checker<ConvBiasForward> checker(handle());
  1143. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1144. const std::vector<size_t>& out_size, DType A_dtype,
  1145. DType B_dtype, DType C_dtype, DType D_dtype,
  1146. param::MatrixMul::Format format, float eps) {
  1147. for (auto&& arg : args) {
  1148. for (uint32_t m : out_size) {
  1149. checker.set_extra_opr_impl(std::bind(
  1150. winograd_algo_extra_impl, std::placeholders::_1, m,
  1151. arg.param, handle, format));
  1152. checker.set_dtype(0, A_dtype)
  1153. .set_dtype(1, B_dtype)
  1154. .set_dtype(2, C_dtype)
  1155. .set_dtype(4, D_dtype)
  1156. .set_epsilon(eps)
  1157. .set_param(arg.param)
  1158. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1159. }
  1160. }
  1161. };
  1162. float epsilon = 0.001;
  1163. #if MEGDNN_AARCH64
  1164. const char* matmul_name = "AARCH64_F32_MK4_4x16";
  1165. #else
  1166. const char* matmul_name = "ARMV7_F32_MK4_4x8";
  1167. #endif
  1168. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1169. ssprintf("WINOGRAD_NCHW44:%s:4:2:32", matmul_name).c_str()));
  1170. std::vector<TestArg> quantized_args = get_int8_nchw44_args(3, 4, true);
  1171. UniformIntRNG int_rng{-50, 50};
  1172. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1173. run(handle(), quantized_args, {2}, dtype::QuantizedS8(0.41113496f),
  1174. dtype::QuantizedS8(0.01887994f),
  1175. dtype::QuantizedS32(0.41113496f * 0.01887994f),
  1176. dtype::QuantizedS8(0.49550694f), param::MatrixMul::Format::MK4,
  1177. epsilon);
  1178. }
  1179. TEST_F(ARM_COMMON_MULTI_THREADS,
  1180. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_COMP_F32_GROUPMODE) {
  1181. using namespace conv_bias;
  1182. Checker<ConvBiasForward> checker(handle());
  1183. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1184. const std::vector<size_t>& out_size, DType A_dtype,
  1185. DType B_dtype, DType C_dtype, DType D_dtype,
  1186. param::MatrixMul::Format format, float eps) {
  1187. for (auto&& arg : args) {
  1188. for (uint32_t m : out_size) {
  1189. checker.set_extra_opr_impl(std::bind(
  1190. winograd_algo_extra_impl, std::placeholders::_1, m,
  1191. arg.param, handle, format));
  1192. checker.set_dtype(0, A_dtype)
  1193. .set_dtype(1, B_dtype)
  1194. .set_dtype(2, C_dtype)
  1195. .set_dtype(4, D_dtype)
  1196. .set_epsilon(eps)
  1197. .set_param(arg.param)
  1198. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1199. }
  1200. }
  1201. };
  1202. float epsilon = 0.001;
  1203. #if MEGDNN_AARCH64
  1204. const char* matmul_name = "AARCH64_F32_MK4_4x16";
  1205. #else
  1206. const char* matmul_name = "ARMV7_F32_MK4_4x8";
  1207. #endif
  1208. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1209. ssprintf("WINOGRAD_NCHW44:%s:4:2:32", matmul_name).c_str()));
  1210. std::vector<TestArg> quantized_args =
  1211. get_int8_nchw44_args(3, 4, true, true);
  1212. UniformIntRNG int_rng{-50, 50};
  1213. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1214. run(handle(), quantized_args, {2}, dtype::QuantizedS8(0.41113496f),
  1215. dtype::QuantizedS8(0.01887994f),
  1216. dtype::QuantizedS32(0.41113496f * 0.01887994f),
  1217. dtype::QuantizedS8(0.49550694f), param::MatrixMul::Format::MK4,
  1218. epsilon);
  1219. }
  1220. TEST_F(ARM_COMMON_MULTI_THREADS,
  1221. CONV_BIAS_WINOGRAD_MK_PACKED_INT8_WEIGHT_PREPROCESS) {
  1222. using namespace conv_bias;
  1223. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1224. handle());
  1225. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1226. const std::vector<size_t>& out_size, DType A_dtype,
  1227. DType B_dtype, DType C_dtype, DType D_dtype,
  1228. param::MatrixMul::Format format, float eps) {
  1229. for (auto&& arg : args) {
  1230. for (uint32_t m : out_size) {
  1231. checker.set_extra_opr_impl(std::bind(
  1232. winograd_algo_extra_impl, std::placeholders::_1, m,
  1233. arg.param, handle, format));
  1234. checker.set_dtype(0, A_dtype)
  1235. .set_dtype(1, B_dtype)
  1236. .set_dtype(2, C_dtype)
  1237. .set_dtype(4, D_dtype)
  1238. .set_epsilon(eps)
  1239. .set_param(arg.param)
  1240. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1241. }
  1242. }
  1243. };
  1244. #if MEGDNN_AARCH64
  1245. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1246. #else
  1247. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1248. #endif
  1249. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1250. ssprintf("WINOGRAD:%s:8:2:32", matmul_name).c_str()));
  1251. std::vector<TestArg> quantized_args =
  1252. get_quantized_winograd_mk_packed_args(8);
  1253. UniformIntRNG int_rng{-50, 50};
  1254. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1255. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1256. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1257. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1258. }
  1259. TEST_F(ARM_COMMON_MULTI_THREADS,
  1260. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_WEIGHT_PREPROCESS) {
  1261. using namespace conv_bias;
  1262. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1263. handle());
  1264. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1265. const std::vector<size_t>& out_size, DType A_dtype,
  1266. DType B_dtype, DType C_dtype, DType D_dtype,
  1267. param::MatrixMul::Format format, float eps) {
  1268. for (auto&& arg : args) {
  1269. for (uint32_t m : out_size) {
  1270. checker.set_extra_opr_impl(std::bind(
  1271. winograd_algo_extra_impl, std::placeholders::_1, m,
  1272. arg.param, handle, format));
  1273. checker.set_dtype(0, A_dtype)
  1274. .set_dtype(1, B_dtype)
  1275. .set_dtype(2, C_dtype)
  1276. .set_dtype(4, D_dtype)
  1277. .set_epsilon(eps)
  1278. .set_param(arg.param)
  1279. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1280. }
  1281. }
  1282. };
  1283. #if MEGDNN_AARCH64
  1284. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1285. #else
  1286. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1287. #endif
  1288. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1289. ssprintf("WINOGRAD_NCHW44:%s:8:2:32", matmul_name).c_str()));
  1290. std::vector<TestArg> quantized_args = get_int8_nchw44_args(3, 4);
  1291. UniformIntRNG int_rng{-50, 50};
  1292. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1293. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1294. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1295. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1296. }
  1297. TEST_F(ARM_COMMON_MULTI_THREADS,
  1298. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_GROUPMODE_WEIGHT_PREPROCESS) {
  1299. using namespace conv_bias;
  1300. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1301. handle());
  1302. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1303. const std::vector<size_t>& out_size, DType A_dtype,
  1304. DType B_dtype, DType C_dtype, DType D_dtype,
  1305. param::MatrixMul::Format format, float eps) {
  1306. for (auto&& arg : args) {
  1307. for (uint32_t m : out_size) {
  1308. checker.set_extra_opr_impl(std::bind(
  1309. winograd_algo_extra_impl, std::placeholders::_1, m,
  1310. arg.param, handle, format));
  1311. checker.set_dtype(0, A_dtype)
  1312. .set_dtype(1, B_dtype)
  1313. .set_dtype(2, C_dtype)
  1314. .set_dtype(4, D_dtype)
  1315. .set_epsilon(eps)
  1316. .set_param(arg.param)
  1317. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1318. }
  1319. }
  1320. };
  1321. #if MEGDNN_AARCH64
  1322. const char* matmul_name = "AARCH64_INT16X16X32_MK8_8X8";
  1323. #else
  1324. const char* matmul_name = "ARMV7_INT16X16X32_MK8_4X8";
  1325. #endif
  1326. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1327. ssprintf("WINOGRAD_NCHW44:%s:8:2:32", matmul_name).c_str()));
  1328. std::vector<TestArg> quantized_args =
  1329. get_int8_nchw44_args(3, 4, false, true);
  1330. UniformIntRNG int_rng{-50, 50};
  1331. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1332. run(handle(), quantized_args, {2}, dtype::QuantizedS8(2.5f),
  1333. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f),
  1334. dtype::QuantizedS8(60.25f), param::MatrixMul::Format::MK8, 1e-3);
  1335. }
  1336. TEST_F(ARM_COMMON_MULTI_THREADS,
  1337. CONV_BIAS_WINOGRAD_NCHW44_MK_PACKED_INT8_COMP_F32_WEIGHT_PREPROCESS) {
  1338. using namespace conv_bias;
  1339. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1340. handle());
  1341. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1342. const std::vector<size_t>& out_size, DType A_dtype,
  1343. DType B_dtype, DType C_dtype, DType D_dtype,
  1344. param::MatrixMul::Format format, float eps) {
  1345. for (auto&& arg : args) {
  1346. for (uint32_t m : out_size) {
  1347. checker.set_extra_opr_impl(std::bind(
  1348. winograd_algo_extra_impl, std::placeholders::_1, m,
  1349. arg.param, handle, format));
  1350. checker.set_dtype(0, A_dtype)
  1351. .set_dtype(1, B_dtype)
  1352. .set_dtype(2, C_dtype)
  1353. .set_dtype(4, D_dtype)
  1354. .set_epsilon(eps)
  1355. .set_param(arg.param)
  1356. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1357. }
  1358. }
  1359. };
  1360. float epsilon = 0.001;
  1361. #if MEGDNN_AARCH64
  1362. const char* matmul_name = "AARCH64_F32_MK4_4x16";
  1363. #else
  1364. const char* matmul_name = "ARMV7_F32_MK4_4x8";
  1365. #endif
  1366. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1367. ssprintf("WINOGRAD_NCHW44:%s:4:2:32", matmul_name).c_str()));
  1368. std::vector<TestArg> quantized_args = get_int8_nchw44_args(3, 4, true);
  1369. UniformIntRNG int_rng{-50, 50};
  1370. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1371. run(handle(), quantized_args, {2}, dtype::QuantizedS8(0.41113496f),
  1372. dtype::QuantizedS8(0.01887994f),
  1373. dtype::QuantizedS32(0.41113496f * 0.01887994f),
  1374. dtype::QuantizedS8(0.49550694f), param::MatrixMul::Format::MK4,
  1375. epsilon);
  1376. }
  1377. TEST_F(ARM_COMMON_MULTI_THREADS,
  1378. WINOGRAD_NCHW44_MK_PACKED_INT8_COMP_F32_GROUPMODE_WEIGHT_PREPROCESS) {
  1379. using namespace conv_bias;
  1380. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1381. handle());
  1382. auto run = [&checker](Handle* handle, const std::vector<TestArg>& args,
  1383. const std::vector<size_t>& out_size, DType A_dtype,
  1384. DType B_dtype, DType C_dtype, DType D_dtype,
  1385. param::MatrixMul::Format format, float eps) {
  1386. for (auto&& arg : args) {
  1387. for (uint32_t m : out_size) {
  1388. checker.set_extra_opr_impl(std::bind(
  1389. winograd_algo_extra_impl, std::placeholders::_1, m,
  1390. arg.param, handle, format));
  1391. checker.set_dtype(0, A_dtype)
  1392. .set_dtype(1, B_dtype)
  1393. .set_dtype(2, C_dtype)
  1394. .set_dtype(4, D_dtype)
  1395. .set_epsilon(eps)
  1396. .set_param(arg.param)
  1397. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  1398. }
  1399. }
  1400. };
  1401. float epsilon = 0.001;
  1402. #if MEGDNN_AARCH64
  1403. const char* matmul_name = "AARCH64_F32_MK4_4x16";
  1404. #else
  1405. const char* matmul_name = "ARMV7_F32_MK4_4x8";
  1406. #endif
  1407. checker.set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
  1408. ssprintf("WINOGRAD_NCHW44:%s:4:2:32", matmul_name).c_str()));
  1409. std::vector<TestArg> quantized_args =
  1410. get_int8_nchw44_args(3, 4, true, true);
  1411. UniformIntRNG int_rng{-50, 50};
  1412. checker.set_rng(0, &int_rng).set_rng(1, &int_rng).set_rng(2, &int_rng);
  1413. run(handle(), quantized_args, {2}, dtype::QuantizedS8(0.41113496f),
  1414. dtype::QuantizedS8(0.01887994f),
  1415. dtype::QuantizedS32(0.41113496f * 0.01887994f),
  1416. dtype::QuantizedS8(0.49550694f), param::MatrixMul::Format::MK4,
  1417. epsilon);
  1418. }
  1419. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  1420. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F23) {
  1421. using namespace conv_bias;
  1422. std::vector<TestArg> args = get_winograd_mk_packed_args();
  1423. Checker<ConvBiasForward> checker(handle());
  1424. check_winograd_fp16("1:2:32", checker, args, NULL, 0.08);
  1425. }
  1426. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F45_1) {
  1427. using namespace conv_bias;
  1428. std::vector<TestArg> args = get_winograd_args(5);
  1429. std::vector<TestArg> args_head_half(args.begin(),
  1430. args.begin() + args.size() / 2);
  1431. Checker<ConvBiasForward> checker(handle());
  1432. //! fp16 range -1.0 ~ 1.0
  1433. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1434. check_winograd_fp16("1:4:32", checker, args_head_half, rng, 0.25);
  1435. }
  1436. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F45_2) {
  1437. using namespace conv_bias;
  1438. std::vector<TestArg> args = get_winograd_args(5);
  1439. std::vector<TestArg> args_back_half(args.begin() + args.size() / 2,
  1440. args.end());
  1441. Checker<ConvBiasForward> checker(handle());
  1442. //! fp16 range -1.0 ~ 1.0
  1443. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1444. check_winograd_fp16("1:4:32", checker, args_back_half, rng, 0.25);
  1445. }
  1446. //! FIXME: This test may be failed if run `ARM_COMMON.CONV_BIAS_WINOGRAD*`, but
  1447. //! it will pass when run single testcase
  1448. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F63) {
  1449. using namespace conv_bias;
  1450. std::vector<TestArg> args = get_winograd_args(3);
  1451. Checker<ConvBiasForward> checker(handle());
  1452. //! fp16 range -1.0 ~ 1.0
  1453. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1454. check_winograd_fp16("1:6:32", checker, args, rng, 0.3);
  1455. }
  1456. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_8x8_1) {
  1457. using namespace conv_bias;
  1458. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  1459. std::vector<TestArg> args_head_half(args.begin(),
  1460. args.begin() + args.size() / 2);
  1461. Checker<ConvBiasForward> checker(handle());
  1462. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1463. check_winograd_fp16("8:2:32", checker, args_head_half, rng, 0.25,
  1464. param::MatrixMul::Format::MK8);
  1465. }
  1466. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_8x8_2) {
  1467. using namespace conv_bias;
  1468. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  1469. std::vector<TestArg> args_back_half(args.begin() + args.size() / 2,
  1470. args.end());
  1471. Checker<ConvBiasForward> checker(handle());
  1472. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1473. check_winograd_fp16("8:2:32", checker, args_back_half, rng, 0.25,
  1474. param::MatrixMul::Format::MK8);
  1475. }
  1476. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F23_WEIGHT_PREPROCESS) {
  1477. using namespace conv_bias;
  1478. std::vector<TestArg> args = get_winograd_mk_packed_args();
  1479. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1480. handle());
  1481. check_winograd_fp16("1:2:32", checker, args, NULL, 0.08);
  1482. }
  1483. TEST_F(ARM_COMMON_MULTI_THREADS,
  1484. CONV_BIAS_WINOGRAD_F16_F45_1_WEIGHT_PREPROCESS) {
  1485. using namespace conv_bias;
  1486. std::vector<TestArg> args = get_winograd_args(5);
  1487. std::vector<TestArg> args_head_half(args.begin(),
  1488. args.begin() + args.size() / 2);
  1489. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1490. handle());
  1491. //! fp16 range -1.0 ~ 1.0
  1492. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1493. check_winograd_fp16("1:4:32", checker, args_head_half, rng, 0.25);
  1494. }
  1495. TEST_F(ARM_COMMON_MULTI_THREADS,
  1496. CONV_BIAS_WINOGRAD_F16_F45_2_WEIGHT_PREPROCESS) {
  1497. using namespace conv_bias;
  1498. std::vector<TestArg> args = get_winograd_args(5);
  1499. std::vector<TestArg> args_back_half(args.begin() + args.size() / 2,
  1500. args.end());
  1501. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1502. handle());
  1503. //! fp16 range -1.0 ~ 1.0
  1504. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1505. check_winograd_fp16("1:4:32", checker, args_back_half, rng, 0.25);
  1506. }
  1507. //! FIXME: This test may be failed if run `ARM_COMMON.CONV_BIAS_WINOGRAD*`, but
  1508. //! it will pass when run single testcase
  1509. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_F16_F63_WEIGHT_PREPROCESS) {
  1510. using namespace conv_bias;
  1511. std::vector<TestArg> args = get_winograd_args(3);
  1512. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1513. handle());
  1514. //! fp16 range -1.0 ~ 1.0
  1515. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1516. check_winograd_fp16("1:6:32", checker, args, rng, 0.3);
  1517. }
  1518. TEST_F(ARM_COMMON_MULTI_THREADS,
  1519. CONV_BIAS_WINOGRAD_F16_8x8_1_WEIGHT_PREPROCESS) {
  1520. using namespace conv_bias;
  1521. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  1522. std::vector<TestArg> args_head_half(args.begin(),
  1523. args.begin() + args.size() / 2);
  1524. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1525. handle());
  1526. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1527. check_winograd_fp16("8:2:32", checker, args_head_half, rng, 0.25,
  1528. param::MatrixMul::Format::MK8);
  1529. }
  1530. TEST_F(ARM_COMMON_MULTI_THREADS,
  1531. CONV_BIAS_WINOGRAD_F16_8x8_2_WEIGHT_PREPROCESS) {
  1532. using namespace conv_bias;
  1533. std::vector<TestArg> args = get_winograd_mk_packed_args(8);
  1534. std::vector<TestArg> args_back_half(args.begin() + args.size() / 2,
  1535. args.end());
  1536. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1537. handle());
  1538. Float16PeriodicalRNG* rng = new Float16PeriodicalRNG(0x3c00);
  1539. check_winograd_fp16("8:2:32", checker, args_back_half, rng, 0.25,
  1540. param::MatrixMul::Format::MK8);
  1541. }
  1542. #endif
  1543. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_WINOGRAD_INT8_8X8) {
  1544. using namespace conv_bias;
  1545. std::vector<TestArg> args = get_quantized_winograd_mk_packed_args(8);
  1546. Checker<ConvBiasForward> checker(handle());
  1547. UniformIntRNG rng{-50, 50};
  1548. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  1549. .set_dtype(1, dtype::QuantizedS8(2.5f))
  1550. .set_dtype(2, dtype::QuantizedS32(6.25f))
  1551. .set_dtype(4, dtype::QuantizedS8(60.25f))
  1552. .set_rng(0, &rng)
  1553. .set_rng(1, &rng)
  1554. .set_rng(2, &rng);
  1555. check_winograd("8:2:32", checker, args, param::MatrixMul::Format::MK8);
  1556. }
  1557. TEST_F(ARM_COMMON_MULTI_THREADS,
  1558. CONV_BIAS_WINOGRAD_INT8_8X8_WEIGHT_PREPROCESS) {
  1559. using namespace conv_bias;
  1560. std::vector<TestArg> args = get_quantized_winograd_mk_packed_args(8);
  1561. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  1562. handle());
  1563. UniformIntRNG rng{-50, 50};
  1564. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  1565. .set_dtype(1, dtype::QuantizedS8(2.5f))
  1566. .set_dtype(2, dtype::QuantizedS32(6.25f))
  1567. .set_dtype(4, dtype::QuantizedS8(60.25f))
  1568. .set_rng(0, &rng)
  1569. .set_rng(1, &rng)
  1570. .set_rng(2, &rng);
  1571. check_winograd("8:2:32", checker, args, param::MatrixMul::Format::MK8);
  1572. }
  1573. void checker_conv_bias(std::vector<conv_bias::TestArg> args, Handle* handle,
  1574. RNG* rng, float epsilon, DType type0, DType type1,
  1575. DType type2, DType type3, const char* algo_name) {
  1576. using namespace conv_bias;
  1577. Checker<ConvBias> checker(handle);
  1578. checker.set_before_exec_callback(
  1579. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  1580. checker.set_dtype(0, type0);
  1581. checker.set_dtype(1, type1);
  1582. checker.set_dtype(2, type2);
  1583. checker.set_dtype(4, type3);
  1584. checker.set_epsilon(epsilon);
  1585. if (NULL != rng) {
  1586. checker.set_rng(0, rng).set_rng(1, rng).set_rng(2, rng).set_rng(3, rng);
  1587. }
  1588. for (auto&& arg : args) {
  1589. checker.set_param(arg.param).execs(
  1590. {arg.src, arg.filter, arg.bias, {}, {}});
  1591. }
  1592. }
  1593. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COL_FP32_STRIDE2_PREPROCESS) {
  1594. #define cb(name) \
  1595. check_conv_bias_preprocess( \
  1596. get_conv_bias_args({1, 2, 3, 4, 5, 6, 7}, 2, false, false, false), \
  1597. handle(), nullptr, 0.001, dtype::Float32(), dtype::Float32(), \
  1598. dtype::Float32(), dtype::Float32(), name);
  1599. #if MEGDNN_AARCH64
  1600. cb("IM2COLMATMUL:AARCH64_F32K8X12X1")
  1601. cb("IM2COLMATMUL:AARCH64_F32K4X16X1")
  1602. #elif MEGDNN_ARMV7
  1603. cb("IM2COLMATMUL:ARMV7_F32")
  1604. #endif
  1605. #undef cb
  1606. }
  1607. // clang-format off
  1608. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COL_FP32_STRIDE2) {
  1609. #define cb(name) \
  1610. check_conv_bias( \
  1611. get_conv_bias_args({1, 2, 3, 4, 5, 6, 7}, 2, false, false, false), \
  1612. handle(), name);
  1613. #if MEGDNN_AARCH64
  1614. cb("IM2COLMATMUL:AARCH64_F32K8X12X1")
  1615. cb("IM2COLMATMUL:AARCH64_F32K4X16X1")
  1616. cb("IM2COLMATMUL:FB_F32_K8X12X1")
  1617. #elif MEGDNN_ARMV7
  1618. cb("IM2COLMATMUL:ARMV7_F32")
  1619. #endif
  1620. #undef cb
  1621. }
  1622. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COL_FP32_STRIDE1_PREPROCESS) {
  1623. #define cb(name) \
  1624. check_conv_bias_preprocess( \
  1625. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, false), \
  1626. handle(), nullptr, 0.001, dtype::Float32(), dtype::Float32(), \
  1627. dtype::Float32(), dtype::Float32(), name);
  1628. #if MEGDNN_AARCH64
  1629. cb("IM2COLMATMUL:AARCH64_F32K8X12X1")
  1630. cb("IM2COLMATMUL:AARCH64_F32K4X16X1")
  1631. #elif MEGDNN_ARMV7
  1632. cb("IM2COLMATMUL:ARMV7_F32")
  1633. #endif
  1634. #undef cb
  1635. }
  1636. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COL_FP32_STRIDE1) {
  1637. #define cb(name) \
  1638. check_conv_bias( \
  1639. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, false), \
  1640. handle(), name);
  1641. #if MEGDNN_AARCH64
  1642. cb("IM2COLMATMUL:AARCH64_F32K8X12X1")
  1643. cb("IM2COLMATMUL:AARCH64_F32K4X16X1")
  1644. cb("IM2COLMATMUL:FB_F32_K8X12X1")
  1645. #elif MEGDNN_ARMV7
  1646. cb("IM2COLMATMUL:ARMV7_F32")
  1647. cb("IM2COLMATMUL:FB_F32_K8X12X1")
  1648. #endif
  1649. #undef cb
  1650. }
  1651. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM) {
  1652. UniformIntRNG rng{-50, 50};
  1653. #define cb(name) \
  1654. checker_conv_bias(get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1655. false, true, true), \
  1656. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1657. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1658. dtype::QuantizedS8(60.25f), name); \
  1659. checker_conv_bias( \
  1660. get_conv_bias_args({1}, 2, false, false, false, true, true), \
  1661. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1662. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1663. dtype::QuantizedS8(60.25f), name);
  1664. float epsilon = 0.001;
  1665. #if MEGDNN_AARCH64
  1666. #if __ARM_FEATURE_DOTPROD
  1667. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X12X4_DOTPROD");
  1668. #else
  1669. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X8X8");
  1670. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K4X4X16");
  1671. #endif
  1672. #elif MEGDNN_ARMV7
  1673. epsilon = 1;
  1674. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X8X8");
  1675. #endif
  1676. #undef cb
  1677. }
  1678. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_PREPROCESS) {
  1679. UniformIntRNG rng{-50, 50};
  1680. #define cb(name) \
  1681. check_conv_bias_preprocess(get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1682. false, true, true), \
  1683. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1684. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1685. dtype::QuantizedS8(60.25f), name); \
  1686. check_conv_bias_preprocess( \
  1687. get_conv_bias_args({1}, 2, false, false, false, true, true), \
  1688. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1689. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1690. dtype::QuantizedS8(60.25f), name);
  1691. float epsilon = 0.001;
  1692. #if MEGDNN_AARCH64
  1693. #if __ARM_FEATURE_DOTPROD
  1694. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X12X4_DOTPROD");
  1695. #else
  1696. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X8X8");
  1697. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K4X4X16");
  1698. #endif
  1699. #elif MEGDNN_ARMV7
  1700. epsilon = 1;
  1701. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X8X8");
  1702. #endif
  1703. #undef cb
  1704. }
  1705. #if __ARM_FEATURE_DOTPROD
  1706. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_MK4_DOT) {
  1707. UniformIntRNG rng{-50, 50};
  1708. #define cb(name) \
  1709. checker_conv_bias(get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, \
  1710. false, false, false, true), \
  1711. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1712. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1713. dtype::QuantizedS8(60.25f), name); \
  1714. checker_conv_bias( \
  1715. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true), \
  1716. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1717. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1718. dtype::QuantizedS8(60.25f), name);
  1719. float epsilon = 0.001;
  1720. #if MEGDNN_AARCH64
  1721. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1722. #elif MEGDNN_ARMV7
  1723. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1724. #endif
  1725. #undef cb
  1726. }
  1727. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_MK4_DOT_PREPROCESS) {
  1728. UniformIntRNG rng{-50, 50};
  1729. #define cb(name) \
  1730. check_conv_bias_preprocess(get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, \
  1731. false, false, false, true), \
  1732. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1733. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1734. dtype::QuantizedS8(60.25f), name); \
  1735. checker_conv_bias( \
  1736. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true), \
  1737. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1738. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1739. dtype::QuantizedS8(60.25f), name);
  1740. float epsilon = 0.001;
  1741. #if MEGDNN_AARCH64
  1742. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1743. #elif MEGDNN_ARMV7
  1744. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1745. #endif
  1746. #undef cb
  1747. }
  1748. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_MK4_DOT_S2_FUSE) {
  1749. UniformIntRNG rng{-50, 50};
  1750. #define cb(name) \
  1751. checker_conv_bias(get_nchw44_conv_bias_args({3}, 2, false, \
  1752. false, false, false, true), \
  1753. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1754. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1755. dtype::QuantizedS8(60.25f), name); \
  1756. float epsilon = 0.001;
  1757. #if MEGDNN_AARCH64
  1758. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1759. #elif MEGDNN_ARMV7
  1760. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1761. #endif
  1762. #undef cb
  1763. }
  1764. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_S8x8x32_MK4_DOT) {
  1765. UniformIntRNG rng{-50, 50};
  1766. #define cb(name) \
  1767. checker_conv_bias( \
  1768. get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1769. true, false, true, false, false, true), \
  1770. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1771. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), {}, name); \
  1772. checker_conv_bias( \
  1773. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true, \
  1774. false, false, true), \
  1775. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1776. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), {}, name);
  1777. float epsilon = 0.001;
  1778. #if MEGDNN_AARCH64
  1779. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1780. #elif MEGDNN_ARMV7
  1781. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1782. #endif
  1783. #undef cb
  1784. }
  1785. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_S8x8x32_MK4_DOT_PREPROCESS) {
  1786. UniformIntRNG rng{-50, 50};
  1787. #define cb(name) \
  1788. check_conv_bias_preprocess( \
  1789. get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1790. true, false, true, false, false, true), \
  1791. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1792. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), {}, name); \
  1793. check_conv_bias_preprocess( \
  1794. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true, \
  1795. false, false, true), \
  1796. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1797. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), {}, name);
  1798. float epsilon = 0.001;
  1799. #if MEGDNN_AARCH64
  1800. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1801. #elif MEGDNN_ARMV7
  1802. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1803. #endif
  1804. #undef cb
  1805. }
  1806. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32_MK4_DOT) {
  1807. UniformIntRNG rng{-50, 50};
  1808. #define cb(name) \
  1809. checker_conv_bias( \
  1810. get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1811. true, false, true, false, false, true), \
  1812. handle(), &rng, epsilon, dtype::Int8(), dtype::Int8(), \
  1813. dtype::Int32(), {}, name); \
  1814. checker_conv_bias( \
  1815. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true, \
  1816. false, false, true), \
  1817. handle(), &rng, epsilon, dtype::Int8(), dtype::Int8(), \
  1818. dtype::Int32(), {}, name);
  1819. float epsilon = 0.001;
  1820. #if MEGDNN_AARCH64
  1821. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1822. #elif MEGDNN_ARMV7
  1823. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1824. #endif
  1825. #undef cb
  1826. }
  1827. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32_MK4_DOT_PREPROCESS) {
  1828. UniformIntRNG rng{-50, 50};
  1829. #define cb(name) \
  1830. check_conv_bias_preprocess( \
  1831. get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1832. true, false, true, false, false, true), \
  1833. handle(), &rng, epsilon, dtype::Int8(), dtype::Int8(), \
  1834. dtype::Int32(), {}, name); \
  1835. check_conv_bias_preprocess( \
  1836. get_nchw44_conv_bias_args({1}, 2, false, true, true, false, true, \
  1837. false, false, true), \
  1838. handle(), &rng, epsilon, dtype::Int8(), dtype::Int8(), \
  1839. dtype::Int32(), {}, name);
  1840. float epsilon = 0.001;
  1841. #if MEGDNN_AARCH64
  1842. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  1843. #elif MEGDNN_ARMV7
  1844. cb("IM2COLMATMUL:AARCH32_INT8_MK4_8X4X4_DOTPROD:96");
  1845. #endif
  1846. #undef cb
  1847. }
  1848. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_CONV1x1_QUANTIZEDSYM_MK4_DOT) {
  1849. UniformIntRNG rng{-50, 50};
  1850. #define cb(name) \
  1851. checker_conv_bias( \
  1852. get_nchw44_conv_bias_args({1}, 1, true, true, false, false, true), \
  1853. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1854. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  1855. dtype::QuantizedS8(60.25f), name); \
  1856. checker_conv_bias( \
  1857. get_nchw44_conv_bias_args({1}, 1, true, true, true, false, true, \
  1858. false, false, true), \
  1859. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  1860. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), {}, name); \
  1861. checker_conv_bias( \
  1862. get_nchw44_conv_bias_args({1}, 1, true, true, true, false, true, \
  1863. false, false, true), \
  1864. handle(), &rng, epsilon, dtype::Int8(), dtype::Int8(), \
  1865. dtype::Int32(), {}, name);
  1866. float epsilon = 0.001;
  1867. #if MEGDNN_AARCH64
  1868. cb("CONV1x1:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD");
  1869. #elif MEGDNN_ARMV7
  1870. cb("CONV1x1:AARCH32_INT8_MK4_8X4X4_DOTPROD");
  1871. #endif
  1872. #undef cb
  1873. }
  1874. #endif
  1875. // clang-format on
  1876. #if MEGDNN_AARCH64 || MEGDNN_ARMV7
  1877. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUANTIZEDASYM) {
  1878. NormalRNG rng(128.f);
  1879. #define cb(name) \
  1880. checker_conv_bias(get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, \
  1881. false, true, true), \
  1882. handle(), &rng, epsilon, \
  1883. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1884. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1885. dtype::QuantizedS32(1.2 * 1.3), \
  1886. dtype::Quantized8Asymm(50.3f, (uint8_t)120), name); \
  1887. checker_conv_bias( \
  1888. get_conv_bias_args({1}, 2, false, false, false, true, true), \
  1889. handle(), &rng, epsilon, \
  1890. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1891. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1892. dtype::QuantizedS32(1.2 * 1.3), \
  1893. dtype::Quantized8Asymm(50.3f, (uint8_t)120), name);
  1894. float epsilon = 0.001;
  1895. #if MEGDNN_AARCH64
  1896. #if __ARM_FEATURE_DOTPROD
  1897. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X4_DOTPROD");
  1898. #else
  1899. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X8");
  1900. #endif
  1901. #elif MEGDNN_ARMV7
  1902. epsilon = 1;
  1903. cb("IM2COLMATMUL:ARMV7_QUINT8_K4X8X8");
  1904. #endif
  1905. #undef cb
  1906. }
  1907. TEST_F(ARM_COMMON_MULTI_THREADS,
  1908. CONV_BIAS_IM2COLMATMUL_QUANTIZEDASYM_FILTERPREPROCESS) {
  1909. NormalRNG rng(128.f);
  1910. #define cb(name) \
  1911. check_conv_bias_preprocess( \
  1912. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, false, \
  1913. true, true), \
  1914. handle(), &rng, epsilon, \
  1915. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1916. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1917. dtype::QuantizedS32(1.2 * 1.3), \
  1918. dtype::Quantized8Asymm(50.3f, (uint8_t)120), name); \
  1919. check_conv_bias_preprocess( \
  1920. get_conv_bias_args({1}, 2, false, false, false, true, true), \
  1921. handle(), &rng, epsilon, \
  1922. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1923. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1924. dtype::QuantizedS32(1.2 * 1.3), \
  1925. dtype::Quantized8Asymm(50.3f, (uint8_t)120), name);
  1926. float epsilon = 0.001;
  1927. #if MEGDNN_AARCH64
  1928. #if __ARM_FEATURE_DOTPROD
  1929. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X4_DOTPROD");
  1930. #else
  1931. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X8");
  1932. #endif
  1933. #elif MEGDNN_ARMV7
  1934. epsilon = 1;
  1935. cb("IM2COLMATMUL:ARMV7_QUINT8_K4X8X8");
  1936. #endif
  1937. #undef cb
  1938. }
  1939. #endif
  1940. #if MEGDNN_AARCH64 || MEGDNN_ARMV7
  1941. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUINT8x8x32) {
  1942. UniformIntRNG rng{-50, 50};
  1943. float epsilon = 0.001;
  1944. #define cb(name) \
  1945. checker_conv_bias( \
  1946. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true), \
  1947. handle(), &rng, epsilon, \
  1948. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1949. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1950. dtype::QuantizedS32(1.2 * 1.3), {}, name); \
  1951. checker_conv_bias(get_conv_bias_args({1}, 2, false, true, true), handle(), \
  1952. &rng, epsilon, \
  1953. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1954. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1955. dtype::QuantizedS32(1.2 * 1.3), {}, name);
  1956. #if MEGDNN_AARCH64
  1957. #if __ARM_FEATURE_DOTPROD
  1958. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X4_DOTPROD");
  1959. #else
  1960. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X8");
  1961. #endif
  1962. #elif MEGDNN_ARMV7
  1963. #if __ARM_FEATURE_DOTPROD
  1964. cb("IM2COLMATMUL:AARCH32_QUINT8_K4X8X4");
  1965. #endif
  1966. cb("IM2COLMATMUL:ARMV7_QUINT8_K4X8X8");
  1967. #endif
  1968. #undef cb
  1969. }
  1970. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_QUINT8x8x32_FILTERPREPROCESS) {
  1971. UniformIntRNG rng{-50, 50};
  1972. float epsilon = 0.001;
  1973. #define cb(name) \
  1974. check_conv_bias_preprocess( \
  1975. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true), \
  1976. handle(), &rng, epsilon, \
  1977. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1978. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1979. dtype::QuantizedS32(1.2 * 1.3), {}, name); \
  1980. check_conv_bias_preprocess(get_conv_bias_args({1}, 2, false, true, true), \
  1981. handle(), &rng, epsilon, \
  1982. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  1983. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  1984. dtype::QuantizedS32(1.2 * 1.3), {}, name);
  1985. #if MEGDNN_AARCH64
  1986. #if __ARM_FEATURE_DOTPROD
  1987. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X4_DOTPROD");
  1988. #else
  1989. cb("IM2COLMATMUL:AARCH64_QUINT8_K8X8X8");
  1990. #endif
  1991. #elif MEGDNN_ARMV7
  1992. #if __ARM_FEATURE_DOTPROD
  1993. cb("IM2COLMATMUL:AARCH32_QUINT8_K4X8X4");
  1994. #endif
  1995. cb("IM2COLMATMUL:ARMV7_QUINT8_K4X8X8");
  1996. #endif
  1997. #undef cb
  1998. }
  1999. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COLMATMUL_INT8x8x16) {
  2000. UniformIntRNG rng{-50, 50};
  2001. float epsilon = 0.001;
  2002. std::vector<conv_bias::TestArg> args_nchw44 =
  2003. get_nchw44_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, true, true, true,
  2004. false, false, false, false, true);
  2005. std::vector<conv_bias::TestArg> args_nchw44_1x1s2 =
  2006. get_nchw44_conv_bias_args({1}, 2, true, true, true, false, false,
  2007. false, false, true);
  2008. #define cb(name) \
  2009. checker_conv_bias( \
  2010. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true), \
  2011. handle(), &rng, epsilon, dtype::Int8{}, dtype::Int8{}, \
  2012. dtype::Int16{}, dtype::Int16{}, name); \
  2013. checker_conv_bias(get_conv_bias_args({1}, 2, false, true, true), handle(), \
  2014. &rng, epsilon, dtype::Int8{}, dtype::Int8{}, \
  2015. dtype::Int16{}, dtype::Int16{}, name);
  2016. #define cb_nchw44(name) \
  2017. checker_conv_bias(args_nchw44, handle(), &rng, epsilon, dtype::Int8{}, \
  2018. dtype::Int8{}, dtype::Int16{}, dtype::Int16{}, name); \
  2019. checker_conv_bias(args_nchw44_1x1s2, handle(), &rng, epsilon, \
  2020. dtype::Int8{}, dtype::Int8{}, dtype::Int16{}, \
  2021. dtype::Int16{}, name);
  2022. #if MEGDNN_AARCH64
  2023. cb("IM2COLMATMUL:AARCH64_INT8X8X16_K8X8X8");
  2024. cb("IM2COLMATMUL:AARCH64_INT8X8X16_K4X4X16");
  2025. cb("IM2COLMATMUL:ARM_COMMON_INT8X8X16");
  2026. #elif MEGDNN_ARMV7
  2027. cb("IM2COLMATMUL:ARM_COMMON_INT8X8X16");
  2028. cb("IM2COLMATMUL:ARMV7_INT8X8X16_K4X8X8");
  2029. cb("IM2COLMATMUL:ARMV7_INT8X8X16_K4X2X16");
  2030. cb_nchw44("IM2COLMATMUL:ARMV7_INT8X8X16_MK4_K8X8X4");
  2031. #endif
  2032. #undef cb
  2033. #undef cb_nchw44
  2034. }
  2035. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COLMATMUL_INT8x8x16_FILTERPREPROCESS) {
  2036. UniformIntRNG rng{-50, 50};
  2037. float epsilon = 0.001;
  2038. #define cb(name) \
  2039. check_conv_bias_preprocess( \
  2040. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true), \
  2041. handle(), &rng, epsilon, dtype::Int8{}, dtype::Int8{}, \
  2042. dtype::Int16{}, dtype::Int16{}, name); \
  2043. check_conv_bias_preprocess(get_conv_bias_args({1}, 2, false, true, true), \
  2044. handle(), &rng, epsilon, dtype::Int8{}, \
  2045. dtype::Int8{}, dtype::Int16{}, dtype::Int16{}, \
  2046. name);
  2047. #if MEGDNN_AARCH64
  2048. cb("IM2COLMATMUL:AARCH64_INT8X8X16_K8X8X8");
  2049. cb("IM2COLMATMUL:AARCH64_INT8X8X16_K4X4X16");
  2050. #elif MEGDNN_ARMV7
  2051. cb("IM2COLMATMUL:ARMV7_INT8X8X16_K4X8X8");
  2052. cb("IM2COLMATMUL:ARMV7_INT8X8X16_K4X2X16");
  2053. #endif
  2054. #undef cb
  2055. }
  2056. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_IM2COLMATMUL_INT8x8x16_NOPACK_FILTERPREPROCESS) {
  2057. UniformIntRNG rng{-50, 50};
  2058. float epsilon = 0.001;
  2059. #define cb(name) \
  2060. check_conv_bias_preprocess( \
  2061. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true), \
  2062. handle(), &rng, epsilon, dtype::Int8{}, dtype::Int8{}, \
  2063. dtype::Int16{}, dtype::Int16{}, name); \
  2064. check_conv_bias_preprocess(get_conv_bias_args({1}, 2, false, true, true), \
  2065. handle(), &rng, epsilon, dtype::Int8{}, \
  2066. dtype::Int8{}, dtype::Int16{}, dtype::Int16{}, \
  2067. name);
  2068. #if MEGDNN_AARCH64
  2069. cb("IM2COLMATMUL:ARM_COMMON_INT8X8X16");
  2070. #elif MEGDNN_ARMV7
  2071. cb("IM2COLMATMUL:ARM_COMMON_INT8X8X16");
  2072. #endif
  2073. #undef cb
  2074. }
  2075. #endif
  2076. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  2077. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_FP16) {
  2078. using namespace conv_bias;
  2079. param::ConvBias cur_param;
  2080. std::vector<conv_bias::TestArg> args =
  2081. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, false);
  2082. std::vector<conv_bias::TestArg> args1 =
  2083. get_conv_bias_args({1}, 2, false, false, false);
  2084. args.insert(args.begin(), args1.begin(), args1.end());
  2085. NormalRNG rng(1);
  2086. #define cb(name) \
  2087. checker_conv_bias(args, handle(), &rng, 0.03, dtype::Float16{}, \
  2088. dtype::Float16{}, dtype::Float16{}, dtype::Float16{}, \
  2089. name);
  2090. #if MEGDNN_AARCH64
  2091. cb("IM2COLMATMUL:AARCH64_F16_K8X24X1");
  2092. #elif MEGDNN_ARMV7
  2093. cb("IM2COLMATMUL:AARCH32_F16_K4X16X1");
  2094. #endif
  2095. #undef cb
  2096. }
  2097. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_FP16_FILTERPREPROCESS) {
  2098. using namespace conv_bias;
  2099. param::ConvBias cur_param;
  2100. std::vector<conv_bias::TestArg> args =
  2101. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, false, false);
  2102. std::vector<conv_bias::TestArg> args1 =
  2103. get_conv_bias_args({1}, 2, false, false, false);
  2104. args.insert(args.begin(), args1.begin(), args1.end());
  2105. NormalRNG rng(1);
  2106. #define cb(name) \
  2107. check_conv_bias_preprocess(args, handle(), &rng, 0.03, dtype::Float16{}, \
  2108. dtype::Float16{}, dtype::Float16{}, \
  2109. dtype::Float16{}, name);
  2110. #if MEGDNN_AARCH64
  2111. cb("IM2COLMATMUL:AARCH64_F16_K8X24X1");
  2112. #elif MEGDNN_ARMV7
  2113. cb("IM2COLMATMUL:AARCH32_F16_K4X16X1");
  2114. #endif
  2115. #undef cb
  2116. }
  2117. #endif
  2118. void checker_conv_bias_mul_int8x8x32(std::vector<conv_bias::TestArg> args,
  2119. Handle* handle, const char* algo_name) {
  2120. using namespace conv_bias;
  2121. Checker<ConvBias> checker(handle);
  2122. checker.set_before_exec_callback(
  2123. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  2124. checker.set_dtype(0, dtype::Int8());
  2125. checker.set_dtype(1, dtype::Int8());
  2126. checker.set_dtype(2, dtype::Int32());
  2127. checker.set_dtype(4, dtype::Int32());
  2128. for (auto&& arg : args) {
  2129. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  2130. }
  2131. UniformIntRNG rng{-50, 50};
  2132. for (auto&& arg : args) {
  2133. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  2134. .set_dtype(1, dtype::QuantizedS8(2.5f))
  2135. .set_dtype(2, dtype::QuantizedS32(6.25f))
  2136. .set_dtype(4, {})
  2137. .set_rng(0, &rng)
  2138. .set_rng(1, &rng)
  2139. .set_rng(2, &rng)
  2140. .set_param(arg.param)
  2141. .execs({arg.src, arg.filter, {}, {}, {}});
  2142. }
  2143. }
  2144. void checker_conv_bias_int8x8x32_preprocess(std::vector<conv_bias::TestArg> args,
  2145. Handle* handle, const char* algo_name) {
  2146. using namespace conv_bias;
  2147. Checker<ConvBiasForward, OprWeightPreprocessProxy<ConvBiasForward>> checker(
  2148. handle);
  2149. checker.set_before_exec_callback(
  2150. conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name));
  2151. checker.set_dtype(0, dtype::Int8());
  2152. checker.set_dtype(1, dtype::Int8());
  2153. checker.set_dtype(2, dtype::Int32());
  2154. checker.set_dtype(4, dtype::Int32());
  2155. for (auto&& arg : args) {
  2156. checker.set_param(arg.param).execs({arg.src, arg.filter, {}, {}, {}});
  2157. }
  2158. UniformIntRNG rng{-50, 50};
  2159. for (auto&& arg : args) {
  2160. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  2161. .set_dtype(1, dtype::QuantizedS8(2.5f))
  2162. .set_dtype(2, dtype::QuantizedS32(6.25f))
  2163. .set_dtype(4, {})
  2164. .set_rng(0, &rng)
  2165. .set_rng(1, &rng)
  2166. .set_rng(2, &rng)
  2167. .set_param(arg.param)
  2168. .execs({arg.src, arg.filter, {}, {}, {}});
  2169. }
  2170. }
  2171. #if MEGDNN_AARCH64 || MEGDNN_ARMV7
  2172. #if !__ARM_FEATURE_DOTPROD
  2173. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32NCHW44_S2) {
  2174. using namespace conv_bias;
  2175. std::vector<conv_bias::TestArg> args =
  2176. get_nchw44_conv_bias_args({2, 5, 7}, 2, false, true, true);
  2177. #define cb(name) checker_conv_bias_mul_int8x8x32(args, handle(), name);
  2178. #if MEGDNN_AARCH64
  2179. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2180. #else
  2181. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2182. #endif
  2183. #undef cb
  2184. }
  2185. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32NCHW44_S2_PREPROCESS) {
  2186. using namespace conv_bias;
  2187. std::vector<conv_bias::TestArg> args =
  2188. get_nchw44_conv_bias_args({2, 5, 7}, 2, false, true, true);
  2189. #define cb(name) checker_conv_bias_int8x8x32_preprocess(args, handle(), name);
  2190. #if MEGDNN_AARCH64
  2191. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2192. #else
  2193. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2194. #endif
  2195. #undef cb
  2196. }
  2197. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32NCHW44_S1) {
  2198. using namespace conv_bias;
  2199. std::vector<conv_bias::TestArg> args =
  2200. get_nchw44_conv_bias_args({3, 4, 6}, 1, false, true, true);
  2201. #define cb(name) checker_conv_bias_mul_int8x8x32(args, handle(), name);
  2202. #if MEGDNN_AARCH64
  2203. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2204. #else
  2205. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2206. #endif
  2207. #undef cb
  2208. }
  2209. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32NCHW44_S1_PREPROCESS) {
  2210. using namespace conv_bias;
  2211. std::vector<conv_bias::TestArg> args =
  2212. get_nchw44_conv_bias_args({3, 4, 6}, 1, false, true, true);
  2213. #define cb(name) checker_conv_bias_int8x8x32_preprocess(args, handle(), name);
  2214. #if MEGDNN_AARCH64
  2215. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2216. #else
  2217. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2218. #endif
  2219. #undef cb
  2220. }
  2221. TEST_F(ARM_COMMON_MULTI_THREADS,
  2222. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_S2) {
  2223. UniformIntRNG rng{-50, 50};
  2224. #define cb(name) \
  2225. checker_conv_bias(get_nchw44_conv_bias_args({3, 4, 6}, 2), handle(), &rng, \
  2226. epsilon, dtype::QuantizedS8(2.5f), \
  2227. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2228. dtype::QuantizedS8(60.25f), name);
  2229. float epsilon = 0.001;
  2230. #if MEGDNN_AARCH64
  2231. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2232. #else
  2233. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2234. #endif
  2235. #undef cb
  2236. }
  2237. TEST_F(ARM_COMMON_MULTI_THREADS,
  2238. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_S2_PREPROCESS) {
  2239. UniformIntRNG rng{-50, 50};
  2240. #define cb(name) \
  2241. check_conv_bias_preprocess( \
  2242. get_nchw44_conv_bias_args({3, 4, 6}, 2), handle(), &rng, epsilon, \
  2243. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f), \
  2244. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f), name);
  2245. float epsilon = 0.001;
  2246. #if MEGDNN_AARCH64
  2247. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2248. #else
  2249. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2250. #endif
  2251. #undef cb
  2252. }
  2253. TEST_F(ARM_COMMON_MULTI_THREADS,
  2254. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_S1) {
  2255. UniformIntRNG rng{-50, 50};
  2256. #define cb(name) \
  2257. checker_conv_bias(get_nchw44_conv_bias_args({2, 5, 7}, 1), handle(), &rng, \
  2258. epsilon, dtype::QuantizedS8(2.5f), \
  2259. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2260. dtype::QuantizedS8(60.25f), name);
  2261. float epsilon = 0.001;
  2262. #if MEGDNN_AARCH64
  2263. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2264. #else
  2265. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2266. #endif
  2267. #undef cb
  2268. }
  2269. TEST_F(ARM_COMMON_MULTI_THREADS,
  2270. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_S1_PREPROCESS) {
  2271. UniformIntRNG rng{-50, 50};
  2272. #define cb(name) \
  2273. check_conv_bias_preprocess( \
  2274. get_nchw44_conv_bias_args({2, 5, 7}, 1), handle(), &rng, epsilon, \
  2275. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f), \
  2276. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f), name);
  2277. float epsilon = 0.001;
  2278. #if MEGDNN_AARCH64
  2279. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2280. #else
  2281. cb("IM2COLMATMUL:ARMV7_INT8X8X32_MK4_4X2X16:96");
  2282. #endif
  2283. #undef cb
  2284. }
  2285. #if MEGDNN_AARCH64
  2286. TEST_F(ARM_COMMON_MULTI_THREADS,
  2287. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_FUSE) {
  2288. UniformIntRNG rng{-50, 50};
  2289. #define cb(name) \
  2290. checker_conv_bias(get_nchw44_conv_bias_args({3}, 1), handle(), &rng, \
  2291. epsilon, dtype::QuantizedS8(2.5f), \
  2292. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2293. dtype::QuantizedS8(60.25f), name);
  2294. float epsilon = 0.001;
  2295. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2296. #undef cb
  2297. }
  2298. TEST_F(ARM_COMMON_MULTI_THREADS,
  2299. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44_FUSE_PREPROCESS) {
  2300. UniformIntRNG rng{-50, 50};
  2301. #define cb(name) \
  2302. check_conv_bias_preprocess( \
  2303. get_nchw44_conv_bias_args({3}, 1), handle(), &rng, epsilon, \
  2304. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f), \
  2305. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f), name);
  2306. float epsilon = 0.001;
  2307. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96");
  2308. #undef cb
  2309. }
  2310. #endif
  2311. #endif
  2312. #endif
  2313. #if MEGDNN_AARCH64
  2314. #if __ARM_FEATURE_DOTPROD
  2315. TEST_F(ARM_COMMON_MULTI_THREADS,
  2316. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44DOT_FUSE) {
  2317. UniformIntRNG rng{-50, 50};
  2318. #define cb(name) \
  2319. checker_conv_bias( \
  2320. get_nchw44_conv_bias_args({3}, 1, false, false, false, false, \
  2321. true, false, false, false), \
  2322. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  2323. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2324. dtype::QuantizedS8(60.25f), name);
  2325. float epsilon = 0.001;
  2326. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  2327. #undef cb
  2328. }
  2329. TEST_F(ARM_COMMON_MULTI_THREADS,
  2330. CONV_BIAS_IM2COLMATMUL_QUANTIZEDSYM_NCHW44DOT_FUSE_PREPROCESS) {
  2331. UniformIntRNG rng{-50, 50};
  2332. #define cb(name) \
  2333. check_conv_bias_preprocess( \
  2334. get_nchw44_conv_bias_args({3}, 1, false, false, false, false, \
  2335. true, false, false, false), \
  2336. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  2337. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2338. dtype::QuantizedS8(60.25f), name);
  2339. float epsilon = 0.001;
  2340. cb("IM2COLMATMUL:AARCH64_INT8X8X32_MK4_8X12X4_DOTPROD:96");
  2341. #undef cb
  2342. }
  2343. #endif
  2344. #endif
  2345. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8x8x32) {
  2346. using namespace conv_bias;
  2347. std::vector<conv_bias::TestArg> args =
  2348. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true);
  2349. std::vector<conv_bias::TestArg> args1 =
  2350. get_conv_bias_args({1}, 2, false, true, true);
  2351. args.insert(args.begin(), args1.begin(), args1.end());
  2352. #define cb(name) checker_conv_bias_mul_int8x8x32(args, handle(), name);
  2353. #if MEGDNN_AARCH64
  2354. #if __ARM_FEATURE_DOTPROD
  2355. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X12X4_DOTPROD");
  2356. #else
  2357. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X8X8");
  2358. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K4X4X16");
  2359. #endif
  2360. #elif MEGDNN_ARMV7
  2361. #if __ARM_FEATURE_DOTPROD
  2362. cb("IM2COLMATMUL:AARCH32_INT8_K6X8X4");
  2363. #endif
  2364. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X8X8");
  2365. #endif
  2366. #if MEGDNN_ARMV7
  2367. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X2X16");
  2368. #endif
  2369. #undef cb
  2370. }
  2371. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COLMATMUL_INT8X8X32_FILTER_PREPROCESS) {
  2372. using namespace conv_bias;
  2373. std::vector<conv_bias::TestArg> args =
  2374. get_conv_bias_args({2, 3, 4, 5, 6, 7}, 1, false, true, true);
  2375. std::vector<conv_bias::TestArg> args1 =
  2376. get_conv_bias_args({1}, 2, false, true, true);
  2377. args.insert(args.begin(), args1.begin(), args1.end());
  2378. #define cb(name) checker_conv_bias_int8x8x32_preprocess(args, handle(), name);
  2379. #if MEGDNN_AARCH64
  2380. #if __ARM_FEATURE_DOTPROD
  2381. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X12X4_DOTPROD");
  2382. #else
  2383. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K8X8X8");
  2384. cb("IM2COLMATMUL:AARCH64_INT8X8X32_K4X4X16");
  2385. #endif
  2386. #elif MEGDNN_ARMV7
  2387. #if __ARM_FEATURE_DOTPROD
  2388. cb("IM2COLMATMUL:AARCH32_INT8_K6X8X4");
  2389. #endif
  2390. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X8X8");
  2391. #endif
  2392. #if MEGDNN_ARMV7
  2393. cb("IM2COLMATMUL:ARMV7_INT8X8X32_K4X2X16");
  2394. #endif
  2395. #undef cb
  2396. }
  2397. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COL_S1_MK4_PACK_F32) {
  2398. using namespace conv_bias;
  2399. std::vector<conv_bias::TestArg> args = get_nchw44_conv_bias_args(
  2400. {2, 4, 7}, 1, false, false, false, false, false, true, true);
  2401. #if MEGDNN_AARCH64
  2402. check_conv_bias(args, handle(), "IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1");
  2403. #elif MEGDNN_ARMV7
  2404. check_conv_bias(args, handle(), "IM2COLMATMUL:ARMV7_F32_MK4_PACK_4X12");
  2405. #endif
  2406. }
  2407. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COL_S1_MK4_PACK_F32_PREPROCESS) {
  2408. using namespace conv_bias;
  2409. std::vector<conv_bias::TestArg> args = get_nchw44_conv_bias_args(
  2410. {2, 4, 7}, 1, false, false, false, false, false, true,true);
  2411. #define cb(name) \
  2412. check_conv_bias_preprocess(args, handle(), nullptr, 0.001, \
  2413. dtype::Float32(), dtype::Float32(), \
  2414. dtype::Float32(), dtype::Float32(), name);
  2415. #if MEGDNN_AARCH64
  2416. cb("IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1");
  2417. #elif MEGDNN_ARMV7
  2418. cb("IM2COLMATMUL:ARMV7_F32_MK4_PACK_4X12");
  2419. #endif
  2420. #undef cb
  2421. }
  2422. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COL_S2_MK4_PACK_F32) {
  2423. using namespace conv_bias;
  2424. std::vector<conv_bias::TestArg> args = get_nchw44_conv_bias_args(
  2425. {3, 5, 6}, 2, false, false, false, false, false, true, true);
  2426. #define cb(name) check_conv_bias(args, handle(), name);
  2427. #if MEGDNN_AARCH64
  2428. cb("IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1");
  2429. #elif MEGDNN_ARMV7
  2430. cb("IM2COLMATMUL:ARMV7_F32_MK4_PACK_4X12");
  2431. #endif
  2432. #undef cb
  2433. }
  2434. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COL_S2_MK4_PACK_F32_FUSE_PREPROCESS) {
  2435. using namespace conv_bias;
  2436. std::vector<conv_bias::TestArg> args = get_nchw44_conv_bias_args(
  2437. {3}, 2, false, false, false, false, false, true, true, false);
  2438. #define cb(name) \
  2439. check_conv_bias_preprocess(args, handle(), nullptr, 0.001, \
  2440. dtype::Float32(), dtype::Float32(), \
  2441. dtype::Float32(), dtype::Float32(), name);
  2442. #if MEGDNN_AARCH64
  2443. cb("IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1");
  2444. #elif MEGDNN_ARMV7
  2445. cb("IM2COLMATMUL:ARMV7_F32_MK4_PACK_4X12");
  2446. #endif
  2447. #undef cb
  2448. }
  2449. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_IM2COL_S2_MK4_PACK_F32_FUSE) {
  2450. using namespace conv_bias;
  2451. std::vector<conv_bias::TestArg> args = get_nchw44_conv_bias_args(
  2452. {3}, 2, false, false, false, false, false, true, true, false);
  2453. #define cb(name) check_conv_bias(args, handle(), name);
  2454. #if MEGDNN_AARCH64
  2455. cb("IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1");
  2456. #elif MEGDNN_ARMV7
  2457. cb("IM2COLMATMUL:ARMV7_F32_MK4_PACK_4X12");
  2458. #endif
  2459. #undef cb
  2460. }
  2461. /***************************** Conv1x1 Algo Test ***********************/
  2462. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_F32) {
  2463. using namespace conv_bias;
  2464. std::vector<conv_bias::TestArg> args = get_conv_bias_1x1_args(false, false);
  2465. #if MEGDNN_AARCH64
  2466. check_conv_bias(args, handle(), "CONV1x1:AARCH64_F32K8X12X1:24");
  2467. #elif MEGDNN_ARMV7
  2468. check_conv_bias(args, handle(), "CONV1x1:ARMV7_F32:48");
  2469. #endif
  2470. std::vector<conv_bias::TestArg> gemv_args;
  2471. for (auto&& arg : args)
  2472. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2473. gemv_args.emplace_back(arg);
  2474. }
  2475. check_conv_bias(gemv_args, handle(), "CONV1x1_GEMV");
  2476. }
  2477. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_MK4_PACK_F32) {
  2478. using namespace conv_bias;
  2479. std::vector<conv_bias::TestArg> args =
  2480. get_nchw44_conv_bias_args({1}, 1, true, false, false);
  2481. #if MEGDNN_AARCH64
  2482. check_conv_bias(args, handle(), "CONV1x1:AARCH64_F32_MK4_K8X12X1:24");
  2483. #elif MEGDNN_ARMV7
  2484. check_conv_bias(args, handle(), "CONV1x1:ARMV7_F32_MK4_PACK_4X12:24");
  2485. #endif
  2486. std::vector<conv_bias::TestArg> gemv_args;
  2487. for (auto&& arg : args)
  2488. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2489. gemv_args.emplace_back(arg);
  2490. }
  2491. check_conv_bias(gemv_args, handle(), "CONV1x1_GEMV");
  2492. }
  2493. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_MK4_NO_PACK_F32) {
  2494. using namespace conv_bias;
  2495. std::vector<conv_bias::TestArg> args =
  2496. get_nchw44_conv_bias_args({1}, 1, true, false, false);
  2497. std::vector<conv_bias::TestArg> args_of_4;
  2498. for (auto&& arg : args) {
  2499. if (arg.src.shape[2] * arg.src.shape[3] % 4 == 0) {
  2500. args_of_4.push_back(arg);
  2501. }
  2502. }
  2503. #if MEGDNN_AARCH64
  2504. check_conv_bias(args_of_4, handle(), "CONV1x1:AARCH64_F32_MK4_4x16:24");
  2505. #elif MEGDNN_ARMV7
  2506. check_conv_bias(args_of_4, handle(), "CONV1x1:ARMV7_F32_MK4_4x8:48");
  2507. #endif
  2508. }
  2509. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  2510. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_F16) {
  2511. using namespace conv_bias;
  2512. std::vector<conv_bias::TestArg> args = get_conv_bias_1x1_args(false, false);
  2513. NormalRNG rng(1);
  2514. #if MEGDNN_AARCH64
  2515. checker_conv_bias(args, handle(), &rng, 0.03, dtype::Float16{},
  2516. dtype::Float16{}, dtype::Float16{}, dtype::Float16{},
  2517. "CONV1x1:AARCH64_F16_K8X24X1:48");
  2518. #elif MEGDNN_ARMV7
  2519. checker_conv_bias(args, handle(), &rng, 0.03, dtype::Float16{},
  2520. dtype::Float16{}, dtype::Float16{}, dtype::Float16{},
  2521. "CONV1x1:AARCH32_F16_K4X16X1:24");
  2522. #endif
  2523. std::vector<conv_bias::TestArg> gemv_args;
  2524. for (auto&& arg : args)
  2525. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2526. gemv_args.emplace_back(arg);
  2527. }
  2528. check_conv_bias(gemv_args, handle(), "CONV1x1_GEMV");
  2529. }
  2530. #endif
  2531. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_QUANTIZEDSYM) {
  2532. UniformIntRNG rng{-50, 50};
  2533. float epsilon = 0.001;
  2534. std::vector<conv_bias::TestArg> args =
  2535. get_conv_bias_1x1_args(false, false, true, true);
  2536. #define cb(name) \
  2537. checker_conv_bias(args, handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  2538. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2539. dtype::QuantizedS8(60.25f), name);
  2540. #if MEGDNN_AARCH64
  2541. #if __ARM_FEATURE_DOTPROD
  2542. cb("CONV1x1:AARCH64_INT8X8X32_K8X12X4_DOTPROD:24");
  2543. #else
  2544. cb("CONV1x1:AARCH64_INT8X8X32_K8X8X8:24");
  2545. cb("CONV1x1:AARCH64_INT8X8X32_K4X4X16:48");
  2546. #endif
  2547. #elif MEGDNN_ARMV7
  2548. epsilon = 1;
  2549. cb("CONV1x1:ARMV7_INT8X8X32_K4X8X8:48");
  2550. #endif
  2551. #undef cb
  2552. std::vector<conv_bias::TestArg> gemv_args;
  2553. for (auto&& arg : args)
  2554. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2555. gemv_args.emplace_back(arg);
  2556. }
  2557. checker_conv_bias(gemv_args, handle(), &rng, epsilon,
  2558. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  2559. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f),
  2560. "CONV1x1_GEMV");
  2561. }
  2562. #if MEGDNN_AARCH64 || MEGDNN_ARMV7
  2563. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_QUANTIZEDASYM) {
  2564. UniformIntRNG rng{-50, 50};
  2565. std::vector<conv_bias::TestArg> args =
  2566. get_conv_bias_1x1_args(false, false, true, true);
  2567. #define cb(name) \
  2568. checker_conv_bias(args, handle(), &rng, epsilon, \
  2569. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  2570. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  2571. dtype::QuantizedS32(1.2 * 1.3), \
  2572. dtype::Quantized8Asymm(50.3f, (uint8_t)120), name);
  2573. float epsilon = 0.001;
  2574. #if MEGDNN_AARCH64
  2575. #if __ARM_FEATURE_DOTPROD
  2576. cb("CONV1x1:AARCH64_QUINT8_K8X8X4_DOTPROD:48");
  2577. #else
  2578. cb("CONV1x1:AARCH64_QUINT8_K8X8X8:24");
  2579. #endif
  2580. #elif MEGDNN_ARMV7
  2581. epsilon = 1;
  2582. cb("CONV1x1:ARMV7_QUINT8_K4X8X8:48");
  2583. #endif
  2584. #undef cb
  2585. std::vector<conv_bias::TestArg> gemv_args;
  2586. for (auto&& arg : args)
  2587. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2588. gemv_args.emplace_back(arg);
  2589. }
  2590. checker_conv_bias(gemv_args, handle(), &rng, epsilon,
  2591. dtype::Quantized8Asymm(1.2f, (uint8_t)125),
  2592. dtype::Quantized8Asymm(1.3f, (uint8_t)129),
  2593. dtype::QuantizedS32(1.2 * 1.3),
  2594. dtype::Quantized8Asymm(50.3f, (uint8_t)120),
  2595. "CONV1x1_GEMV");
  2596. }
  2597. #endif
  2598. #if MEGDNN_AARCH64 || MEGDNN_ARMV7
  2599. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_QUINT8x8x32) {
  2600. NormalRNG rng(128.f);
  2601. float epsilon = 0.001;
  2602. std::vector<conv_bias::TestArg> args = get_conv_bias_1x1_args(true, true);
  2603. #define cb(name) \
  2604. checker_conv_bias(args, handle(), &rng, epsilon, \
  2605. dtype::Quantized8Asymm(1.2f, (uint8_t)125), \
  2606. dtype::Quantized8Asymm(1.3f, (uint8_t)129), \
  2607. dtype::QuantizedS32(1.2 * 1.3), {}, name);
  2608. #if MEGDNN_AARCH64
  2609. #if __ARM_FEATURE_DOTPROD
  2610. cb("CONV1x1:AARCH64_QUINT8_K8X8X4_DOTPROD:24");
  2611. #else
  2612. cb("CONV1x1:AARCH64_QUINT8_K8X8X8:48");
  2613. #endif
  2614. #elif MEGDNN_ARMV7
  2615. #if __ARM_FEATURE_DOTPROD
  2616. cb("CONV1x1:AARCH32_QUINT8_K4X8X4:48");
  2617. #endif
  2618. cb("CONV1x1:ARMV7_QUINT8_K4X8X8:24");
  2619. #endif
  2620. #undef cb
  2621. std::vector<conv_bias::TestArg> gemv_args;
  2622. for (auto&& arg : args)
  2623. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2624. gemv_args.emplace_back(arg);
  2625. }
  2626. checker_conv_bias(gemv_args, handle(), &rng, epsilon,
  2627. dtype::Quantized8Asymm(1.2f, (uint8_t)125),
  2628. dtype::Quantized8Asymm(1.3f, (uint8_t)129),
  2629. dtype::QuantizedS32(1.2 * 1.3), {}, "CONV1x1_GEMV");
  2630. }
  2631. TEST_F(ARM_COMMON_MULTI_THREADS, CONVBIAS_1X1_S1_INT8x8x16) {
  2632. UniformIntRNG rng{-50, 50};
  2633. float epsilon = 0.001;
  2634. std::vector<conv_bias::TestArg> args = get_conv_bias_1x1_args(true, true);
  2635. std::vector<conv_bias::TestArg> args_nchw44 = get_nchw44_conv_bias_args(
  2636. {1}, 1, true, true, true, false, false, false, false, true);
  2637. #define cb(name) \
  2638. checker_conv_bias(args, handle(), &rng, epsilon, dtype::Int8{}, \
  2639. dtype::Int8{}, dtype::Int16{}, dtype::Int16{}, name);
  2640. #define cb_nchw44(name) \
  2641. checker_conv_bias(args_nchw44, handle(), &rng, epsilon, dtype::Int8{}, \
  2642. dtype::Int8{}, dtype::Int16{}, dtype::Int16{}, name);
  2643. #if MEGDNN_AARCH64
  2644. cb("CONV1x1:AARCH64_INT8X8X16_K8X8X8:24");
  2645. cb("CONV1x1:AARCH64_INT8X8X16_K4X4X16:24");
  2646. #elif MEGDNN_ARMV7
  2647. cb("CONV1x1:ARMV7_INT8X8X16_K4X8X8:24");
  2648. cb("CONV1x1:ARMV7_INT8X8X16_K4X2X16:48");
  2649. cb_nchw44("CONV1x1:ARMV7_INT8X8X16_MK4_K8X8X4:48");
  2650. #endif
  2651. cb("CONV1x1:ARM_COMMON_INT8X8X16:48");
  2652. #undef cb
  2653. #undef cb_nchw44
  2654. std::vector<conv_bias::TestArg> gemv_args;
  2655. for (auto&& arg : args)
  2656. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2657. gemv_args.emplace_back(arg);
  2658. }
  2659. checker_conv_bias(gemv_args, handle(), &rng, epsilon, dtype::Int8{},
  2660. dtype::Int8{}, dtype::Int16{}, dtype::Int16{},
  2661. "CONV1x1_GEMV");
  2662. }
  2663. #endif
  2664. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_INT8x8x32) {
  2665. using namespace conv_bias;
  2666. std::vector<conv_bias::TestArg> args = get_conv_bias_1x1_args(true, true);
  2667. #define cb(name) checker_conv_bias_mul_int8x8x32(args, handle(), name);
  2668. #if MEGDNN_AARCH64
  2669. #if __ARM_FEATURE_DOTPROD
  2670. cb("CONV1x1:AARCH64_INT8X8X32_K8X12X4_DOTPROD:48");
  2671. #else
  2672. cb("CONV1x1:AARCH64_INT8X8X32_K8X8X8:24");
  2673. cb("CONV1x1:AARCH64_INT8X8X32_K4X4X16:24");
  2674. #endif
  2675. #elif MEGDNN_ARMV7
  2676. #if __ARM_FEATURE_DOTPROD
  2677. cb("CONV1x1:AARCH32_INT8_K6X8X4:48");
  2678. #endif
  2679. cb("CONV1x1:ARMV7_INT8X8X32_K4X8X8:24");
  2680. #endif
  2681. #if MEGDNN_ARMV7
  2682. cb("CONV1x1:ARMV7_INT8X8X32_K4X2X16:48");
  2683. #endif
  2684. #undef cb
  2685. std::vector<conv_bias::TestArg> gemv_args;
  2686. for (auto&& arg : args)
  2687. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2688. gemv_args.emplace_back(arg);
  2689. }
  2690. checker_conv_bias_mul_int8x8x32(gemv_args, handle(), "CONV1x1_GEMV");
  2691. }
  2692. #ifndef __ARM_FEATURE_DOTPROD
  2693. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_INT8x8x32_MK4) {
  2694. using namespace conv_bias;
  2695. std::vector<conv_bias::TestArg> args =
  2696. get_nchw44_conv_bias_args({1}, 1, true, true, true);
  2697. #define cb(name) checker_conv_bias_mul_int8x8x32(args, handle(), name);
  2698. #if MEGDNN_AARCH64
  2699. cb("CONV1x1:AARCH64_INT8X8X32_MK4_4X4X16:24");
  2700. #elif MEGDNN_ARMV7
  2701. cb("CONV1x1:ARMV7_INT8X8X32_MK4_4X2X16:24");
  2702. #endif
  2703. #undef cb
  2704. UniformIntRNG rng{-50, 50};
  2705. float epsilon = 0.001;
  2706. #define cb(name) \
  2707. checker_conv_bias(get_nchw44_conv_bias_args({1}, 1, true, false, false), \
  2708. handle(), &rng, epsilon, dtype::QuantizedS8(2.5f), \
  2709. dtype::QuantizedS8(2.5f), dtype::QuantizedS32(6.25f), \
  2710. dtype::QuantizedS8(60.25f), name);
  2711. #if MEGDNN_AARCH64
  2712. cb("CONV1x1:AARCH64_INT8X8X32_MK4_4X4X16:24");
  2713. #elif MEGDNN_ARMV7
  2714. cb("CONV1x1:ARMV7_INT8X8X32_MK4_4X2X16:24");
  2715. #endif
  2716. #undef cb
  2717. }
  2718. #endif
  2719. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_INT8x8x32_NCHW44) {
  2720. using namespace conv_bias;
  2721. std::vector<conv_bias::TestArg> args =
  2722. get_nchw44_conv_bias_args({1}, 1, true, false, false);
  2723. UniformIntRNG rng{-50, 50};
  2724. float epsilon = 0.001;
  2725. std::vector<conv_bias::TestArg> gemv_args;
  2726. for (auto&& arg : args)
  2727. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2728. gemv_args.emplace_back(arg);
  2729. }
  2730. checker_conv_bias(gemv_args, handle(), &rng, epsilon,
  2731. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  2732. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f),
  2733. "CONV1x1_GEMV");
  2734. }
  2735. #ifdef __ARM_FEATURE_DOTPROD
  2736. TEST_F(ARM_COMMON_MULTI_THREADS, CONV_BIAS_1X1_S1_INT8x8x32_NCHW44_DOT) {
  2737. using namespace conv_bias;
  2738. std::vector<conv_bias::TestArg> args =
  2739. get_nchw44_conv_bias_args({1}, 1, true, false, false, false, true);
  2740. UniformIntRNG rng{-50, 50};
  2741. float epsilon = 0.001;
  2742. std::vector<conv_bias::TestArg> gemv_args;
  2743. for (auto&& arg : args)
  2744. if (arg.src.shape[2] == 1 && arg.src.shape[3] == 1) {
  2745. gemv_args.emplace_back(arg);
  2746. }
  2747. checker_conv_bias(gemv_args, handle(), &rng, epsilon,
  2748. dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
  2749. dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f),
  2750. "CONV1x1_GEMV");
  2751. }
  2752. #endif
  2753. // vim: syntax=cpp.doxygen

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