From 320f2f605eb743072aa6107b4c4ca036b251316a Mon Sep 17 00:00:00 2001 From: mengyuanli Date: Fri, 25 Feb 2022 16:34:29 +0800 Subject: [PATCH] fix bug of control flow stuck --- .../lite/src/control_flow/actor/exit_actor.cc | 15 +++++++++++++-- .../lite/src/control_flow/actor/exit_actor.h | 1 + mindspore/lite/test/config/models_mindspore.cfg | 3 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mindspore/lite/src/control_flow/actor/exit_actor.cc b/mindspore/lite/src/control_flow/actor/exit_actor.cc index 4e4b66184ca..814f99669ad 100644 --- a/mindspore/lite/src/control_flow/actor/exit_actor.cc +++ b/mindspore/lite/src/control_flow/actor/exit_actor.cc @@ -143,14 +143,25 @@ int LiteExitOpActor::PreInit(std::vector> *actors, return RET_OK; } +bool LiteExitOpActor::IsSubSet(const std::vector &all_set, const std::vector &sub_set) { + if (sub_set.size() > all_set.size()) { + return false; + } + for (auto &sub_item : sub_set) { + if (std::find(all_set.begin(), all_set.end(), sub_item) == all_set.end()) { + return false; + } + } + return true; +} + int LiteExitOpActor::RecordCallNodeOutputActor(std::vector> *actors) { actors_ = actors; for (auto actor : *actors_) { auto actor_in_tensors = actor->GetKernel()->in_tensors(); for (auto &info : all_mapping_info_) { auto &call = info.call_node; - if (std::includes(actor_in_tensors.begin(), actor_in_tensors.end(), call->out_tensors().begin(), - call->out_tensors().end())) { + if (IsSubSet(actor_in_tensors, call->out_tensors())) { info.call_output_aid = actor->GetAID(); } } diff --git a/mindspore/lite/src/control_flow/actor/exit_actor.h b/mindspore/lite/src/control_flow/actor/exit_actor.h index d209a5d112a..00f204bb015 100644 --- a/mindspore/lite/src/control_flow/actor/exit_actor.h +++ b/mindspore/lite/src/control_flow/actor/exit_actor.h @@ -50,6 +50,7 @@ class LiteExitOpActor : public LiteOpActor { int RecordCallNodeOutputActor(std::vector> *actors); void RecordPartialNodeInputActor(); void SetEntranceInputAID(OpData *inputs); + bool IsSubSet(const std::vector &all_set, const std::vector &sub_set); std::vector> *actors_{}; std::vector all_mapping_info_{}; diff --git a/mindspore/lite/test/config/models_mindspore.cfg b/mindspore/lite/test/config/models_mindspore.cfg index e3834223722..7c69331fc84 100644 --- a/mindspore/lite/test/config/models_mindspore.cfg +++ b/mindspore/lite/test/config/models_mindspore.cfg @@ -18,8 +18,7 @@ ControlOneIfOneScaleOneScale.mindir;3 add_if_while.mindir;3 add_if_after_while_after_for.mindir;3 add_if_after_if.mindir;3 -#stuck in sumsang phone -#add_for_while.mindir;3 +add_for_while.mindir;3 add_for_if.mindir;3 switchlayer.mindir;3 HDC_multimedia_3M_vit32_60ep_clip_vit_base_image.mindir 3