From b1b13f8f5494b7ccd38f8b095c74d2d8172e2d9d Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 26 Jul 2017 17:13:22 +0800 Subject: [PATCH] Update Interface --- paddle/framework/backward.cc | 12 ++++++------ paddle/framework/backward.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/paddle/framework/backward.cc b/paddle/framework/backward.cc index 116903421..d8653b5dd 100644 --- a/paddle/framework/backward.cc +++ b/paddle/framework/backward.cc @@ -29,10 +29,10 @@ static bool AllInSet(const std::vector& names, return true; } -static std::vector InSetIdx(const std::vector& names, - const std::string& suffix, - const std::unordered_set& set) { - std::vector ret_val; +static std::vector InSetIdx( + const std::vector& names, const std::string& suffix, + const std::unordered_set& set) { + std::vector ret_val; ret_val.reserve(names.size()); for (size_t i = 0; i < names.size(); ++i) { if (set.find(names[i] + suffix) != set.end()) { @@ -78,7 +78,7 @@ static std::shared_ptr BackwardImpl( } extern std::shared_ptr Backward( - const std::shared_ptr& forwardOp, + const OperatorBase& forwardOp, const std::unordered_set& no_grad_vars) { std::unordered_set no_grad_names; no_grad_names.reserve(no_grad_vars.size()); @@ -87,7 +87,7 @@ extern std::shared_ptr Backward( no_grad_names.insert(name + OperatorBase::GRAD_VAR_SUFFIX()); } int uid = 0; - return BackwardImpl(*forwardOp, no_grad_names, uid); + return BackwardImpl(forwardOp, no_grad_names, uid); } } // namespace framework } // namespace paddle diff --git a/paddle/framework/backward.h b/paddle/framework/backward.h index e835ef635..d711c7bbb 100644 --- a/paddle/framework/backward.h +++ b/paddle/framework/backward.h @@ -25,7 +25,7 @@ namespace framework { * @return */ extern std::shared_ptr Backward( - const std::shared_ptr& forwardOp, + const OperatorBase& forwardOp, const std::unordered_set& no_grad_vars); } // namespace framework } // namespace paddle -- GitLab