|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122 |
- #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);
- }
- }
-
- void benchmark_with_contrast(
- const std::vector<conv_bias::TestArg>& args, const std::string algo_name,
- std::vector<DType>& data_type,
- const std::vector<conv_bias::TestArg>& args_contrast,
- const std::string algo_name_contrast, std::vector<DType>& data_type_contrast,
- size_t RUNS, TaskExecutorConfig&& single_thread_config) {
- auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config);
-
- auto benchmarker = Benchmarker<ConvBias>(single_thread_handle.get());
- auto benchmarker_contrast = Benchmarker<ConvBias>(single_thread_handle.get());
-
- benchmarker.set_times(RUNS)
- .set_display(false)
- .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()));
- benchmarker_contrast.set_times(RUNS)
- .set_display(false)
- .set_dtype(0, data_type_contrast[0])
- .set_dtype(1, data_type_contrast[1])
- .set_dtype(2, data_type_contrast[2])
- .set_dtype(4, data_type_contrast[3])
- .set_before_exec_callback(conv_bias::ConvBiasAlgoChecker<ConvBias>(
- algo_name_contrast.c_str()));
-
- size_t arg_size = args.size(), arg_contrast_size = args_contrast.size();
- megdnn_assert(arg_size == arg_contrast_size);
- rep(i, arg_size) {
- TensorLayout dst_layout, dst_layout_contrast;
- auto opr = single_thread_handle.get()->create_operator<ConvBias>();
-
- auto&& arg = args[i];
- opr->param() = arg.param;
- opr->deduce_layout(
- {arg.src, data_type[0]}, {arg.filter, data_type[1]},
- {arg.bias, data_type[2]}, {}, dst_layout);
- float computation = (dst_layout.total_nr_elems() * arg.filter[1] *
- arg.filter[2] * arg.filter[3] * arg.filter[4] * 2.0) /
- (1024 * 1024 * 1024) * 1e3;
- benchmarker.set_param(arg.param);
- auto used = benchmarker.exec({arg.src, arg.filter, arg.bias, {}, {}}) / RUNS;
-
- auto&& arg_contrast = args_contrast[i];
- opr->param() = arg_contrast.param;
- opr->deduce_layout(
- {arg_contrast.src, data_type_contrast[0]},
- {arg_contrast.filter, data_type_contrast[1]},
- {arg_contrast.bias, data_type_contrast[2]}, {}, dst_layout_contrast);
- float computation_contrast =
- (dst_layout_contrast.total_nr_elems() * arg_contrast.filter[1] *
- arg_contrast.filter[2] * arg_contrast.filter[3] *
- arg_contrast.filter[4] * 2.0) /
- (1024 * 1024 * 1024) * 1e3;
- benchmarker_contrast.set_param(arg_contrast.param);
- auto used_contrast = benchmarker_contrast.exec(
- {arg_contrast.src,
- arg_contrast.filter,
- arg_contrast.bias,
- {},
- {}}) /
- RUNS;
-
- printf("Bench case: \n");
- printf("padding: %u, stride: %u, nonline mode: %u\n", arg.param.pad_h,
- arg.param.stride_h, arg.param.nonlineMode);
- printf("%s %s %s\n", arg.src.to_string().c_str(),
- arg.filter.to_string().c_str(), arg.bias.to_string().c_str());
- printf("%s %s %s\n", arg_contrast.src.to_string().c_str(),
- arg_contrast.filter.to_string().c_str(),
- arg_contrast.bias.to_string().c_str());
-
- printf("%s: %f gflops;\n%s: %f gflops\n"
- "spead up = %f\n",
- algo_name.c_str(), computation / used, algo_name_contrast.c_str(),
- computation_contrast / used_contrast, used_contrast / used);
- }
- }
- } // namespace
-
- #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";
- 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";
- 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";
- 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";
- 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);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CHANNEL_WISE_FP16_NCHW88) {
- constexpr size_t RUNS = 50;
-
- std::string algo_name = "F16_CHANNEL_WISE_NCHW88";
- printf("Benchmarker F16_CHANNEL_WISE_NCHW88 algo\n");
- std::vector<DType> data_type = {
- dtype::Float16(), dtype::Float16(), dtype::Float16(), dtype::Float16()};
-
- auto bench_case = [&](size_t N, size_t IC, size_t H, size_t W, size_t FS, size_t P,
- size_t S) {
- 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::GROUP;
- param.format = param::ConvBias::Format::NCHW88;
-
- size_t group = IC;
- size_t OC = IC;
- SmallVector<TensorShape> shapes{
- {N, IC, H, W, 8},
- {group, 1, 1, FS, FS, 8},
- {1, OC, 1, 1, 8},
- {},
- {N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 8}};
- TensorShape dst{N, OC, (H + 2 * P - FS) / S + 1, (W + 2 * P - FS) / S + 1, 8};
- float computations = ((IC / group) * FS * FS * 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, algo_name, RUNS, {4, {4, 5, 6, 7}}, {1, {7}},
- data_type);
- };
-
- bench_case(1, 64, 100, 100, 5, 2, 1);
- bench_case(1, 64, 56, 56, 5, 2, 1);
- bench_case(1, 64, 28, 28, 5, 2, 1);
- bench_case(1, 64, 100, 100, 5, 2, 2);
- bench_case(1, 64, 56, 56, 5, 2, 2);
- bench_case(1, 64, 28, 28, 5, 2, 2);
-
- bench_case(1, 64, 100, 100, 3, 1, 1);
- bench_case(1, 64, 56, 56, 3, 1, 1);
- bench_case(1, 64, 28, 28, 3, 1, 1);
- bench_case(1, 64, 100, 100, 3, 1, 2);
- bench_case(1, 64, 56, 56, 3, 1, 2);
- bench_case(1, 64, 28, 28, 3, 1, 2);
-
- bench_case(1, 64, 100, 100, 2, 0, 1);
- bench_case(1, 64, 56, 56, 2, 0, 1);
- bench_case(1, 64, 28, 28, 2, 0, 1);
- bench_case(1, 64, 100, 100, 2, 0, 2);
- bench_case(1, 64, 56, 56, 2, 0, 2);
- bench_case(1, 64, 28, 28, 2, 0, 2);
- }
-
- TEST_F(ARM_COMMON_BENCHMARK_MULTI_THREADS, BENCHMARK_CONVBIAS_FP16_NCHW88) {
- constexpr size_t RUNS = 40;
- std::vector<DType> data_type = {
- dtype::Float16(), dtype::Float16(), dtype::Float16(), dtype::Float16()};
- 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) {
- 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::NCHW88;
- 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 / 8, H, W, 8};
- TensorShape filter = {OC / 8, IC / 8, FS, FS, 8, 8};
- if (group > 1) {
- filter = {group, OC / group / 8, IC / group / 8, FS, FS, 8, 8};
- param.sparse = param::ConvBias::Sparse::GROUP;
- }
- TensorShape bias = {1, OC / 8, 1, 1, 8};
- TensorShape dst = {N, OC / 8, OH, OW, 8};
-
- 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, 28, 28, 3, 1, 1, 1);
- bench_case(1, 64, 64, 28, 28, 5, 1, 2, 1);
- bench_case(1, 64, 64, 28, 28, 7, 1, 3, 1);
-
- bench_case(1, 64, 64, 28, 28, 3, 1, 1, 2);
- bench_case(1, 64, 64, 28, 28, 5, 1, 2, 2);
- bench_case(1, 64, 64, 28, 28, 7, 1, 3, 2);
-
- bench_case(1, 64, 64, 28, 28, 3, 2, 1, 1);
- bench_case(1, 64, 64, 28, 28, 3, 4, 1, 1);
- bench_case(1, 64, 64, 28, 28, 3, 8, 1, 1);
-
- bench_case(1, 16, 16, 28, 28, 3, 1, 1, 1);
- bench_case(1, 32, 32, 28, 28, 3, 1, 1, 1);
- bench_case(1, 128, 128, 28, 28, 3, 1, 1, 1);
- bench_case(1, 256, 256, 28, 28, 3, 1, 1, 1);
-
- bench_case(1, 64, 64, 7, 7, 3, 1, 1, 1);
- bench_case(1, 64, 64, 14, 14, 3, 1, 1, 1);
- bench_case(1, 64, 64, 56, 56, 3, 1, 1, 1);
- bench_case(1, 64, 64, 112, 112, 3, 1, 1, 1);
- }
-
- #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";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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, 2, 64, 160, 160, 1, 1, 0, 1, true);
- 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);
- }
-
- #if MGB_ENABLE_DOT
- 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_INT8_NCHW44_DOT_S2) {
- 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, 2);
- bench_case(1, 64, 64, 128, 128, 3, 1, 1, 2);
- bench_case(1, 64, 64, 256, 256, 3, 1, 1, 2);
- bench_case(1, 64, 64, 156, 156, 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);
- }
-
- #endif
- 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";
- 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";
- 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 MGB_ENABLE_DOT
- 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";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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";
- 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 MGB_ENABLE_DOT
- 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";
- 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";
- 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";
- 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";
- 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_CONVBIAS_IM2COL_NCHW44_VS_NCHW88) {
- constexpr size_t RUNS = 50;
- using NLMode = param::ConvBias::NonlineMode;
-
- std::vector<conv_bias::TestArg> args_nchw88, args_nchw44;
- auto bench_case = [&](size_t N, size_t IC, size_t OC, size_t H, size_t W, size_t FS,
- size_t group) {
- param::ConvBias param_nchw88, param_nchw44;
- param_nchw88.format = param::ConvBias::Format::NCHW88;
- param_nchw44.format = param::ConvBias::Format::NCHW44;
- for (size_t pad : {1, 2, 4}) {
- for (size_t stride : {1, 2, 3}) {
- for (auto nlmode :
- {NLMode::RELU, NLMode::IDENTITY, NLMode::SIGMOID,
- NLMode::H_SWISH}) {
- param_nchw88.nonlineMode = nlmode;
- param_nchw88.pad_h = pad;
- param_nchw88.pad_w = pad;
- param_nchw88.stride_h = stride;
- param_nchw88.stride_w = stride;
-
- param_nchw44.nonlineMode = nlmode;
- param_nchw44.pad_h = pad;
- param_nchw44.pad_w = pad;
- param_nchw44.stride_h = stride;
- param_nchw44.stride_w = stride;
-
- args_nchw88.emplace_back(
- param_nchw88, TensorShape{N, IC / 8, H, W, 8},
- TensorShape{OC / 8, IC / group / 8, FS, FS, 8, 8},
- TensorShape{1, OC / 8, 1, 1, 8});
- args_nchw44.emplace_back(
- param_nchw44, TensorShape{N, IC / 4, H, W, 4},
- TensorShape{OC / 4, IC / group / 4, FS, FS, 4, 4},
- TensorShape{1, OC / 4, 1, 1, 4});
- }
- }
- }
- };
- std::vector<DType> data_type_fp16 = {
- dtype::Float16(), dtype::Float16(), dtype::Float16(), dtype::Float16()};
- std::vector<DType> data_type_fp32 = {
- 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_nchw88 = "IM2COLMATMUL:AARCH64_F16_MK8_16X12X1:96";
- std::string algo_name_nchw44 = "IM2COLMATMUL:AARCH64_F32_MK4_K8X12X1:96";
-
- benchmark_with_contrast(
- args_nchw88, algo_name_nchw88, data_type_fp16, args_nchw44,
- algo_name_nchw44, data_type_fp32, RUNS, {1, {4}});
- }
-
- 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_CHANNEL_WISE_INT8_INT8_INT16_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::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 = "S8x8x16_CHAN_WISE_STRD1_STRD2_NCHW44";
- printf("Benchmarker S8x8x16_CHAN_WISE_STRD1_STRD2_NCHW44 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);
- }
-
- 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 MGB_ENABLE_DOT
- 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
|