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

Method run_cv_benchmark

dnn/test/common/relayout.cpp:116–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114} // namespace megdnn
115
116void test::relayout::run_cv_benchmark(Handle* handle) {
117 auto handle_naive = create_cpu_handle(2);
118 std::vector<TestArg> args;
119
120 args.push_back(generate_transpose_args(1, 255, 256, 1, dtype::Int32()));
121 args.push_back(generate_transpose_args(1, 513, 1025, 3, dtype::Int32()));
122
123 args.push_back(generate_transpose_args(1, 255, 256, 1, dtype::Uint8()));
124 args.push_back(generate_transpose_args(1, 513, 1025, 3, dtype::Uint8()));
125
126 args.push_back(generate_transpose_args(1, 255, 256, 3, dtype::Float32()));
127 args.push_back(generate_transpose_args(1, 513, 1025, 1, dtype::Float32()));
128
129 args.push_back(generate_transpose_args(2, 987, 573, 6, dtype::Float32()));
130
131 Benchmarker<Relayout> benchmarker(handle);
132 Benchmarker<Relayout> benchmarker_naive(handle_naive.get());
133
134 Checker<Relayout> checker(handle);
135 benchmarker_naive.set_times(1).set_display(false);
136 benchmarker.set_times(1).set_display(false);
137 for (auto&& arg : args) {
138 checker.execl({arg.src, arg.dst});
139 auto t0 = benchmarker.execl({arg.src, arg.dst});
140 auto t1 = benchmarker_naive.execl({arg.src, arg.dst});
141 double k = arg.dst.span().dist_byte() * 1e3 / (1024 * 1024 * 1024);
142 printf("cur=%7.3fms,%5.2fGiB/s naive=%7.3fms,%5.2fGiB/s %s %s\n", t0, k / t0,
143 t1, k / t1, arg.dst.TensorShape::to_string().c_str(),
144 arg.dst.dtype.name());
145 }
146}
147TEST(RELAYOUT, TRANSPOSE_DET) {
148 auto run = [](const TensorShape& shape, const std::vector<size_t>& dimshuffle,
149 bool expect_is_transpose, const TransposeParam& p = {}) {

Callers

nothing calls this directly

Calls 7

generate_transpose_argsFunction · 0.85
dist_byteMethod · 0.80
spanMethod · 0.80
push_backMethod · 0.45
getMethod · 0.45
execlMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected