Browse Source

!8147 Delete the remaining useless code

Merge pull request !8147 from Margaret_wangrui/delete_unuse_code
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
55cb801c7f
2 changed files with 0 additions and 63 deletions
  1. +0
    -57
      mindspore/ccsrc/backend/session/ascend_session.cc
  2. +0
    -6
      mindspore/ccsrc/backend/session/ascend_session.h

+ 0
- 57
mindspore/ccsrc/backend/session/ascend_session.cc View File

@@ -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<std::pair<AnfNodePtr, AnfNodePtr>> 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<AnfNodePtr> 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<AnfNodePtr, AnfNodePtr>(front_anf, backend_parameter));
}
// erase the repeat assign
std::set<std::pair<AnfNodePtr, AnfNodePtr>> 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<AnfNodePtr> inputs = {NewValueNode(std::make_shared<Primitive>("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<GraphId> &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()) {


+ 0
- 6
mindspore/ccsrc/backend/session/ascend_session.h View File

@@ -107,16 +107,12 @@ class AscendSession : public SessionBasic {
void RootGraphExecutorValidate(NotNull<KernelGraphPtr> 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<GraphId> &GetGraphOrder(GraphId final_graph_id) const;
// get graph order type vector by graph id
const std::vector<GraphType> &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<KernelGraph> &kernel_graph);
@@ -134,8 +130,6 @@ class AscendSession : public SessionBasic {
std::unordered_map<GraphId, std::vector<GraphId>> graph_execute_orders_;
// key is final_graph_id,value is the graph types of child graphs
std::unordered_map<GraphId, std::vector<GraphType>> graph_order_types_;
// share parameters
std::vector<std::tuple<AnfNodePtr, GraphId, size_t>> assigns_;
// initial tensors, these tensor will sync data to device before run graph
std::map<std::pair<GraphId, size_t>, tensor::TensorPtr> initial_tenosrs_;
// final_graph_id is used in every root graph has it's own session situation


Loading…
Cancel
Save