| 357 | ////////////////// Algo Benchmark //////////////////////// |
| 358 | template <typename Opr, typename Proxy = OprProxy<Opr>, typename T = Timer> |
| 359 | float algo_benchmark( |
| 360 | Benchmarker<Opr, T, Proxy>& benchmark, TensorLayoutArray layouts, |
| 361 | const std::string& algo_base) { |
| 362 | Proxy proxy; |
| 363 | auto opr = benchmark.opr(); |
| 364 | opr->param() = benchmark.param(); |
| 365 | proxy.deduce_layout(opr, layouts); |
| 366 | auto algos = OprAlgoProxy<Opr>::get_all_algorithms_info_safe(opr, layouts); |
| 367 | float min_used = std::numeric_limits<float>::max(); |
| 368 | bool execed = false; |
| 369 | for (auto i : algos) { |
| 370 | if (std::regex_match(i.desc.name, std::regex("(" + algo_base + ")(.*)"))) { |
| 371 | opr->execution_policy().algo = i.desc; |
| 372 | auto used = benchmark.exec(layouts); |
| 373 | min_used = std::min(min_used, used); |
| 374 | printf("run algo: %s used: %f ms min_used: %f ms\n", i.desc.name.c_str(), |
| 375 | used, min_used); |
| 376 | execed = true; |
| 377 | } |
| 378 | } |
| 379 | megdnn_assert(execed, "no algo start with %s\n", algo_base.c_str()); |
| 380 | return min_used; |
| 381 | } |
| 382 | |
| 383 | template <typename Opr, typename Proxy = OprProxy<Opr>, typename T = Timer> |
| 384 | float algo_benchmark( |
nothing calls this directly
no test coverage detected