From 00fa02a9b82b78167161a48c41771c7ec47d845d Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 12 Apr 2021 17:30:53 +0800 Subject: [PATCH] fix(mgb): fix attribute uncomplete filter when get_profile_result_from_cache in fast run GitOrigin-RevId: 599437ad72def044ab39914e55a75a8be1ee6f93 --- src/opr/impl/search_policy/algo_chooser.cpp | 25 ++++++++++++++++--------- src/opr/test/dnn/convolution.cpp | 3 +-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/opr/impl/search_policy/algo_chooser.cpp b/src/opr/impl/search_policy/algo_chooser.cpp index b8c3d7be..6116e831 100644 --- a/src/opr/impl/search_policy/algo_chooser.cpp +++ b/src/opr/impl/search_policy/algo_chooser.cpp @@ -557,10 +557,18 @@ AlgoChooser::ExeContext::get_profile_result_from_cache( if (prof.empty()) return {}; + + auto attr_from_strategy = + extract_algo_attribute_from_execution_strategy(selected_strategy); for (auto&& i : prof) { - if (!(selected_strategy & ExecutionStrategy::REPRODUCIBLE) || - static_cast(i.attribute) & - AlgoAttribute::REPRODUCIBLE) { + auto attr_of_algo = + static_cast(i.attribute); + bool contain_attr_all_positive = + (attr_from_strategy.first == + (attr_of_algo & attr_from_strategy.first)); + bool contain_attr_any_negative = + static_cast(attr_of_algo & attr_from_strategy.second); + if (contain_attr_all_positive && !contain_attr_any_negative) { auto iter = algo_map.find(i.algo); mgb_assert(iter != algo_map.end(), "algorithm %s exists in " @@ -576,12 +584,11 @@ AlgoChooser::ExeContext::get_profile_result_from_cache( } mgb_log_error( - "Workspace requirement (%zu) could not be satisfied. Abort now " - "to " - "avoid further problems", - WorkspaceLimitGetter::get_workspace_limit( - m_base_mgb_opr->owner_graph(), m_cn, - m_execution_policy.workspace_limit)); + "algos read from cache could not satisfy attribute with %s and " + "without %s", + Algorithm::attribute_str(attr_from_strategy.first).c_str(), + Algorithm::attribute_str(attr_from_strategy.second).c_str()); + mgb_trap(); MIDOUT_E } diff --git a/src/opr/test/dnn/convolution.cpp b/src/opr/test/dnn/convolution.cpp index 32f89d7d..134ef3cb 100644 --- a/src/opr/test/dnn/convolution.cpp +++ b/src/opr/test/dnn/convolution.cpp @@ -364,7 +364,6 @@ TEST(TestOprDNN, ConvBiasExePolicy) { for (auto strategy : SmallVector{S : HEURISTIC, S::PROFILE | S::HEURISTIC}) { #endif - auto graph = ComputingGraph::make(); HostTensorGenerator<> gen; @@ -454,7 +453,7 @@ TEST(TestOprDNN, ConvolutionExePolicy) { #if MGB_ENABLE_FASTRUN for (auto strategy : SmallVector{S::PROFILE, S::HEURISTIC, S::PROFILE | S::REPRODUCIBLE, - S::PROFILE | S::HEURISTIC, S::PROFILE | S::OPTIMIZED}) { + S::PROFILE | S::HEURISTIC}) { #else for (auto strategy : SmallVector{S : HEURISTIC, S::PROFILE | S::HEURISTIC}) {