diff --git a/paddle/fluid/framework/op_version_registry.h b/paddle/fluid/framework/op_version_registry.h index 2a85c60305bd36e78c071f5703885c23e33b403e..79b15fc87d0b0a0ade8324710b80af634ff8878f 100644 --- a/paddle/fluid/framework/op_version_registry.h +++ b/paddle/fluid/framework/op_version_registry.h @@ -34,7 +34,8 @@ struct OpUpdateRecord { kModifyAttr, kNewAttr, kNewInput, - kNewOutput + kNewOutput, + kBugfixWithBehaviorChanged, }; Type type_; std::string remark_; @@ -82,6 +83,11 @@ struct NewOutput : OpUpdateRecord { std::string name_; }; +struct BugfixWithBehaviorChanged : OpUpdateRecord { + explicit BugfixWithBehaviorChanged(const std::string& remark) + : OpUpdateRecord({Type::kBugfixWithBehaviorChanged, remark}) {} +}; + class OpVersionDesc { public: OpVersionDesc& ModifyAttr(const std::string& name, const std::string& remark, @@ -110,6 +116,12 @@ class OpVersionDesc { return *this; } + OpVersionDesc& BugfixWithBehaviorChanged(const std::string& remark) { + infos_.push_back(std::shared_ptr( + new compatible::BugfixWithBehaviorChanged(remark))); + return *this; + } + private: std::vector> infos_; }; diff --git a/paddle/fluid/framework/op_version_registry_test.cc b/paddle/fluid/framework/op_version_registry_test.cc index 052bf3a4b882be749e70704f18f09a7b24551ed7..80ad51ad07b5a84cfabb3ace9b478b1f6ea24f95 100644 --- a/paddle/fluid/framework/op_version_registry_test.cc +++ b/paddle/fluid/framework/op_version_registry_test.cc @@ -23,6 +23,10 @@ namespace compatible { TEST(test_operator_version, test_operator_version) { REGISTER_OP_VERSION(test__) + .AddCheckpoint( + R"ROC(Fix the bug of reshape op, support the case of axis < 0)ROC", + framework::compatible::OpVersionDesc().BugfixWithBehaviorChanged( + "Support the case of axis < 0")) .AddCheckpoint( R"ROC( Upgrade reshape, modified one attribute [axis] and add a new attribute [size].