From ac2d82b576a27143ea735566c754e6517b4b7967 Mon Sep 17 00:00:00 2001 From: leopz Date: Thu, 23 Jul 2020 15:07:03 +0800 Subject: [PATCH] fix cloner when funcgraph return is null --- mindspore/core/ir/func_graph_cloner.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mindspore/core/ir/func_graph_cloner.cc b/mindspore/core/ir/func_graph_cloner.cc index b76d4868ea3..4b116ff5279 100644 --- a/mindspore/core/ir/func_graph_cloner.cc +++ b/mindspore/core/ir/func_graph_cloner.cc @@ -181,11 +181,15 @@ void Cloner::CloneFuncGraphValueNodes(const FuncGraphPtr &func_graph, const Func MS_EXCEPTION_IF_NULL(func_graph); MS_EXCEPTION_IF_NULL(target_func_graph); MS_EXCEPTION_IF_NULL(manager_); - auto return_node = repl_node_[func_graph->get_return()]->cast(); - if (return_node == nullptr) { - MS_LOG(EXCEPTION) << "Can't find replicate node for return."; + + auto old_return = func_graph->get_return(); + if (old_return != nullptr) { + auto return_node = repl_node_[old_return]->cast(); + if (return_node == nullptr) { + MS_LOG(EXCEPTION) << "Can't find replicate node for return."; + } + target_func_graph->set_return(return_node); } - target_func_graph->set_return(return_node); auto &cnodes = func_graph->func_graph_cnodes_index(); for (auto &cnode : cnodes) {