Browse Source

!296 Exclude free variables to further improve performance

Merge pull request !296 from StrawNoBerry/ExcludeFV
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
c84385d706
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      mindspore/ccsrc/pipeline/static_analysis/evaluator.cc

+ 5
- 1
mindspore/ccsrc/pipeline/static_analysis/evaluator.cc View File

@@ -63,6 +63,9 @@ AnalysisContextPtr BaseFuncGraphEvaluator::MakeContext(const AnalysisEnginePtr &
} }


static std::vector<AnfNodePtr> FastShadowSort(const AnfNodePtr &ret_node) { static std::vector<AnfNodePtr> FastShadowSort(const AnfNodePtr &ret_node) {
auto ori_func_graph = ret_node->func_graph();
MS_EXCEPTION_IF_NULL(ori_func_graph);

std::vector<AnfNodePtr> sorted_nodes; std::vector<AnfNodePtr> sorted_nodes;
std::unordered_set<AnfNodePtr> checked_cnodes; std::unordered_set<AnfNodePtr> checked_cnodes;
std::size_t index = 0; std::size_t index = 0;
@@ -75,7 +78,8 @@ static std::vector<AnfNodePtr> FastShadowSort(const AnfNodePtr &ret_node) {
auto &inputs = current->cast<CNodePtr>()->inputs(); auto &inputs = current->cast<CNodePtr>()->inputs();
for (auto it = inputs.begin(); it != inputs.end(); it++) { for (auto it = inputs.begin(); it != inputs.end(); it++) {
AnfNodePtr input = *it; AnfNodePtr input = *it;
if (input != nullptr && input->isa<CNode>() && checked_cnodes.find(input) == checked_cnodes.end()) {
if (input != nullptr && input->isa<CNode>() && checked_cnodes.find(input) == checked_cnodes.end() &&
input->func_graph() == ori_func_graph) {
sorted_nodes.emplace_back(input); sorted_nodes.emplace_back(input);
(void)checked_cnodes.insert(input); (void)checked_cnodes.insert(input);
} }


Loading…
Cancel
Save