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

Function benchmark_winograd

dnn/test/x86/conv_bias.cpp:3067–3109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3065}
3066
3067void benchmark_winograd(
3068 const char* algo_name, Handle* handle, size_t kernel, size_t pack_size) {
3069 auto&& args = get_winograd_benchmark_args(kernel, pack_size);
3070 using namespace conv_bias;
3071 constexpr size_t RUN = 10;
3072 Benchmarker<ConvBias> benchmark(handle);
3073 benchmark.set_display(false);
3074 benchmark.set_times(RUN);
3075
3076 Benchmarker<ConvBias> benchmark_winograd(handle);
3077 benchmark_winograd.set_display(false);
3078 benchmark_winograd.set_times(RUN);
3079
3080 for (auto&& arg : args) {
3081 TensorLayout dst_layout;
3082 auto opr = handle->create_operator<ConvBias>();
3083 opr->param() = arg.param;
3084 opr->deduce_layout(
3085 {arg.src, dtype::Float32()}, {arg.filter, dtype::Float32()},
3086 {arg.bias, dtype::Float32()}, {}, dst_layout);
3087 //! dst.nr_elems * IC * FH * FW * 2
3088 float computations = dst_layout.total_nr_elems() * arg.filter[1] *
3089 arg.filter[2] * arg.filter[3] * 2.0 * 8.0 /
3090 (1024 * 1024 * 1024) * 1e3;
3091
3092 auto used =
3093 benchmark.set_param(arg.param).exec({arg.src, arg.filter, {}, {}, {}}) /
3094 RUN;
3095
3096 benchmark_winograd.set_param(arg.param);
3097 auto used_winograd = algo_benchmark<ConvBias>(
3098 benchmark_winograd,
3099 {arg.src, arg.filter, {}, {}, {}}, algo_name) /
3100 RUN;
3101
3102 printf("%s %s: normal: %f ms %f Gflops winograd: %f ms %f GFlops "
3103 "speedup: "
3104 "%f\n",
3105 arg.src.to_string().c_str(), arg.filter.to_string().c_str(), used,
3106 computations / used, used_winograd, computations / used_winograd,
3107 used / used_winograd);
3108 }
3109}
3110} // namespace
3111
3112TEST_F(X86, BENCHMARK_CONVBIAS_WINOGRAD_F63_8x8) {

Callers 3

TEST_FFunction · 0.70
TEST_FFunction · 0.50
TEST_FFunction · 0.50

Calls 6

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

Tested by

no test coverage detected