From 999d0fdbef0c18024c89c9a5eee309177dc4e160 Mon Sep 17 00:00:00 2001 From: yuyang18 Date: Tue, 15 May 2018 20:31:48 +0800 Subject: [PATCH] By default is all reduce --- paddle/fluid/framework/details/build_strategy.h | 2 +- paddle/fluid/framework/details/fetch_op_handle.cc | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/framework/details/build_strategy.h b/paddle/fluid/framework/details/build_strategy.h index d6f9c547d..91bdfe613 100644 --- a/paddle/fluid/framework/details/build_strategy.h +++ b/paddle/fluid/framework/details/build_strategy.h @@ -27,7 +27,7 @@ struct BuildStrategy { kCustomized = 2, }; - ReduceStrategy reduce_{ReduceStrategy::kReduce}; + ReduceStrategy reduce_{ReduceStrategy::kAllReduce}; GradientScaleStrategy gradient_scale_{GradientScaleStrategy::kCoeffNumDevice}; }; diff --git a/paddle/fluid/framework/details/fetch_op_handle.cc b/paddle/fluid/framework/details/fetch_op_handle.cc index c581149a2..b1c9dd0d1 100644 --- a/paddle/fluid/framework/details/fetch_op_handle.cc +++ b/paddle/fluid/framework/details/fetch_op_handle.cc @@ -44,12 +44,6 @@ void FetchOpHandle::WaitAndMergeCPUTensors() const { data_->at(offset_).MergeLoDTensor(tensors_ptr, platform::CPUPlace()); } -template -inline T &Ref(T *ptr, ARGS &&... args) { - PADDLE_ENFORCE(ptr != nullptr, args...); - return *ptr; -} - void FetchOpHandle::RunImpl() { WaitInputVarGenerated(platform::CPUPlace()); @@ -59,14 +53,10 @@ void FetchOpHandle::RunImpl() { platform::CPUPlace cpu; auto &scopes = *local_scopes_; - PADDLE_ENFORCE_EQ(inputs_.size(), scopes.size()); for (size_t i = 0; i < scopes.size(); ++i) { auto &scope = scopes[i]; - auto *var = Ref(Ref(scope->FindVar(kLocalExecScopeName), "Cannot find %s", - kLocalExecScopeName) - .Get(), - "Cannot get scope") - .FindVar(var_name); + auto *var = + scope->FindVar(kLocalExecScopeName)->Get()->FindVar(var_name); PADDLE_ENFORCE_NOT_NULL(var, "Cannot find variable %s in execution scope", var_name); auto &t = var->Get(); -- GitLab