Skip to content

Commit

Permalink
update op_version_registry, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Shixiaowei02 committed Aug 24, 2020
1 parent 8645591 commit 03183d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions paddle/fluid/framework/op_version_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -64,9 +68,10 @@ class OpVersionDesc {
return *this;
}

OpVersionDesc& NewAttr(const std::string& name, const std::string& remark) {
infos_.push_back(
std::shared_ptr<OpUpdateRecord>(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<OpUpdateRecord>(
new compatible::NewAttr(name, remark, default_value)));
return *this;
}

Expand Down
6 changes: 4 additions & 2 deletions paddle/fluid/framework/op_version_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ 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]
)ROC",
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
Expand Down

1 comment on commit 03183d6

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.