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

Function TEST_F

dnn/test/naive/convolution.cpp:15–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#if MEGDNN_WITH_BENCHMARK
14
15TEST_F(NAIVE, BENCHMARK_CONVOLUTION_BACKWARD_DATA) {
16 using Param = ConvolutionBackwardData::Param;
17 auto run = [&](const TensorLayoutArray& tensors, Param param) {
18 Benchmarker<ConvolutionBackwardData> benchmarker_naive(handle());
19 size_t RUN = 500;
20 auto tfloat = benchmarker_naive.set_display(false)
21 .set_dtype(0, dtype::Float32{})
22 .set_dtype(1, dtype::Float32{})
23 .set_times(RUN)
24 .set_param(param)
25 .exec(tensors);
26 size_t IC = tensors[0][1];
27 size_t FH = tensors[0][2];
28 size_t FW = tensors[0][3];
29 printf("fp32 flops: %.3f mflops\n",
30 (IC * tensors[1].total_nr_elems() * FH * FW * 2) /
31 (tfloat / RUN * 1000));
32 };
33
34 auto profile = [&](size_t n, size_t ic, size_t oh, size_t ow, size_t oc, size_t fh,
35 size_t fw, size_t stride = 1, size_t padding = 0) {
36 Param param;
37 param.pad_h = param.pad_w = padding;
38 param.stride_h = param.stride_w = stride;
39 printf("oc: %zd ic: %zd w: %zd h: %zd stride: %zd kernel_size: %zd\n", oc, ic,
40 ow, oh, stride, fh);
41
42 TensorLayout diff = TensorLayout{{n, oc, oh, ow}, dtype::Float32()};
43 TensorLayout filter = TensorLayout{{oc, ic, fh, fw}, dtype::Float32()};
44 TensorLayout grad;
45 {
46 auto opr = handle()->create_operator<ConvolutionBackwardData>();
47 opr->param() = param;
48 opr->deduce_layout(filter, diff, grad);
49 }
50 run(TensorLayoutArray{filter, diff, grad}, param);
51 };
52
53 profile(1, 1, 2, 2, 1, 3, 3);
54 profile(1, 1, 4, 4, 1, 3, 3);
55 profile(1, 1, 8, 8, 1, 3, 3);
56 profile(1, 1, 16, 16, 1, 3, 3);
57 profile(1, 1, 32, 32, 1, 3, 3);
58 profile(1, 1, 64, 64, 1, 3, 3);
59 profile(1, 1, 128, 128, 1, 3, 3);
60}
61
62#endif
63

Callers

nothing calls this directly

Calls 15

profileFunction · 0.85
TensorValueFunction · 0.85
freeFunction · 0.85
TensorLayoutClass · 0.85
set_dtypeMethod · 0.80
exectMethod · 0.80
dimshuffleMethod · 0.80
emplace_backMethod · 0.80
dist_byteMethod · 0.80
spanMethod · 0.80
runFunction · 0.50
sqrtFunction · 0.50

Tested by

no test coverage detected