From 55d7f55c63a33aa2fc8f8a4d1c5c2024ec8a137d Mon Sep 17 00:00:00 2001 From: minqiyang Date: Tue, 14 Aug 2018 16:34:04 +0800 Subject: [PATCH] Revert the changes to attribute.h --- paddle/fluid/framework/attribute.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/framework/attribute.h b/paddle/fluid/framework/attribute.h index ea91ac2bb..8428bf8e3 100644 --- a/paddle/fluid/framework/attribute.h +++ b/paddle/fluid/framework/attribute.h @@ -82,10 +82,7 @@ class DefaultValueSetter { public: explicit DefaultValueSetter(T default_value) : default_value_(default_value) {} - void operator()(T* value) const { - PADDLE_ENFORCE(value != nullptr, "Can not set default value to nullptr"); - *value = default_value_; - } + void operator()(T& value) const { value = default_value_; } private: T default_value_; @@ -202,7 +199,6 @@ struct ExtractAttribute { template class TypedAttrChecker { typedef std::function ValueChecker; - typedef std::function ValueSetter; public: explicit TypedAttrChecker(const std::string& attr_name) @@ -245,7 +241,7 @@ class TypedAttrChecker { "Attribute '%s' is required!", attr_name_); // default_value_setter_ has no more than one element T val; - (default_value_setter_[0])(&val); + (default_value_setter_[0])(val); attr_map[attr_name_] = val; } Attribute& attr = attr_map.at(attr_name_); @@ -259,7 +255,7 @@ class TypedAttrChecker { private: std::string attr_name_; std::vector value_checkers_; - std::vector default_value_setter_; + std::vector default_value_setter_; }; // check whether op's all attributes fit their own limits -- GitLab