MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / benchmark_winograd_compare

Function benchmark_winograd_compare

dnn/test/common/conv_bias.cpp:1072–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070}
1071
1072void benchmark_winograd_compare(
1073 const char* algoA_name, const char* algoB_name, megdnn::Handle* handle,
1074 size_t kernel, size_t pack_size, size_t io_pack_size) {
1075 auto&& args = get_winograd_benchmark_args(kernel, pack_size, io_pack_size);
1076 using namespace conv_bias;
1077 constexpr size_t RUN = 10;
1078
1079 Benchmarker<ConvBias, Timer, OprWeightPreprocessBenchmarkProxy<ConvBias>>
1080 benchmark_winograd(handle);
1081 benchmark_winograd.set_display(false);
1082 benchmark_winograd.set_times(RUN);
1083
1084 for (auto&& arg : args) {
1085 TensorLayout dst_layout;
1086 auto opr = handle->create_operator<ConvBias>();
1087 opr->param() = arg.param;
1088 opr->deduce_layout(
1089 {arg.src, dtype::Float32()}, {arg.filter, dtype::Float32()},
1090 {arg.bias, dtype::Float32()}, {}, dst_layout);
1091 float computations = 0.0;
1092 if (io_pack_size == 1) {
1093 //! dst.nr_elems * IC * FH * FW * 2
1094 computations = dst_layout.total_nr_elems() * arg.filter[1] * arg.filter[2] *
1095 arg.filter[3] * 2.0 / (1024 * 1024 * 1024) * 1e3;
1096 } else {
1097 //! dst.nr_elems * IC/4 * FH * FW * 4 * 2
1098 computations = dst_layout.total_nr_elems() * arg.filter[1] * arg.filter[2] *
1099 arg.filter[3] * arg.filter[4] * 2.0 / (1024 * 1024 * 1024) *
1100 1e3;
1101 }
1102
1103 benchmark_winograd.set_param(arg.param);
1104 auto used_winograd1 =
1105 algo_benchmark<
1106 ConvBias, OprWeightPreprocessBenchmarkProxy<ConvBias>, Timer>(
1107 benchmark_winograd, {arg.src, arg.filter, {}, {}, {}},
1108 algoA_name) /
1109 RUN;
1110 auto used_winograd2 =
1111 algo_benchmark<
1112 ConvBias, OprWeightPreprocessBenchmarkProxy<ConvBias>, Timer>(
1113 benchmark_winograd, {arg.src, arg.filter, {}, {}, {}},
1114 algoB_name) /
1115 RUN;
1116
1117 printf("%s %s: %s: %f ms %f Gflops %s: %f ms %f GFlops "
1118 "speedup: "
1119 "%f\n",
1120 arg.src.to_string().c_str(), arg.filter.to_string().c_str(), algoA_name,
1121 used_winograd1, computations / used_winograd1, algoB_name,
1122 used_winograd2, computations / used_winograd2,
1123 used_winograd2 / used_winograd1);
1124 }
1125}
1126
1127void benchmark_with_contrast(
1128 const std::vector<std::pair<conv_bias::TestArg, float>>& args_with_computation,

Callers 1

TEST_FFunction · 0.85

Calls 5

paramMethod · 0.45
deduce_layoutMethod · 0.45
total_nr_elemsMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected