!3172 Fix bugs of the MaybeDropNodes function

Merge pull request !3172 from Kang/opt
This commit is contained in:
mindspore-ci-bot 2020-07-20 11:28:22 +08:00 committed by Gitee
commit ef7cfaaf2e
1 changed files with 9 additions and 4 deletions

View File

@ -387,12 +387,17 @@ FuncGraphSetPtr FuncGraphManager::MaybeDropNodes(const std::vector<AnfNodePtr> &
continue;
}
AnfNodeIndexSet &users = node_users_[node];
std::vector<AnfNodePtr> parameters;
if (!users.empty() ||
(node->isa<Parameter>() && parameters.end() != std::find(parameters.begin(), parameters.end(), node))) {
if (!users.empty()) {
continue;
}
if (node->isa<Parameter>() && node->func_graph() != nullptr) {
auto &parameters = node->func_graph()->parameters();
if (std::find(parameters.begin(), parameters.end(), node) != parameters.end()) {
continue;
}
}
if (IsValueNode<FuncGraph>(node)) {
auto fg = GetValueNode<FuncGraphPtr>(node);
func_graphs_to_check->add(fg);