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

Function benchmarker_conv_bias

dnn/test/aarch64/conv_bias.cpp:94–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void benchmarker_conv_bias(
95 std::vector<conv_bias::TestArg> args, Handle* handle, const char* algo_name,
96 const char* cmp_algo_name) {
97 using namespace conv_bias;
98
99 constexpr size_t N = 10;
100 Benchmarker<ConvBias> benchmark_float(handle);
101 benchmark_float
102 .set_before_exec_callback(
103 conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name))
104 .set_times(N)
105 .set_display(false);
106#if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
107 Benchmarker<ConvBias> benchmark_float16(handle);
108 benchmark_float16
109 .set_before_exec_callback(
110 conv_bias::ConvBiasAlgoChecker<ConvBias>(cmp_algo_name))
111 .set_times(N)
112 .set_dtype(0, dtype::Float16())
113 .set_dtype(1, dtype::Float16())
114 .set_dtype(2, dtype::Float16())
115 .set_dtype(4, dtype::Float16())
116 .set_display(false);
117#endif
118 for (auto&& arg : args) {
119 TensorLayout dst_layout;
120 auto opr = handle->create_operator<ConvBias>();
121 opr->param() = arg.param;
122 opr->deduce_layout(
123 {arg.src, dtype::Float32()}, {arg.filter, dtype::Float32()},
124 {arg.bias, dtype::Float32()}, {}, dst_layout);
125 float computations = dst_layout.total_nr_elems() * arg.filter[1] *
126 arg.filter[2] * arg.filter[3] * 2.0 /
127 (1024 * 1024 * 1024) * 1e3; // GFLOPS
128 printf("filter n: %zu c: %zu h:%zu w:%zu ", arg.filter[0], arg.filter[1],
129 arg.filter[2], arg.filter[3]);
130 printf("input c: %zu h:%zu w:%zu \n", arg.src[1], arg.src[2], arg.src[3]);
131 auto time32 = benchmark_float.set_param(arg.param).execs(
132 {arg.src, arg.filter, arg.bias, {}, {}}) /
133 N;
134#if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
135 auto time16 = benchmark_float16.set_param(arg.param).execs(
136 {arg.src, arg.filter, arg.bias, {}, {}}) /
137 N;
138 printf("---------------------------------fp32 flops: %.3f Gflops fp16 "
139 "flops %.3f Gflops speedup: %f\n",
140 computations / time32, computations / time16, time32 / time16);
141#else
142 printf("---------------------------------fp32 flops: %.3f Gflops\n",
143 computations / time32);
144#endif
145 }
146}
147
148TEST_F(AARCH64, BENCHMARK_CONVBIAS_CONV1x1_MATMUL_VS_DIRECT_NCHW88) {
149 constexpr size_t RUNS = 50;

Callers 1

TEST_FFunction · 0.85

Calls 5

set_dtypeMethod · 0.80
paramMethod · 0.45
deduce_layoutMethod · 0.45
total_nr_elemsMethod · 0.45
execsMethod · 0.45

Tested by

no test coverage detected