From c97825902788e791441e668a92fad739b566acd4 Mon Sep 17 00:00:00 2001 From: yuyang18 Date: Tue, 22 May 2018 15:40:04 +0800 Subject: [PATCH] Add default value of op_role --- paddle/fluid/framework/op_proto_maker.cc | 4 +++- paddle/fluid/framework/op_proto_maker.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/op_proto_maker.cc b/paddle/fluid/framework/op_proto_maker.cc index 6070ade7e..5a4380a83 100644 --- a/paddle/fluid/framework/op_proto_maker.cc +++ b/paddle/fluid/framework/op_proto_maker.cc @@ -69,7 +69,9 @@ void OpProtoAndCheckerMaker::operator()(proto::OpProto* proto, static_cast(OpRole::kOptimize), static_cast(OpRole::kLoss) | static_cast(OpRole::kForward), static_cast(OpRole::kLoss) | - static_cast(OpRole::kBackward)}); + static_cast(OpRole::kBackward), + static_cast(OpRole::kNotSpecified)}) + .SetDefault(static_cast(OpRole::kNotSpecified)); AddAttr>(OpRoleVarAttrName(), "Optimized for variable") .SetDefault({}); diff --git a/paddle/fluid/framework/op_proto_maker.h b/paddle/fluid/framework/op_proto_maker.h index dad628b12..9bd6ca6ea 100644 --- a/paddle/fluid/framework/op_proto_maker.h +++ b/paddle/fluid/framework/op_proto_maker.h @@ -26,6 +26,9 @@ enum class OpRole { kOptimize = 0x0002, kLoss = 0x0100, + // The default value of op's role. This should be only used for unittests and + // CreateOp inside a operator. + kNotSpecified = 0x1000, }; // this class not only make proto but also init attribute checkers. -- GitLab