diff --git a/mindspore/ccsrc/pipeline/static_analysis/evaluator.cc b/mindspore/ccsrc/pipeline/static_analysis/evaluator.cc index 99cb893104..5bad1634d5 100644 --- a/mindspore/ccsrc/pipeline/static_analysis/evaluator.cc +++ b/mindspore/ccsrc/pipeline/static_analysis/evaluator.cc @@ -63,6 +63,9 @@ AnalysisContextPtr BaseFuncGraphEvaluator::MakeContext(const AnalysisEnginePtr & } static std::vector FastShadowSort(const AnfNodePtr &ret_node) { + auto ori_func_graph = ret_node->func_graph(); + MS_EXCEPTION_IF_NULL(ori_func_graph); + std::vector sorted_nodes; std::unordered_set checked_cnodes; std::size_t index = 0; @@ -75,7 +78,8 @@ static std::vector FastShadowSort(const AnfNodePtr &ret_node) { auto &inputs = current->cast()->inputs(); for (auto it = inputs.begin(); it != inputs.end(); it++) { AnfNodePtr input = *it; - if (input != nullptr && input->isa() && checked_cnodes.find(input) == checked_cnodes.end()) { + if (input != nullptr && input->isa() && checked_cnodes.find(input) == checked_cnodes.end() && + input->func_graph() == ori_func_graph) { sorted_nodes.emplace_back(input); (void)checked_cnodes.insert(input); }