Browse Source

!5573 Fix wrong graph inputs bug

Merge pull request !5573 from fanglei/graphclone
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
340bb4c28f
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      mindspore/core/ir/func_graph_cloner.cc

+ 8
- 1
mindspore/core/ir/func_graph_cloner.cc View File

@@ -336,7 +336,14 @@ void Cloner::AddInputs(const FuncGraphPtr &func_graph_user, const FuncGraphPtr &
} }
auto cnode = node->cast<CNodePtr>(); auto cnode = node->cast<CNodePtr>();
auto inputs = cnode->inputs(); auto inputs = cnode->inputs();
(void)std::copy(params.begin(), params.end(), std::back_inserter(inputs));
std::vector<AnfNodePtr> add_params{params.begin(), params.end()};
for (size_t i = 2; i < inputs.size(); i++) {
auto ret = std::find(add_params.begin(), add_params.end(), inputs[i]);
if (ret != add_params.end()) {
add_params.erase(ret);
}
}
(void)std::copy(add_params.begin(), add_params.end(), std::back_inserter(inputs));
cnode->set_inputs(inputs); cnode->set_inputs(inputs);
OrderParameters(func_graph, inputs); OrderParameters(func_graph, inputs);
} }


Loading…
Cancel
Save