!5573 Fix wrong graph inputs bug

Merge pull request !5573 from fanglei/graphclone
This commit is contained in:
mindspore-ci-bot 2020-09-01 10:45:21 +08:00 committed by Gitee
commit 340bb4c28f
1 changed files with 8 additions and 1 deletions

View File

@ -336,7 +336,14 @@ void Cloner::AddInputs(const FuncGraphPtr &func_graph_user, const FuncGraphPtr &
}
auto cnode = node->cast<CNodePtr>();
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);
OrderParameters(func_graph, inputs);
}