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

Function benchmark_target_algo

dnn/test/cuda/batch_conv_bias.cpp:196–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196void benchmark_target_algo(
197 Handle* handle, const std::vector<BenchArgs>& args, DType src_dtype,
198 DType filter_dtype, DType bias_dtype, DType dst_dtype,
199 const char* algo = nullptr,
200 param::BatchConvBias::Format format = param::BatchConvBias::Format::NCHW4) {
201 megdnn_assert(src_dtype.enumv() == filter_dtype.enumv());
202 megdnn_assert(format == param::BatchConvBias::Format::NCHW4);
203 CUBenchmarker<BatchConvBiasForward> benchmarker(handle);
204 CUBenchmarker<ConvBiasForward> benchmarker_cudnn(handle);
205 CUBenchmarker<BatchedMatrixMul> benchmarker_matmul(handle);
206 size_t RUNS = 1000;
207 benchmarker.set_display(false).set_times(RUNS);
208 benchmarker_cudnn.set_display(false).set_times(RUNS);
209 benchmarker_matmul.set_display(false).set_times(RUNS);
210
211 std::unique_ptr<OprProxy<BatchConvBiasForward>> proxy{
212 new OprProxy<BatchConvBiasForward>{true}};
213
214 if (algo) {
215 benchmarker.set_before_exec_callback(AlgoChecker<BatchConvBiasForward>(algo));
216 } else {
217 benchmarker.set_proxy(proxy);
218 }
219
220#define V1(x) #x
221#define V(x) V1(x)
222#define CUDNN_VERSION_STRING \
223 "v" V(CUDNN_MAJOR) "." V(CUDNN_MINOR) "." V(CUDNN_PATCHLEVEL)
224 benchmarker_cudnn.set_before_exec_callback(
225 conv_bias::ConvBiasAlgoChecker<ConvBiasForward>(
226 ConvBiasForward::algo_name<ConvBias::DefaultParam>(
227 "CUDNN:ConvBiasActivation:"
228 "CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_"
229 "GEMM" CUDNN_VERSION_STRING,
230 {})
231 .c_str()));
232 benchmarker_matmul.set_before_exec_callback(AlgoChecker<BatchedMatrixMul>(
233 ExecutionPolicyAlgoName{"BRUTE_FORCE", {{"CUBLAS", {}}}}));
234
235 benchmarker.set_dtype(0, src_dtype)
236 .set_dtype(1, filter_dtype)
237 .set_dtype(2, bias_dtype)
238 .set_dtype(3, dst_dtype)
239 .set_dtype(4, dst_dtype);
240 benchmarker_cudnn.set_dtype(0, src_dtype)
241 .set_dtype(1, filter_dtype)
242 .set_dtype(2, bias_dtype)
243 .set_dtype(3, dst_dtype)
244 .set_dtype(4, dst_dtype);
245 benchmarker_matmul.set_dtype(0, src_dtype)
246 .set_dtype(1, filter_dtype)
247 .set_dtype(2, bias_dtype);
248
249 using Param = ConvBias::Param;
250 using Format = Param::Format;
251 if (format == Format::NCHW4) {
252 for (auto&& arg : args) {
253 ConvBias::Param param;

Callers 2

TEST_FFunction · 0.70
TEST_FFunction · 0.70

Calls 5

set_dtypeMethod · 0.80
enumvMethod · 0.45
resetMethod · 0.45
execsMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected