From e0cee58c844ff7fdabdad9fe0a0e25341384bfdf Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Tue, 17 Oct 2017 02:48:35 +0000 Subject: [PATCH] modify protobuf --- paddle/framework/framework.proto | 2 +- paddle/framework/prune.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/paddle/framework/framework.proto b/paddle/framework/framework.proto index fd4c0440e..008fb45fb 100644 --- a/paddle/framework/framework.proto +++ b/paddle/framework/framework.proto @@ -55,7 +55,7 @@ message OpDesc { repeated Var inputs = 1; repeated Var outputs = 2; repeated Attr attrs = 4; - required bool is_target = 5 [ default = false ]; + optional bool is_target = 5 [ default = false ]; }; // OpProto describes a C++ framework::OperatorBase derived class. diff --git a/paddle/framework/prune.cc b/paddle/framework/prune.cc index c9a1d7d5c..b08e0116b 100644 --- a/paddle/framework/prune.cc +++ b/paddle/framework/prune.cc @@ -39,6 +39,13 @@ bool HasDependentVar(const OpDesc& op_desc, return false; } +bool IsTarget(const OpDesc& op_desc) { + if (op_desc.has_is_target()) { + return op_desc.is_target(); + } + return false; +} + void Prune(const ProgramDesc& input, ProgramDesc& output, int block_id) { // TODO(tonyyang-svail): // - will change to use multiple blocks for RNN op and Cond Op @@ -66,7 +73,7 @@ void Prune(const ProgramDesc& input, ProgramDesc& output, int block_id) { for (auto op_iter = ops.rbegin(); op_iter != ops.rend(); ++op_iter) { auto& op_desc = *op_iter; - if (op_desc.is_target() || HasDependentVar(op_desc, dependent_vars)) { + if (IsTarget(op_desc) || HasDependentVar(op_desc, dependent_vars)) { // insert its input to the dependency graph for (auto& var : op_desc.inputs()) { for (auto& argu : var.arguments()) { -- GitLab