diff --git a/mindspore/ccsrc/backend/session/ascend_session.cc b/mindspore/ccsrc/backend/session/ascend_session.cc index 4ca5943ead..b43777c4a6 100644 --- a/mindspore/ccsrc/backend/session/ascend_session.cc +++ b/mindspore/ccsrc/backend/session/ascend_session.cc @@ -231,8 +231,6 @@ void AscendSession::BuildGraphImpl(GraphId graph_id) { if (!graph->executable()) { return; } - // insert assigns to child graph - InsertAllAssigns(); SetFinalGraphSummaryFlag(graph); // OptChildGraphs auto graph_order = GetGraphOrder(final_graph_id_); @@ -658,37 +656,6 @@ void AscendSession::SetSummaryNodes(KernelGraph *graph) { MS_LOG(DEBUG) << "Update summary end size: " << summary.size(); } -void AscendSession::InsertAllAssigns() { - std::vector> assigns; - for (auto assign : assigns_) { - auto front_anf = std::get<0>(assign); - auto to_graph_id = std::get<1>(assign); - auto input_idx = std::get<2>(assign); - auto to_graph = GetGraph(to_graph_id); - MS_EXCEPTION_IF_NULL(to_graph); - std::vector graph_inputs = to_graph->inputs(); - if (input_idx >= graph_inputs.size()) { - MS_LOG(EXCEPTION) << "Input_index " << input_idx << " out of range size " << graph_inputs.size(); - } - auto backend_parameter = graph_inputs[input_idx]; - assigns.emplace_back(std::pair(front_anf, backend_parameter)); - } - // erase the repeat assign - std::set> inserted_nodes; - for (auto &assign : assigns) { - auto front_anf = assign.first; - auto backend_parameter = assign.second; - auto from_graph_id = GetGraphIdByNode(front_anf); - auto from_graph = GetGraph(from_graph_id); - MS_EXCEPTION_IF_NULL(from_graph); - auto backend_arg = from_graph->GetBackendAnfByFrontAnf(front_anf); - if (inserted_nodes.find(assign) == inserted_nodes.end()) { - InsertAssignToGraph(from_graph_id, backend_arg, backend_parameter); - (void)inserted_nodes.insert(assign); - } - } -} - GraphId AscendSession::GetGraphIdByNode(const AnfNodePtr &front_anf) const { for (const auto &graph_item : graphs_) { auto graph = graph_item.second; @@ -759,30 +726,6 @@ void AscendSession::MergeGraphExecOrder() { final_graph->set_execution_order(final_exec_order); } -void AscendSession::InsertAssignToGraph(GraphId graph_id, const AnfNodePtr &from, const AnfNodePtr &to) { - MS_EXCEPTION_IF_NULL(from); - MS_EXCEPTION_IF_NULL(to); - if (AnfAlgo::OutputAddrExist(from, 0) && AnfAlgo::OutputAddrExist(to, 0) && - AnfAlgo::GetOutputAddr(from, 0) == AnfAlgo::GetOutputAddr(to, 0)) { - return; - } - if (from.get() == to.get()) { - return; - } - MS_LOG(INFO) << "Insert assign to graph " << graph_id << " from " << from->DebugString() << " to " - << to->DebugString(); - auto graph = graphs_[graph_id]; - MS_EXCEPTION_IF_NULL(graph); - // config inputs of assign node - std::vector inputs = {NewValueNode(std::make_shared("Assign")), to, from}; - // generate a new cnode - auto assign_node = graph->NewCNode(inputs); - MS_EXCEPTION_IF_NULL(assign_node); - assign_node->set_abstract(to->abstract()); - // append the assign at the end of from graph - AscendControlParser::InsertDependToGraph(NOT_NULL(graph), NOT_NULL(assign_node)); -} - const std::vector &AscendSession::GetGraphOrder(GraphId final_graph_id) const { auto graph_order_iter = graph_execute_orders_.find(final_graph_id); if (graph_order_iter == graph_execute_orders_.end()) { diff --git a/mindspore/ccsrc/backend/session/ascend_session.h b/mindspore/ccsrc/backend/session/ascend_session.h index 0f777494f4..ede6b97096 100644 --- a/mindspore/ccsrc/backend/session/ascend_session.h +++ b/mindspore/ccsrc/backend/session/ascend_session.h @@ -107,16 +107,12 @@ class AscendSession : public SessionBasic { void RootGraphExecutorValidate(NotNull graph); // merge execution order list of child graphs void MergeGraphExecOrder(); - // insert assion op to sync data bettween different graphs - void InsertAssignToGraph(GraphId graph_id, const AnfNodePtr &from, const AnfNodePtr &to); // get graph order vector by graph id const std::vector &GetGraphOrder(GraphId final_graph_id) const; // get graph order type vector by graph id const std::vector &GetGraphOrderType(GraphId final_graph_id) const; // check if graph cache exist bool GraphCacheExist(const GraphInfo &graph_info) const; - // insert all assign to child graph - void InsertAllAssigns(); // sync intial tensors' data to device void SyncInitialTenosrToDevice(); void SetFinalGraphSummaryFlag(const std::shared_ptr &kernel_graph); @@ -134,8 +130,6 @@ class AscendSession : public SessionBasic { std::unordered_map> graph_execute_orders_; // key is final_graph_id,value is the graph types of child graphs std::unordered_map> graph_order_types_; - // share parameters - std::vector> assigns_; // initial tensors, these tensor will sync data to device before run graph std::map, tensor::TensorPtr> initial_tenosrs_; // final_graph_id is used in every root graph has it's own session situation