From 88f111f885a4a4a0dcf00c0ba24916848149b36d Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Fri, 9 Aug 2019 18:14:51 +0800 Subject: [PATCH] remove unused inplace act codes, test=develop (#19079) --- paddle/fluid/operators/activation_op.cc | 14 -------------- paddle/fluid/operators/activation_op.h | 15 --------------- paddle/fluid/pybind/pybind.cc | 3 --- 3 files changed, 32 deletions(-) diff --git a/paddle/fluid/operators/activation_op.cc b/paddle/fluid/operators/activation_op.cc index acffb5d171..7db6c6e676 100755 --- a/paddle/fluid/operators/activation_op.cc +++ b/paddle/fluid/operators/activation_op.cc @@ -36,20 +36,6 @@ static constexpr bool CanInplaceAct() { return GradFunctor::FwdDeps() == kDepOut || GradFunctor::FwdDeps() == kNoDeps; } -std::unique_ptr> GetInplaceOpSet() { - std::unique_ptr> ret( - new std::unordered_set()); -#define INSERT_INTO_INPLACE_OP_SET(op_type, __omitted, fwd_functor, \ - bwd_functor) \ - if (CanInplaceAct>()) { \ - ret->insert(#op_type); \ - } - - FOR_EACH_ACTIVATION_OP(INSERT_INTO_INPLACE_OP_SET); -#undef INSERT_INTO_INPLACE_OP_SET - return ret; -} - #define REGISTER_ACTIVATION_OP_MAKER(OP_NAME, OP_COMMENT) \ class OP_NAME##OpMaker \ : public ::paddle::framework::OpProtoAndCheckerMaker { \ diff --git a/paddle/fluid/operators/activation_op.h b/paddle/fluid/operators/activation_op.h index 1739aa2924..b4d01dfc6b 100644 --- a/paddle/fluid/operators/activation_op.h +++ b/paddle/fluid/operators/activation_op.h @@ -49,21 +49,6 @@ enum ActBwdOpFwdDeps { kDepXOut = 0x03 }; -std::unique_ptr> GetInplaceOpSet(); - -static bool IsInplace(const std::string& op) { - static auto InplaceOpSet = GetInplaceOpSet(); - bool inplace = InplaceOpSet->count(op); - // for op_grad - const int kGradSuffixLen = 4; - if (op.size() > kGradSuffixLen && - op.compare(op.size() - kGradSuffixLen - 1, kGradSuffixLen, "grad")) { - inplace = - InplaceOpSet->count(op.substr(0, op.size() - (kGradSuffixLen + 1))); - } - return inplace; -} - /* The following operator can be used to process SelectedRows, because the * output of those operator for zero is zero too. */ diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 5db8b4df99..c0aeb82b7b 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -1080,9 +1080,6 @@ All parameter, weight, gradient are variables in Paddle. }, py::return_value_policy::take_ownership); - m.def("IsInplace", - [](std::string op) -> bool { return operators::IsInplace(op); }); - m.def("op_support_gpu", OpSupportGPU); #ifdef PADDLE_WITH_CUDA m.def("get_cuda_device_count", platform::GetCUDADeviceCount); -- GitLab