提交 55d7f55c 编写于 作者: M minqiyang

Revert the changes to attribute.h

上级 1800fef1
...@@ -82,10 +82,7 @@ class DefaultValueSetter { ...@@ -82,10 +82,7 @@ class DefaultValueSetter {
public: public:
explicit DefaultValueSetter(T default_value) explicit DefaultValueSetter(T default_value)
: default_value_(default_value) {} : default_value_(default_value) {}
void operator()(T* value) const { void operator()(T& value) const { value = default_value_; }
PADDLE_ENFORCE(value != nullptr, "Can not set default value to nullptr");
*value = default_value_;
}
private: private:
T default_value_; T default_value_;
...@@ -202,7 +199,6 @@ struct ExtractAttribute<int64_t> { ...@@ -202,7 +199,6 @@ struct ExtractAttribute<int64_t> {
template <typename T> template <typename T>
class TypedAttrChecker { class TypedAttrChecker {
typedef std::function<void(T&)> ValueChecker; typedef std::function<void(T&)> ValueChecker;
typedef std::function<void(T*)> ValueSetter;
public: public:
explicit TypedAttrChecker(const std::string& attr_name) explicit TypedAttrChecker(const std::string& attr_name)
...@@ -245,7 +241,7 @@ class TypedAttrChecker { ...@@ -245,7 +241,7 @@ class TypedAttrChecker {
"Attribute '%s' is required!", attr_name_); "Attribute '%s' is required!", attr_name_);
// default_value_setter_ has no more than one element // default_value_setter_ has no more than one element
T val; T val;
(default_value_setter_[0])(&val); (default_value_setter_[0])(val);
attr_map[attr_name_] = val; attr_map[attr_name_] = val;
} }
Attribute& attr = attr_map.at(attr_name_); Attribute& attr = attr_map.at(attr_name_);
...@@ -259,7 +255,7 @@ class TypedAttrChecker { ...@@ -259,7 +255,7 @@ class TypedAttrChecker {
private: private:
std::string attr_name_; std::string attr_name_;
std::vector<ValueChecker> value_checkers_; std::vector<ValueChecker> value_checkers_;
std::vector<ValueSetter> default_value_setter_; std::vector<ValueChecker> default_value_setter_;
}; };
// check whether op's all attributes fit their own limits // check whether op's all attributes fit their own limits
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册