提交 5886c3ac 编写于 作者: K kswang

fix assign cause ir inconsistency

上级 e48eba0d
......@@ -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,
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册