|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865 |
- /**
- * \file dnn/test/arm_common/conv_bias_multi_thread_benchmark.cpp
- * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
- *
- * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- */
- #include "test/arm_common/fixture.h"
- #include "test/common/benchmarker.h"
- #include "test/common/conv_bias.h"
-
- using namespace megdnn;
- using namespace test;
- using namespace conv_bias;
- #if MEGDNN_WITH_BENCHMARK
- namespace {
- void benchmark_impl(const param::ConvBias param,
- std::vector<std::pair<SmallVector<TensorShape>, float>>&
- shapes_and_computation,
- const std::string algo_name, size_t RUNS,
- TaskExecutorConfig&& multi_thread_config,
- TaskExecutorConfig&& single_thread_config,
- std::vector<DType>& data_type) {
- std::vector<float> multi_thread_times, single_thread_times;
- {
- auto multi_thread_hanle =
- create_cpu_handle(0, true, &multi_thread_config);
- auto benchmarker = Benchmarker<ConvBias>(multi_thread_hanle.get());
- benchmarker.set_times(RUNS)
- .set_display(false)
- .set_param(param)
- .set_dtype(0, data_type[0])
- .set_dtype(1, data_type[1])
- .set_dtype(2, data_type[2])
- .set_dtype(4, data_type[3])
- .set_before_exec_callback(
- conv_bias::ConvBiasAlgoChecker<ConvBias>(
- algo_name.c_str()));
- for (auto shape : shapes_and_computation) {
- multi_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
- }
- }
- {
- auto single_thread_handle =
- create_cpu_handle(0, true, &single_thread_config);
- auto benchmarker = Benchmarker<ConvBias>(single_thread_handle.get());
- benchmarker.set_times(RUNS)
- .set_display(false)
- .set_param(param)
- .set_dtype(0, data_type[0])
- .set_dtype(1, data_type[1])
- .set_dtype(2, data_type[2])
- .set_dtype(4, data_type[3])
- .set_before_exec_callback(
- conv_bias::ConvBiasAlgoChecker<ConvBias>(
- algo_name.c_str()));
- for (auto shape : shapes_and_computation) {
- single_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
- }
- }
- printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
- printf("core_ids:");
- for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
- printf("%zu ", multi_thread_config.affinity_core_set[i]);
- }
- printf(", Single thread core_id %zu\n",
- single_thread_config.affinity_core_set[0]);
- for (size_t i = 0; i < shapes_and_computation.size(); i++) {
- auto shapes = shapes_and_computation[i];
- printf("Bench case: ");
- for (auto&& shape : shapes.first) {
- printf("%s ", shape.to_string().c_str());
- }
- float computations = shapes.second;
- printf("%zu threads gflops: %f,\n single thread gflops: "
- "%f. spead up = %f, speedup/cores=%f\n",
- multi_thread_config.nr_thread,
- computations / multi_thread_times[i],
- computations / single_thread_times[i],
- single_thread_times[i] / multi_thread_times[i],
- single_thread_times[i] / multi_thread_times[i] /
- multi_thread_config.nr_thread);
- }
- }
- } // namespace
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 32);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 32);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 32);
- bench_case(1, 32, 32, 80, 80, 3, 4);
- bench_case(1, 32, 32, 80, 80, 3, 32);
-
- std::string algo_name = "F32DIRECT_LARGE_GROUP";
- printf("Benchmark F32DIRECT_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "F32DIRECT_SMALL_GROUP";
- printf("Benchmark F32DIRECT_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32_STR1) {
- constexpr size_t RUNS = 50;
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 32);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 32);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 32);
- bench_case(1, 32, 32, 80, 80, 3, 4);
- bench_case(1, 32, 32, 80, 80, 3, 32);
-
- std::string algo_name = "F32STRD1_LARGE_GROUP";
- printf("Benchmark F32STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "F32STRD1_SMALL_GROUP";
- printf("Benchmark F32STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF32_STR2) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
-
- std::string algo_name = "F32STRD2_LARGE_GROUP";
- printf("Benchmark F32STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "F32STRD2_SMALL_GROUP";
- printf("Benchmark F32STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF16) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 32);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 32);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 32);
- bench_case(1, 32, 32, 80, 80, 3, 4);
- bench_case(1, 32, 32, 80, 80, 3, 32);
-
- std::string algo_name = "F16DIRECT_LARGE_GROUP";
- printf("Benchmark F16DIRECT_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Float16(), dtype::Float16(),
- dtype::Float16(), dtype::Float16()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "F16DIRECT_SMALL_GROUP";
- printf("Benchmark F16DIRECT_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_DIRECTF16_STR1) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 32);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 32);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 32);
- bench_case(1, 32, 32, 80, 80, 3, 4);
- bench_case(1, 32, 32, 80, 80, 3, 32);
-
- std::string algo_name = "F16STRD1_LARGE_GROUP";
- printf("Benchmark F16STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Float16(), dtype::Float16(),
- dtype::Float16(), dtype::Float16()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "F16STRD1_SMALL_GROUP";
- printf("Benchmark F16STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- #endif
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_DIRECT_INT8x8x16) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 32);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 32);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 32);
- bench_case(1, 32, 32, 80, 80, 3, 4);
- bench_case(1, 32, 32, 80, 80, 3, 32);
-
- std::string algo_name = "I8816DIRECT_LARGE_GROUP";
- printf("Benchmark I8816DIRECT_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Int8(), dtype::Int8(),
- dtype::Int16(), dtype::Int16()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "I8816DIRECT_SMALL_GROUP";
- printf("Benchmark I8816DIRECT_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_DIRECT_INT8x8x16_STR2) {
- constexpr size_t RUNS = 50;
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
- (W + 2 * P - FS) / S + 1};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
-
- std::string algo_name = "I8816STRD2_LARGE_GROUP";
- printf("Benchmark I8816STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Int8(), dtype::Int8(),
- dtype::Int16(), dtype::Int16()};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "I8816STRD2_SMALL_GROUP";
- printf("Benchmark I8816STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE1) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
-
- std::string algo_name = "S8STRD1_LARGE_GROUP";
- printf("Benchmark S8STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "S8STRD1_SMALL_GROUP";
- printf("Benchmark S8STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_INT8_NCHW44) {
- constexpr size_t RUNS = 40;
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S,
- bool is_nchw = false) {
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = P;
- param.pad_w = P;
- param.stride_h = S;
- param.stride_w = S;
- param.sparse = param::ConvBias::Sparse::DENSE;
- param.format = param::ConvBias::Format::NCHW44;
- auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
- auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
- TensorShape src = {N, IC / 4, H, W, 4};
- TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
- if (group > 1) {
- filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
- param.sparse = param::ConvBias::Sparse::GROUP;
- }
- if (is_nchw) {
- src = {N, IC, H, W};
- filter = {OC / 4, FS, FS, IC, 4};
- }
- TensorShape bias = {1, OC / 4, 1, 1, 4};
- TensorShape dst = {N, OC / 4, OH, OW, 4};
-
- SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
- float computations =
- (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
- std::make_pair(shapes, computations)};
- benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
- {1, {7}}, data_type);
- };
- bench_case(1, 3, 64, 224, 224, 7, 1, 3, 2, true);
- bench_case(1, 64, 64, 56, 56, 3, 1, 1, 1);
- bench_case(1, 128, 128, 28, 28, 3, 1, 1, 1);
- bench_case(1, 256, 256, 14, 14, 3, 1, 1, 1);
- bench_case(1, 512, 512, 7, 7, 3, 1, 1, 1);
-
- bench_case(1, 64, 64, 56, 56, 3, 4, 1, 1);
- bench_case(1, 128, 128, 28, 28, 3, 4, 1, 1);
- bench_case(1, 256, 256, 14, 14, 3, 4, 1, 1);
- bench_case(1, 512, 512, 7, 7, 3, 4, 1, 1);
-
- bench_case(1, 4, 64, 224, 224, 7, 1, 1, 2);
- bench_case(1, 256, 128, 56, 56, 3, 1, 1, 2);
- bench_case(1, 512, 256, 28, 28, 3, 1, 1, 2);
- bench_case(1, 4, 32, 224, 224, 3, 1, 1, 2);
-
- bench_case(1, 256, 128, 56, 56, 3, 4, 1, 2);
- bench_case(1, 512, 256, 28, 28, 3, 4, 1, 2);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_INT8_NCHW44_DOT) {
- constexpr size_t RUNS = 40;
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S,
- bool is_nchw = false) {
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = P;
- param.pad_w = P;
- param.stride_h = S;
- param.stride_w = S;
- param.sparse = param::ConvBias::Sparse::DENSE;
- param.format = param::ConvBias::Format::NCHW44_DOT;
- auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
- auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
- TensorShape src = {N, IC / 4, H, W, 4};
- TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
- if (group > 1) {
- filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
- param.sparse = param::ConvBias::Sparse::GROUP;
- }
- if (is_nchw) {
- src = {N, IC, H, W};
- filter = {OC / 4, FS, FS, IC, 4};
- }
- TensorShape bias = {1, OC / 4, 1, 1, 4};
- TensorShape dst = {N, OC / 4, OH, OW, 4};
-
- SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
- float computations =
- (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
- std::make_pair(shapes, computations)};
- benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
- {1, {7}}, data_type);
- };
- bench_case(1, 64, 64, 56, 56, 3, 1, 1, 1);
- bench_case(1, 128, 128, 28, 28, 3, 1, 1, 1);
- bench_case(1, 256, 256, 14, 14, 3, 1, 1, 1);
- bench_case(1, 512, 512, 7, 7, 3, 1, 1, 1);
-
- bench_case(1, 64, 64, 56, 56, 3, 4, 1, 1);
- bench_case(1, 128, 128, 28, 28, 3, 4, 1, 1);
- bench_case(1, 256, 256, 14, 14, 3, 4, 1, 1);
- bench_case(1, 512, 512, 7, 7, 3, 4, 1, 1);
-
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_FLOAT_NCHW44) {
- constexpr size_t RUNS = 40;
- std::vector<DType> data_type = {
- dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S,
- bool is_nchw = false) {
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = P;
- param.pad_w = P;
- param.stride_h = S;
- param.stride_w = S;
- param.sparse = param::ConvBias::Sparse::DENSE;
- param.format = param::ConvBias::Format::NCHW44;
- auto OH = (H + 2 * P - FS) / static_cast<size_t>(S) + 1;
- auto OW = (W + 2 * P - FS) / static_cast<size_t>(S) + 1;
- TensorShape src = {N, IC / 4, H, W, 4};
- TensorShape filter = {OC / 4, IC / 4, FS, FS, 4, 4};
- if (group > 1) {
- filter = {group, OC / group / 4, IC / group / 4, FS, FS, 4, 4};
- param.sparse = param::ConvBias::Sparse::GROUP;
- }
- if (is_nchw) {
- src = {N, IC, H, W};
- filter = {OC / 4, FS, FS, IC, 4};
- }
- TensorShape bias = {1, OC / 4, 1, 1, 4};
- TensorShape dst = {N, OC / 4, OH, OW, 4};
-
- SmallVector<TensorShape> shapes{src, filter, bias, {}, dst};
- float computations =
- (((IC / group) * FS * FS + 1) * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- std::vector<std::pair<SmallVector<TensorShape>, float>> shape_arg = {
- std::make_pair(shapes, computations)};
- benchmark_impl(param, shape_arg, ".+", RUNS, {4, {4, 5, 6, 7}},
- {1, {7}}, data_type);
- };
- bench_case(1, 64, 64, 56, 56, 3, 1, 1, 2);
- bench_case(1, 128, 128, 28, 28, 3, 1, 1, 2);
- bench_case(1, 256, 256, 14, 14, 3, 1, 1, 2);
- bench_case(1, 512, 512, 7, 7, 3, 1, 1, 2);
-
- bench_case(1, 64, 64, 56, 56, 3, 4, 1, 2);
- bench_case(1, 128, 128, 28, 28, 3, 4, 1, 2);
- bench_case(1, 256, 256, 14, 14, 3, 4, 1, 2);
- bench_case(1, 512, 512, 7, 7, 3, 4, 1, 2);
-
- bench_case(1, 64, 64, 56*2, 56*2, 3, 4, 1, 2);
- bench_case(1, 128, 128, 28*2, 28*2, 3, 4, 1, 2);
- bench_case(1, 256, 256, 14*2, 14*2, 3, 4, 1, 2);
- bench_case(1, 512, 512, 7*2, 7*2, 3, 4, 1, 2);
- }
-
-
-
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE2) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
-
- std::string algo_name = "S8STRD2_LARGE_GROUP";
- printf("Benchmark S8STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "S8STRD2_SMALL_GROUP";
- printf("Benchmark S8STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- #if __ARM_FEATURE_DOTPROD
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE1_WITHDOTPROD) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
-
- std::string algo_name = "ARMDOTS8STRD1_LARGE_GROUP";
- printf("Benchmark ARMDOTS8STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "ARMDOTS8STRD1_SMALL_GROUP";
- printf("Benchmark ARMDOTS8STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_INT8_INT8_INT8_STRIDE2_WITHDOTPROD) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
-
- std::string algo_name = "ARMDOTS8STRD2_LARGE_GROUP";
- printf("Benchmark ARMDOTS8STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "ARMDOTS8STRD2_SMALL_GROUP";
- printf("Benchmark ARMDOTS8STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- #endif
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE1) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
-
- std::string algo_name = "QU8STRD1_LARGE_GROUP";
- printf("Benchmark QU8STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
- dtype::Quantized8Asymm(0.2f, 120),
- dtype::QuantizedS32(0.04f),
- dtype::Quantized8Asymm(1.4f, 110)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "QU8STRD1_SMALL_GROUP";
- printf("Benchmark QU8STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE2) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 2);
-
- std::string algo_name = "QU8STRD2_LARGE_GROUP";
- printf("Benchmark QU8STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
- dtype::Quantized8Asymm(0.2f, 120),
- dtype::QuantizedS32(0.04f),
- dtype::Quantized8Asymm(1.4f, 110)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "QU8STRD2_SMALL_GROUP";
- printf("Benchmark QU8STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- #if __ARM_FEATURE_DOTPROD
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE1_WITHDOTPROD) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
- (W + 2 * P - FS) / S + 1};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4, 1, 1);
- bench_case(1, 32, 32, 200, 200, 3, 32, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 32, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 32, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 32, 1, 1);
-
- std::string algo_name = "ARMDOTU8STRD1_LARGE_GROUP";
- printf("Benchmark ARMDOTU8STRD1_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
- dtype::Quantized8Asymm(0.2f, 120),
- dtype::QuantizedS32(0.04f),
- dtype::Quantized8Asymm(1.4f, 110)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "ARMDOTU8STRD1_SMALL_GROUP";
- printf("Benchmark ARMDOTS8STRD1_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 3, 1, 1, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1, 1, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1, 1, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1, 1, 1);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_QUINT8_QUINT8_QUINT8_STRIDE2_WITHDOTPROD) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 2;
- param.stride_w = 2;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group, size_t P, size_t S) {
- SmallVector<TensorShape> shapes{
- {N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1}};
- TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
- (W + 2 * P - FS) / S + 1};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 5, 4, 1, 2);
- bench_case(1, 32, 32, 200, 200, 5, 32, 1, 2);
- bench_case(1, 32, 32, 128, 128, 5, 4, 1, 2);
- bench_case(1, 32, 32, 128, 128, 5, 32, 1, 2);
- bench_case(1, 32, 32, 100, 100, 5, 4, 1, 2);
- bench_case(1, 32, 32, 100, 100, 5, 32, 1, 2);
- bench_case(1, 32, 32, 80, 80, 5, 4, 1, 2);
- bench_case(1, 32, 32, 80, 80, 5, 32, 1, 2);
-
- std::string algo_name = "ARMDOTU8STRD2_LARGE_GROUP";
- printf("Benchmark ARMDOTU8STRD2_LARGE_GROUP algo\n");
- std::vector<DType> data_type = {dtype::Quantized8Asymm(0.2f, 100),
- dtype::Quantized8Asymm(0.2f, 120),
- dtype::QuantizedS32(0.04f),
- dtype::Quantized8Asymm(1.4f, 110)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
-
- algo_name = "ARMDOTU8STRD2_SMALL_GROUP";
- printf("Benchmark ARMDOTU8STRD2_SMALL_GROUP algo\n");
- bench_case(1, 32, 32, 200, 200, 5, 1, 1, 2);
- bench_case(1, 32, 32, 128, 128, 5, 1, 1, 2);
- bench_case(1, 32, 32, 100, 100, 5, 1, 1, 2);
- bench_case(1, 32, 32, 80, 80, 5, 1, 1, 2);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
- #endif
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_WINOGRAD_F32) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4);
-
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 512, 256, 14, 14, 3, 1);
- bench_case(1, 512, 128, 14, 14, 3, 1);
- bench_case(1, 512, 64, 14, 14, 3, 1);
-
- bench_case(1, 512, 512, 7, 7, 3, 1);
- bench_case(1, 512, 256, 7, 7, 3, 1);
- bench_case(1, 512, 128, 7, 7, 3, 1);
- bench_case(1, 512, 64, 7, 7, 3, 1);
-
- std::string algo_name;
- #if MEGDNN_AARCH64
- algo_name = "WINOGRAD:AARCH64_F32_MK4_4x16:4:2";
- #else
- algo_name = "WINOGRAD:ARMV7_F32_MK4_4x8:4:2";
- #endif
- std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- printf("Benchmark WINOGRAD_F32_MK4 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_WINOGRAD_INT8) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {group, OC / group, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 4);
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 4);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 4);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 4);
-
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 512, 256, 14, 14, 3, 1);
- bench_case(1, 512, 128, 14, 14, 3, 1);
- bench_case(1, 512, 64, 14, 14, 3, 1);
-
- bench_case(1, 512, 512, 7, 7, 3, 1);
- bench_case(1, 512, 256, 7, 7, 3, 1);
- bench_case(1, 512, 128, 7, 7, 3, 1);
- bench_case(1, 512, 64, 7, 7, 3, 1);
-
- std::string algo_name;
- #if MEGDNN_AARCH64
- algo_name = "WINOGRAD:AARCH64_INT16X16X32_MK8_8X8:8:2:32";
- #else
- algo_name = "WINOGRAD:ARMV7_INT16X16X32_MK8_4X8:8:2:32";
- #endif
-
-
- std::vector<DType> data_type = {dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f) ,dtype::QuantizedS8(60.25f) };
- printf("Benchmark WINOGRAD_IN8_MK8 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_WINOGRAD_NCHW44_INT8_MK8) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::DENSE;
- param.format = param::ConvBias::Format::NCHW44;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC / 4, H, W, 4},
- {OC / 4, IC / 4, FS, FS, 4, 4},
- {1, OC / 4, 1, 1, 4},
- {},
- {N, OC / 4, H, W, 4}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
-
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 512, 256, 14, 14, 3, 1);
- bench_case(1, 512, 128, 14, 14, 3, 1);
- bench_case(1, 512, 64, 14, 14, 3, 1);
-
- bench_case(1, 512, 512, 7, 7, 3, 1);
- bench_case(1, 512, 256, 7, 7, 3, 1);
- bench_case(1, 512, 128, 7, 7, 3, 1);
- bench_case(1, 512, 64, 7, 7, 3, 1);
-
- std::string algo_name;
- #if MEGDNN_AARCH64
- algo_name = "WINOGRAD_NCHW44:AARCH64_INT16X16X32_MK8_8X8:8:2:32";
- #else
- algo_name = "WINOGRAD_NCHW44:ARMV7_INT16X16X32_MK8_4X8:8:2:32";
- #endif
-
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- printf("Benchmark WINOGRAD_INT8_MK8 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_WINOGRAD_NCHW44_INT8_COMP_F32) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::DENSE; // GROUP;
- param.format = param::ConvBias::Format::NCHW44;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC / 4, H, W, 4},
- {OC / 4, IC / 4, FS, FS, 4, 4},
- {1, OC / 4, 1, 1, 4},
- {},
- {N, OC / 4, H, W, 4}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 200, 200, 3, 1);
- bench_case(1, 32, 32, 128, 128, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
-
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 512, 256, 14, 14, 3, 1);
- bench_case(1, 512, 128, 14, 14, 3, 1);
- bench_case(1, 512, 64, 14, 14, 3, 1);
-
- bench_case(1, 512, 512, 7, 7, 3, 1);
- bench_case(1, 512, 256, 7, 7, 3, 1);
- bench_case(1, 512, 128, 7, 7, 3, 1);
- bench_case(1, 512, 64, 7, 7, 3, 1);
-
- std::string algo_name;
- #if MEGDNN_AARCH64
- algo_name = "WINOGRAD_NCHW44:AARCH64_F32_MK4_4x16:4:2:32";
- #else
- algo_name = "WINOGRAD_NCHW44:ARMV7_F32_MK4_4x8:4:2:32";
- #endif
-
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- printf("Benchmark WINOGRAD_INT8_NCHW44_MK4_COMP_F32 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_IM2COL_FP32) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group) {
- SmallVector<TensorShape> shapes{{N, IC, H, W},
- {OC, IC / group, FS, FS},
- {1, OC, 1, 1},
- {},
- {N, OC, H, W}};
- TensorShape dst{N, OC, H, W};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
- std::vector<DType> data_type = {dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32()};
- bench_case(1, 32, 32, 300, 300, 3, 1);
- bench_case(1, 32, 32, 400, 400, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- bench_case(1, 32, 64, 200, 200, 3, 1);
- bench_case(1, 32, 64, 128, 128, 3, 1);
- bench_case(1, 32, 64, 100, 100, 3, 1);
- bench_case(1, 32, 64, 80, 80, 3, 1);
- bench_case(1, 32, 128, 200, 200, 3, 1);
- bench_case(1, 32, 128, 128, 128, 3, 1);
- bench_case(1, 32, 128, 100, 100, 3, 1);
- bench_case(1, 32, 128, 80, 80, 3, 1);
-
- bench_case(1, 64, 32, 7, 7, 3, 1);
- bench_case(1, 64, 64, 7, 7, 3, 1);
- bench_case(1, 64, 128, 7, 7, 3, 1);
- bench_case(1, 64, 256, 7, 7, 3, 1);
- bench_case(1, 64, 512, 7, 7, 3, 1);
- bench_case(1, 64, 1024, 7, 7, 3, 1);
-
- bench_case(1, 64, 32, 14, 14, 3, 1);
- bench_case(1, 64, 64, 14, 14, 3, 1);
- bench_case(1, 64, 128, 14, 14, 3, 1);
- bench_case(1, 64, 256, 14, 14, 3, 1);
- bench_case(1, 64, 512, 14, 14, 3, 1);
-
- bench_case(1, 64, 1024, 14, 14, 3, 1);
- bench_case(1, 128, 128, 14, 14, 3, 1);
- bench_case(1, 128, 256, 14, 14, 3, 1);
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 256, 512, 14, 14, 3, 1);
- bench_case(1, 512, 1024, 14, 14, 3, 1);
- bench_case(1, 1024, 1024, 14, 14, 3, 1);
- std::string algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:96";
- printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:96\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:192";
- printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:192\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- algo_name = "IM2COLMATMUL:AARCH64_F32K8X12X1:384";
- printf("Benchmark IM2COLMATMUL:AARCH64_F32K8X12X1algo:384\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
- }
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CHANNEL_WISE_INT8_INT8_INT8_STRIDE1) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::GROUP;
- param.format = param::ConvBias::Format::NCHW44;
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t H, size_t W, size_t FS,
- size_t P) {
- size_t group = IC;
- size_t OC = IC;
- size_t S = 1;
- SmallVector<TensorShape> shapes{
- {N, IC, H, W, 4},
- {group, 1, 1, FS, FS, 4},
- {1, OC, 1, 1, 4},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 4}};
- TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1,
- (W + 2 * P - FS) / S + 1, 4};
- float computations =
- ((IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
- bench_case(1, 128, 200, 200, 3, 1);
- bench_case(1, 128, 128, 128, 3, 1);
- bench_case(1, 128, 100, 100, 3, 1);
- bench_case(1, 128, 80, 80, 3, 1);
- bench_case(1, 128, 56, 56, 3, 1);
- bench_case(1, 128, 28, 28, 3, 1);
- bench_case(1, 128, 14, 14, 3, 1);
-
- bench_case(1, 64, 200, 200, 3, 1);
- bench_case(1, 64, 128, 128, 3, 1);
- bench_case(1, 64, 100, 100, 3, 1);
- bench_case(1, 64, 80, 80, 3, 1);
- bench_case(1, 64, 56, 56, 3, 1);
- bench_case(1, 64, 28, 28, 3, 1);
- bench_case(1, 64, 14, 14, 3, 1);
-
- bench_case(1, 32, 200, 200, 3, 1);
- bench_case(1, 32, 128, 128, 3, 1);
- bench_case(1, 32, 100, 100, 3, 1);
- bench_case(1, 32, 80, 80, 3, 1);
- bench_case(1, 32, 56, 56, 3, 1);
- bench_case(1, 32, 28, 28, 3, 1);
- bench_case(1, 32, 14, 14, 3, 1);
-
- std::string algo_name = "S8_CHAN_WISE_STRD1_NCHW44";
- printf("Benchmarker S8_CHAN_WISE_STRD1_NCHW44 algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), dtype::QuantizedS8(60.25f)};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_IM2COL_NCHW44_INT8x8x32_STRIDE1) {
- constexpr size_t RUNS = 50;
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::IDENTITY;
- param.pad_h = 1;
- param.pad_w = 1;
- param.stride_h = 1;
- param.stride_w = 1;
- param.sparse = param::ConvBias::Sparse::DENSE;
- param.format = param::ConvBias::Format::NCHW44;
-
-
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W,
- size_t FS, size_t group=1) {
- SmallVector<TensorShape> shapes{{N, IC, H, W,4},
- {OC, IC / group, FS, FS,4,4},
- {/*1, OC, 1, 1*/},
- {},
- {N, OC, H, W,4}};
- TensorShape dst{N, OC, H, W,4};
- float computations =
- ((4 * IC / group) * FS * FS * dst.total_nr_elems() * 2 +
- dst.total_nr_elems()) *
- 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
-
- bench_case(1, 32, 32, 300, 300, 3, 1);
- bench_case(1, 32, 32, 400, 400, 3, 1);
- bench_case(1, 32, 32, 100, 100, 3, 1);
- bench_case(1, 32, 32, 80, 80, 3, 1);
- bench_case(1, 32, 64, 200, 200, 3, 1);
- bench_case(1, 32, 64, 128, 128, 3, 1);
- bench_case(1, 32, 64, 100, 100, 3, 1);
- bench_case(1, 32, 64, 80, 80, 3, 1);
- bench_case(1, 32, 128, 200, 200, 3, 1);
- bench_case(1, 32, 128, 128, 128, 3, 1);
- bench_case(1, 32, 128, 100, 100, 3, 1);
- bench_case(1, 32, 128, 80, 80, 3, 1);
- #if 1
- bench_case(1, 64, 32, 7, 7, 3, 1);
- bench_case(1, 64, 64, 7, 7, 3, 1);
- bench_case(1, 64, 128, 7, 7, 3, 1);
- bench_case(1, 64, 256, 7, 7, 3, 1);
- bench_case(1, 64, 512, 7, 7, 3, 1);
- bench_case(1, 64, 1024, 7, 7, 3, 1);
-
- bench_case(1, 64, 32, 14, 14, 3, 1);
- bench_case(1, 64, 64, 14, 14, 3, 1);
- bench_case(1, 64, 128, 14, 14, 3, 1);
- bench_case(1, 64, 256, 14, 14, 3, 1);
- bench_case(1, 64, 512, 14, 14, 3, 1);
-
- bench_case(1, 64, 1024, 14, 14, 3, 1);
- bench_case(1, 128, 128, 14, 14, 3, 1);
- bench_case(1, 128, 256, 14, 14, 3, 1);
- bench_case(1, 512, 512, 14, 14, 3, 1);
- bench_case(1, 256, 512, 14, 14, 3, 1);
- bench_case(1, 512, 1024, 14, 14, 3, 1);
- bench_case(1, 1024, 1024, 14, 14, 3, 1);
- #endif
- std::string algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96";
- printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:96 algo\n");
- std::vector<DType> data_type = {
- dtype::QuantizedS8(2.5f), dtype::QuantizedS8(2.5f),
- dtype::QuantizedS32(6.25f), {}};
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
-
-
-
- algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:192";
- printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:192 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
-
- algo_name = "IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:384";
- printf("Benchmarker IM2COLMATMUL:AARCH64_INT8X8X32_MK4_4X4X16:384 algo\n");
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
-
- }
-
- #endif
-
- /*================== BENCHMARK MULTITHREAD CONV1X1 =====================*/
- #if MEGDNN_WITH_BENCHMARK
-
- namespace {
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- get_conv1x1_multithread_benchmark_args() {
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation;
- auto bench_case = [&](size_t IC, size_t OC, size_t H, size_t W) {
- SmallVector<TensorShape> shapes{{1, IC, H, W},
- {OC, IC, 1, 1},
- {1, OC, 1, 1},
- {},
- {1, OC, H, W}};
- TensorShape dst{1, OC, H, W};
- float computations =
- (IC * dst.total_nr_elems() * 2 + dst.total_nr_elems()) * 1e-6;
- shapes_and_computation.push_back(std::make_pair(shapes, computations));
- };
- bench_case(32, 32, 300, 300);
- bench_case(32, 32, 400, 400);
- bench_case(32, 32, 100, 100);
- bench_case(32, 32, 80, 80);
- bench_case(32, 64, 200, 200);
- bench_case(32, 64, 128, 128);
- bench_case(32, 64, 100, 100);
- bench_case(32, 64, 80, 80);
- bench_case(32, 128, 200, 200);
- bench_case(32, 128, 128, 128);
- bench_case(32, 128, 100, 100);
- bench_case(32, 128, 80, 80);
-
- bench_case(64, 32, 7, 7);
- bench_case(64, 64, 7, 7);
- bench_case(64, 128, 7, 7);
- bench_case(64, 256, 7, 7);
- bench_case(64, 512, 7, 7);
- bench_case(64, 1024, 7, 7);
-
- bench_case(64, 32, 14, 14);
- bench_case(64, 64, 14, 14);
- bench_case(64, 128, 14, 14);
- bench_case(64, 256, 14, 14);
- bench_case(64, 512, 14, 14);
-
- bench_case(64, 1024, 14, 14);
- bench_case(128, 128, 14, 14);
- bench_case(128, 256, 14, 14);
- bench_case(512, 512, 14, 14);
- bench_case(256, 512, 14, 14);
- bench_case(512, 1024, 14, 14);
- bench_case(1024, 1024, 14, 14);
- return shapes_and_computation;
- }
-
- void conv1x1_multithread_benchmark(const char* algo_name, DType stype,
- DType ftype, DType btype, DType dtype) {
- constexpr size_t RUNS = 50;
- std::vector<std::pair<SmallVector<TensorShape>, float>>
- shapes_and_computation = get_conv1x1_multithread_benchmark_args();
-
- std::vector<DType> data_type = {stype, ftype, btype, dtype};
-
- param::ConvBias param;
- param.nonlineMode = param::ConvBias::NonlineMode::RELU;
- param.pad_h = 0;
- param.pad_w = 0;
- param.stride_h = 1;
- param.stride_w = 1;
-
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {4}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS,
- {4, {4, 5, 6, 7}}, {1, {7}}, data_type);
- benchmark_impl(param, shapes_and_computation, algo_name, RUNS, {2, {4, 5}},
- {1, {4}}, data_type);
- shapes_and_computation.clear();
- }
- } // namespace
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_CONV1X1_S1_FP32) {
- #if MEGDNN_AARCH64
- conv1x1_multithread_benchmark("CONV1x1:AARCH64_F32K8X12X1:8",
- dtype::Float32(), dtype::Float32(),
- dtype::Float32(), dtype::Float32());
- #else
- conv1x1_multithread_benchmark("CONV1x1:ARMV7_F32:8", dtype::Float32(),
- dtype::Float32(), dtype::Float32(),
- dtype::Float32());
- #endif
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS,
- BENCHMARK_CONVBIAS_CONV1X1_S1_QUANTIZEDASYM) {
- dtype::Quantized8Asymm stype(0.2f, 100);
- dtype::Quantized8Asymm ftype(0.2f, 120);
- dtype::QuantizedS32 btype(0.04f);
- dtype::Quantized8Asymm dtype(1.4f, 110);
- #if MEGDNN_AARCH64
- #if __ARM_FEATURE_DOTPROD
- conv1x1_multithread_benchmark("CONV1x1:AARCH64_QUINT8_K8X8X4_DOTPROD:8",
- stype, ftype, btype, dtype);
- #else
- conv1x1_multithread_benchmark("CONV1x1:AARCH64_QUINT8_K8X8X8:8", stype,
- ftype, btype, dtype);
- #endif
- #else
- conv1x1_multithread_benchmark("CONV1x1:ARMV7_QUINT8_K4X8X8:8", stype, ftype,
- btype, dtype);
- #endif
- }
-
- #endif
-
- // vim: syntax=cpp.doxygen
|