提交 1b5768c3 编写于 作者: L liuwei1031 提交者: ceci3

fix a code bug which cause crash when empty variable is used, test=develop (#16080)

上级 c109e6b3
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include <numeric> #include <numeric>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <unordered_map>
#include <unordered_set>
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/framework/var_desc.h"
#include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/cpu_info.h"
...@@ -302,7 +305,10 @@ std::string OrderedSet::ToString() const { ...@@ -302,7 +305,10 @@ std::string OrderedSet::ToString() const {
bool NodeCanReused(ir::Node* node) { bool NodeCanReused(ir::Node* node) {
// valid the node is a var node // valid the node is a var node
if (node == nullptr || !node->IsVar() || node->IsCtrlVar()) return false; // vars can be @EMPTY@, @LR_DECAY_REUSE_ID@. For example, while_grad
if (node == nullptr || !node->IsVar() || node->IsCtrlVar() ||
node->Name() == kEmptyVarName)
return false;
bool flag = true; bool flag = true;
// op output force generated in cpu, can not be reused. // op output force generated in cpu, can not be reused.
...@@ -348,10 +354,6 @@ bool NodeCanReused(const VarDesc& node) { ...@@ -348,10 +354,6 @@ bool NodeCanReused(const VarDesc& node) {
if (shape.empty() || size < MinChunkSize()) { if (shape.empty() || size < MinChunkSize()) {
return false; return false;
} }
// vars can be @EMPTY@, @LR_DECAY_REUSE_ID@. For example, while_grad
std::string name = node.Name();
if (!name.empty() && name[0] == '@' && name[name.size() - 1] == '@')
return false;
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册