From 1c898b66d6c668048ab77ee33b2457687b8b36be Mon Sep 17 00:00:00 2001 From: Wilber Date: Thu, 27 Aug 2020 22:56:33 +0800 Subject: [PATCH] add bug fix enum. (#26736) --- paddle/fluid/framework/op_version_registry.h | 14 +++++++++++++- paddle/fluid/framework/op_version_registry_test.cc | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/op_version_registry.h b/paddle/fluid/framework/op_version_registry.h index 2a85c60305b..79b15fc87d0 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 052bf3a4b88..80ad51ad07b 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]. -- GitLab