diff --git a/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.cc b/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.cc index 8e1edcc5142..e70dc73516b 100644 --- a/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.cc +++ b/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.cc @@ -275,6 +275,21 @@ int MindIRControlFlowAdjust::InsertPartialFusionForRawCall(const std::set all_func_graphs) { + MS_CHECK_TRUE_MSG(fg != nullptr, RET_NULL_PTR, "fg is nullptr."); + auto manager = fg->manager(); + MS_CHECK_TRUE_MSG(manager != nullptr, RET_NULL_PTR, "manager is nullptr."); + manager->Clear(); + manager->AddFuncGraph(fg, true); + for (auto &item : all_func_graphs) { + if (item == fg) { + continue; + } + manager->AddFuncGraph(item); + } + return RET_OK; +} + bool MindIRControlFlowAdjust::Run(const FuncGraphPtr &func_graph) { if (this->fmk_type_ != FmkType::kFmkTypeMs) { MS_LOG(INFO) << "The framework type of model should be MindIR."; @@ -297,6 +312,12 @@ bool MindIRControlFlowAdjust::Run(const FuncGraphPtr &func_graph) { MS_LOG(ERROR) << "AddAfterFgForInlinedFg failed."; return false; } + ret = ResetFuncGraph(func_graph, all_func_graphs); + if (ret != RET_OK) { + MS_LOG(ERROR) << "ResetFuncGraph failed."; + return false; + } + if (status_ != RET_OK) { return false; } diff --git a/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.h b/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.h index 5d31549fcd7..d36120394d0 100644 --- a/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.h +++ b/mindspore/lite/tools/converter/import/mindir_control_flow_adjust.h @@ -43,6 +43,7 @@ class MindIRControlFlowAdjust { int AddAfterFgForInlinedFg(const std::set &all_func_graphs, const FuncGraphPtr &main_fg); int InsertPartialFusionForRawCall(const std::set &all_func_graphs); CNodePtr GetMainFgSwitchNode(const FuncGraphPtr &fg); + int ResetFuncGraph(const FuncGraphPtr &fg, std::set all_func_graphs); private: FmkType fmk_type_ = FmkType::kFmkTypeMs;