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 143 kB

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

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