Browse Source

fix assign cause ir inconsistency

tags/v0.3.0-alpha
kswang 5 years ago
parent
commit
5886c3ac22
2 changed files with 9 additions and 5 deletions
  1. +8
    -4
      mindspore/ccsrc/session/ascend_session.cc
  2. +1
    -1
      mindspore/ccsrc/session/ascend_session.h

+ 8
- 4
mindspore/ccsrc/session/ascend_session.cc View File

@@ -770,7 +770,7 @@ void AscendSession::MergeSwitchCompile() {
}

void AscendSession::InsertAllAssigns() {
std::set<std::pair<AnfNodePtr, AnfNodePtr>> assigns;
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);
@@ -782,9 +782,10 @@ void AscendSession::InsertAllAssigns() {
MS_LOG(EXCEPTION) << "input_index " << input_idx << " out of range size " << graph_inputs.size();
}
auto backend_parameter = graph_inputs[input_idx];
(void)assigns.insert(std::pair<AnfNodePtr, AnfNodePtr>(front_anf, backend_parameter));
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;
@@ -792,7 +793,10 @@ void AscendSession::InsertAllAssigns() {
auto from_graph = GetGraph(from_graph_id);
MS_EXCEPTION_IF_NULL(from_graph);
auto backend_arg = from_graph->GetBackendAnfByFrontAnf(front_anf);
InsertAssignToGraph(from_graph_id, backend_arg, backend_parameter);
if (inserted_nodes.find(assign) == inserted_nodes.end()) {
InsertAssignToGraph(from_graph_id, backend_arg, backend_parameter);
(void)inserted_nodes.insert(assign);
}
}
}

@@ -857,7 +861,7 @@ void AscendSession::SetChildGraphParameter(const AnfNodePtr &front_anf, GraphId
}
MS_LOG(INFO) << "Assign of node" << backend_arg->DebugString() << " of graph " << from_graph_id << " to node"
<< backend_parameter->DebugString() << "of graph " << to_graph_id;
(void)assigns_.insert(std::tuple<AnfNodePtr, GraphId, size_t>(front_anf, to_graph_id, input_idx));
assigns_.emplace_back(std::tuple<AnfNodePtr, GraphId, size_t>(front_anf, to_graph_id, input_idx));
}

void AscendSession::SetChildGraphParameter(const tensor::TensorPtr &front_tensor, GraphId to_graph_id,


+ 1
- 1
mindspore/ccsrc/session/ascend_session.h View File

@@ -140,7 +140,7 @@ class AscendSession : public SessionBasic {
std::unordered_map<GraphId, std::pair<GraphId, GraphId>> switches_;
std::unordered_map<GraphId, AnfNodePtr> condition_output_;
// share parameters
std::set<std::tuple<AnfNodePtr, GraphId, size_t>> assigns_;
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