未验证 提交 efef3035 编写于 作者: H HongyuJia 提交者: GitHub

fix default_attr=nullptr bug (#50383)

上级 d1bfb4b7
......@@ -102,12 +102,9 @@ class DygraphExecutionContext : public framework::ExecutionContext {
}
bool HasAttr(const std::string& name) const override {
if (attrs_.find(name) == attrs_.end()) {
return &default_attrs_ != nullptr &&
return attrs_.find(name) != attrs_.end() ||
default_attrs_.find(name) != default_attrs_.end();
}
return true;
}
const framework::AttributeMap& Attrs() const override { return attrs_; }
......
......@@ -30,6 +30,8 @@
namespace paddle {
namespace imperative {
const static framework::AttributeMap empty_default_attr_map; // NOLINT
// TODO(zjl): to support py_func layer
class OpBase {
public:
......@@ -123,7 +125,12 @@ class OpBase {
const framework::AttributeMap& Attrs() { return attrs_; }
const framework::AttributeMap& DefaultAttrsMap() { return *default_attrs_; }
const framework::AttributeMap& DefaultAttrsMap() {
if (default_attrs_ == nullptr) {
return empty_default_attr_map;
}
return *default_attrs_;
}
bool HasAttr(const std::string& name) const {
VLOG(6) << "Default attrs: " << default_attrs_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册