| 448 | virtual void init(Opr*, const TensorNDArray&) {} |
| 449 | |
| 450 | virtual void exec(Opr* opr, const TensorNDArray& tensors) { |
| 451 | megdnn_assert(tensors.size() == arity); |
| 452 | if (!W.valid()) { |
| 453 | W = WorkspaceWrapper(opr->handle(), 0); |
| 454 | } |
| 455 | TensorLayoutArray layouts; |
| 456 | for (auto&& tensor : tensors) { |
| 457 | layouts.push_back(tensor.layout); |
| 458 | } |
| 459 | if (m_profiling && !target_execution_policy.algo.valid()) { |
| 460 | FastRunCache cache; |
| 461 | std::string param_str; |
| 462 | Algorithm::serialize_write_pod(opr->param(), param_str); |
| 463 | auto&& search_items = |
| 464 | flatten_search_space(layouts, param_str, opr->handle()); |
| 465 | FOREACH_OPR_TYPE_DISPATCH(search_items, { |
| 466 | OprProxyProfilingBase<_Opr>::search( |
| 467 | _item.layouts, _item.param, W, opr->handle(), warmup_times, |
| 468 | exec_times, cache); |
| 469 | }); |
| 470 | |
| 471 | construct_execution_policy( |
| 472 | layouts, param_str, opr->handle(), cache, opr->execution_policy()); |
| 473 | target_execution_policy = opr->execution_policy(); |
| 474 | auto workspace_size = |
| 475 | AlgoProxy<Opr, arity>::get_workspace_in_bytes(opr, layouts); |
| 476 | W.update(workspace_size); |
| 477 | } |
| 478 | if (!target_execution_policy.algo.valid()) { |
| 479 | auto workspace_size = |
| 480 | AlgoProxy<Opr, arity>::get_workspace_in_bytes(opr, layouts); |
| 481 | W.update(workspace_size); |
| 482 | } |
| 483 | AlgoProxy<Opr, arity>::exec(opr, tensors, W.workspace()); |
| 484 | } |
| 485 | |
| 486 | virtual ~OprProxyProfilingBase() {} |
| 487 | }; |
no test coverage detected