diff --git a/paddle/fluid/framework/op_version_registry.h b/paddle/fluid/framework/op_version_registry.h index 214b569fb5..0ffa38a037 100644 --- a/paddle/fluid/framework/op_version_registry.h +++ b/paddle/fluid/framework/op_version_registry.h @@ -48,11 +48,15 @@ struct ModifyAttr : OpUpdateRecord { boost::any default_value_; }; struct NewAttr : OpUpdateRecord { - NewAttr(const std::string& name, const std::string& remark) - : OpUpdateRecord({Type::kNewAttr, remark}), name_(name) {} + NewAttr(const std::string& name, const std::string& remark, + boost::any default_value) + : OpUpdateRecord({Type::kNewAttr, remark}), + name_(name), + default_value_(default_value) {} private: std::string name_; + boost::any default_value_; }; class OpVersionDesc { @@ -64,9 +68,10 @@ class OpVersionDesc { return *this; } - OpVersionDesc& NewAttr(const std::string& name, const std::string& remark) { - infos_.push_back( - std::shared_ptr(new compatible::NewAttr(name, remark))); + OpVersionDesc& NewAttr(const std::string& name, const std::string& remark, + boost::any default_value) { + infos_.push_back(std::shared_ptr( + new compatible::NewAttr(name, remark, default_value))); return *this; } diff --git a/paddle/fluid/framework/op_version_registry_test.cc b/paddle/fluid/framework/op_version_registry_test.cc index cb7aba4ab7..77891dafc8 100644 --- a/paddle/fluid/framework/op_version_registry_test.cc +++ b/paddle/fluid/framework/op_version_registry_test.cc @@ -32,7 +32,8 @@ TEST(test_operator_version, test_operator_version) { "Increased from the original one method to two.", -1) .NewAttr("size", "In order to represent a two-dimensional rectangle, the " - "parameter size is added.")) + "parameter size is added.", + 0)) .AddCheckpoint( R"ROC( Add a new attribute [height] @@ -40,7 +41,8 @@ TEST(test_operator_version, test_operator_version) { framework::compatible::OpVersionDesc().NewAttr( "height", "In order to represent a two-dimensional rectangle, the " - "parameter height is added.")); + "parameter height is added.", + 0)); } } // namespace compatible } // namespace framework