Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update op_version_registry, test=develop #26592

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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