From 10505faf4ea5f8ddb9d5f5b475388452060a8188 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Thu, 17 Oct 2019 15:34:54 +0800 Subject: [PATCH] polish codes, test=develop (#20672) --- paddle/fluid/framework/inplace_op_inference.h | 12 +++++------- paddle/fluid/operators/activation_op.h | 8 -------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/paddle/fluid/framework/inplace_op_inference.h b/paddle/fluid/framework/inplace_op_inference.h index 40026eaca9a..225c8e26b24 100644 --- a/paddle/fluid/framework/inplace_op_inference.h +++ b/paddle/fluid/framework/inplace_op_inference.h @@ -43,13 +43,11 @@ class SingleOpInplaceInToOut : public InplaceOpInference { public: std::unordered_map operator()( const OpDesc& op_desc, bool use_cuda) const override { - PADDLE_ENFORCE_EQ(op_desc.InputNames().size(), 1, - "Op inputs must be unique"); - PADDLE_ENFORCE_EQ(op_desc.OutputNames().size(), 1, - "Op outputs must be unique"); - auto x_name = op_desc.InputNames().at(0); - auto out_name = op_desc.OutputNames().at(0); - return std::unordered_map{{x_name, out_name}}; + auto inputs = op_desc.InputNames(); + auto outputs = op_desc.OutputNames(); + PADDLE_ENFORCE_EQ(inputs.size(), 1, "Op inputs must be unique"); + PADDLE_ENFORCE_EQ(outputs.size(), 1, "Op outputs must be unique"); + return {{inputs[0], outputs[0]}}; } }; diff --git a/paddle/fluid/operators/activation_op.h b/paddle/fluid/operators/activation_op.h index ea19dcd3ab0..8c70c9abccd 100644 --- a/paddle/fluid/operators/activation_op.h +++ b/paddle/fluid/operators/activation_op.h @@ -210,14 +210,6 @@ struct BaseActivationFunctor { using AttrPair = std::vector>; AttrPair GetAttrs() { return AttrPair(); } - - /* NOTE(*): Output reuse X memory if X is not dependented by its Gradient. - For example, sigmoid op's gradient didn't involve x, so its output can - reuse - input memory. But abs op's gradient use x, it can not be inplaced. - gradient did use x. - */ - bool Inplace() const { return false; } }; // sigmoid(x) = 1 / (1 + exp(-x)) -- GitLab