Browse Source

Pre Merge pull request !1829 from wangzhengjun/replace_with_empty_tensor

pull/1829/MERGE
wangzhengjun Gitee 4 years ago
parent
commit
194d02da8e
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      ge/graph/passes/replace_with_empty_const_pass.cc

+ 20
- 0
ge/graph/passes/replace_with_empty_const_pass.cc View File

@@ -21,7 +21,23 @@
#include "framework/common/debug/ge_log.h" #include "framework/common/debug/ge_log.h"
#include "framework/common/ge_inner_error_codes.h" #include "framework/common/ge_inner_error_codes.h"
#include "graph/utils/graph_utils.h" #include "graph/utils/graph_utils.h"
#include "graph/utils/node_utils.h"


namespace {
const std::unordered_set<std::string> kControlFlowOps = {
ge::SWITCH,
ge::REFSWITCH,
ge::MERGE,
ge::REFMERGE,
ge::ENTER,
ge::REFENTER,
ge::NEXTITERATION,
ge::REFNEXTITERATION,
ge::EXIT,
ge::REFEXIT,
ge::LOOPCOND
};
}
namespace ge { namespace ge {
Status ReplaceWithEmptyConstPass::Run(NodePtr &node) { Status ReplaceWithEmptyConstPass::Run(NodePtr &node) {
GELOGD("ReplaceWithEmptyConstPass in."); GELOGD("ReplaceWithEmptyConstPass in.");
@@ -39,6 +55,10 @@ Status ReplaceWithEmptyConstPass::Run(NodePtr &node) {
GELOGI("Node %s is const. Ignore current pass.", node->GetName().c_str()); GELOGI("Node %s is const. Ignore current pass.", node->GetName().c_str());
return SUCCESS; return SUCCESS;
} }
if (kControlFlowOps.count(NodeUtils::GetNodeType(node)) != 0) {
GELOGI("Node %s is control flow op. Ignore current pass.", node->GetName().c_str());
return SUCCESS;
}
// Node like no op, it has no output // Node like no op, it has no output
if (node->GetOpDesc()->GetAllOutputsDescPtr().empty()) { if (node->GetOpDesc()->GetAllOutputsDescPtr().empty()) {
GELOGI("Node %s has no output desc. Ignore current pass.", node->GetName().c_str()); GELOGI("Node %s has no output desc. Ignore current pass.", node->GetName().c_str());


Loading…
Cancel
Save