From 6db96ec23cd02a4cec41338f3c1e53aa303be78e Mon Sep 17 00:00:00 2001 From: chengduoZH Date: Wed, 11 Apr 2018 11:47:03 +0800 Subject: [PATCH] follow comments --- paddle/fluid/framework/details/CMakeLists.txt | 6 ++--- ...st_op_handle.cc => broadcast_op_handle.cc} | 12 ++++----- ...cast_op_handle.h => broadcast_op_handle.h} | 10 +++---- ...le_test.cc => broadcast_op_handle_test.cc} | 26 +++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) rename paddle/fluid/framework/details/{broad_cast_op_handle.cc => broadcast_op_handle.cc} (89%) rename paddle/fluid/framework/details/{broad_cast_op_handle.h => broadcast_op_handle.h} (83%) rename paddle/fluid/framework/details/{broad_cast_op_handle_test.cc => broadcast_op_handle_test.cc} (89%) diff --git a/paddle/fluid/framework/details/CMakeLists.txt b/paddle/fluid/framework/details/CMakeLists.txt index eda2b6aac02..7b7582380cb 100644 --- a/paddle/fluid/framework/details/CMakeLists.txt +++ b/paddle/fluid/framework/details/CMakeLists.txt @@ -5,7 +5,7 @@ cc_library(fetch_op_handle SRCS fetch_op_handle.cc DEPS op_handle_base scope lod if(WITH_GPU) nv_library(nccl_all_reduce_op_handle SRCS nccl_all_reduce_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory dynload_cuda) - nv_library(broad_cast_op_handle SRCS broad_cast_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory) + nv_library(broadcast_op_handle SRCS broadcast_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory) endif() cc_library(computation_op_handle SRCS computation_op_handle.cc DEPS framework_proto scope place operator op_registry) @@ -15,8 +15,8 @@ cc_library(ssa_graph_builder SRCS ssa_graph_builder.cc DEPS ssa_graph) if(WITH_GPU) set(multi_devices_graph_builder_deps nccl_all_reduce_op_handle) - nv_test(broad_cast_op_test SRCS broad_cast_op_handle_test.cc DEPS var_handle op_handle_base scope lod_tensor ddim memory - device_context broad_cast_op_handle) + nv_test(broadcast_op_test SRCS broadcast_op_handle_test.cc DEPS var_handle op_handle_base scope lod_tensor ddim memory + device_context broadcast_op_handle) else() set(multi_devices_graph_builder_deps) endif() diff --git a/paddle/fluid/framework/details/broad_cast_op_handle.cc b/paddle/fluid/framework/details/broadcast_op_handle.cc similarity index 89% rename from paddle/fluid/framework/details/broad_cast_op_handle.cc rename to paddle/fluid/framework/details/broadcast_op_handle.cc index e636371b944..a782ebf8fd3 100644 --- a/paddle/fluid/framework/details/broad_cast_op_handle.cc +++ b/paddle/fluid/framework/details/broadcast_op_handle.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/details/broad_cast_op_handle.h" +#include "paddle/fluid/framework/details/broadcast_op_handle.h" namespace paddle { namespace framework { @@ -28,16 +28,16 @@ Tensor *GetTensorFromVar(Variable *in_var) { } return nullptr; } -BCastOpHandle::BCastOpHandle(const std::vector &local_scopes, - const std::vector &places, - const platform::ContextMap &ctxs) +BroadcastOpHandle::BroadcastOpHandle(const std::vector &local_scopes, + const std::vector &places, + const platform::ContextMap &ctxs) : local_scopes_(local_scopes), places_(places), ctxs_(ctxs) { for (auto &p : places_) { this->dev_ctxes_[p] = ctxs_.DevCtx(p); } } -void BCastOpHandle::RunImpl() { +void BroadcastOpHandle::RunImpl() { PADDLE_ENFORCE_EQ(this->inputs_.size(), 1); PADDLE_ENFORCE_EQ(this->outputs_.size(), places_.size()); @@ -97,7 +97,7 @@ void BCastOpHandle::RunImpl() { } } -std::string BCastOpHandle::Name() const { return "broadcast"; } +std::string BroadcastOpHandle::Name() const { return "broadcast"; } } // namespace details } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/details/broad_cast_op_handle.h b/paddle/fluid/framework/details/broadcast_op_handle.h similarity index 83% rename from paddle/fluid/framework/details/broad_cast_op_handle.h rename to paddle/fluid/framework/details/broadcast_op_handle.h index 432e86e410d..a571af1218f 100644 --- a/paddle/fluid/framework/details/broad_cast_op_handle.h +++ b/paddle/fluid/framework/details/broadcast_op_handle.h @@ -29,17 +29,17 @@ namespace framework { namespace details { /* - * BroadCast the input to all scope. + * Broadcast the input to all scope. * */ -struct BCastOpHandle : public OpHandleBase { +struct BroadcastOpHandle : public OpHandleBase { const std::vector &local_scopes_; const std::vector &places_; const platform::ContextMap &ctxs_; - BCastOpHandle(const std::vector &local_scopes, - const std::vector &places, - const platform::ContextMap &ctxs); + BroadcastOpHandle(const std::vector &local_scopes, + const std::vector &places, + const platform::ContextMap &ctxs); std::string Name() const override; diff --git a/paddle/fluid/framework/details/broad_cast_op_handle_test.cc b/paddle/fluid/framework/details/broadcast_op_handle_test.cc similarity index 89% rename from paddle/fluid/framework/details/broad_cast_op_handle_test.cc rename to paddle/fluid/framework/details/broadcast_op_handle_test.cc index a1338abeb5e..fd671ded217 100644 --- a/paddle/fluid/framework/details/broad_cast_op_handle_test.cc +++ b/paddle/fluid/framework/details/broadcast_op_handle_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/details/broad_cast_op_handle.h" +#include "paddle/fluid/framework/details/broadcast_op_handle.h" #include "gtest/gtest.h" #include "paddle/fluid/platform/device_context.h" @@ -23,12 +23,12 @@ namespace p = paddle::platform; // test data amount const f::DDim kDims = {20, 20}; -class BroadCastTester : public ::testing::Test { +class BroadcastTester : public ::testing::Test { public: void SetUp() override { int count = p::GetCUDADeviceCount(); if (count <= 1) { - LOG(WARNING) << "Cannot test multi-gpu BroadCast, because the CUDA " + LOG(WARNING) << "Cannot test multi-gpu Broadcast, because the CUDA " "device count is " << count; exit(0); @@ -40,7 +40,7 @@ class BroadCastTester : public ::testing::Test { } template - void BroadCastInitOp(int gpu_id = 0) { + void BroadcastInitOp(int gpu_id = 0) { for (size_t j = 0; j < gpu_list_.size(); ++j) { local_scope_.push_back(&g_scope_.NewScope()); auto* out_var = local_scope_[j]->Var("out"); @@ -50,7 +50,7 @@ class BroadCastTester : public ::testing::Test { in_var->GetMutable(); bc_op_handle_ = - new f::details::BCastOpHandle(local_scope_, gpu_list_, *ctxs_); + new f::details::BroadcastOpHandle(local_scope_, gpu_list_, *ctxs_); f::details::VarHandle* in_var_handle = new f::details::VarHandle(); in_var_handle->place_ = gpu_list_[gpu_id]; @@ -68,7 +68,7 @@ class BroadCastTester : public ::testing::Test { bc_op_handle_->AddOutput(out_var_handle); } } - void BroadCastDestroy() { + void BroadcastDestroy() { delete ctxs_; for (auto in : bc_op_handle_->inputs_) { delete in; @@ -84,12 +84,12 @@ class BroadCastTester : public ::testing::Test { p::ContextMap* ctxs_; std::vector local_scope_; std::vector gpu_list_; - f::details::BCastOpHandle* bc_op_handle_; + f::details::BroadcastOpHandle* bc_op_handle_; }; -TEST_F(BroadCastTester, BroadCastTestLodTensor) { +TEST_F(BroadcastTester, BroadcastTestLodTensor) { int gpu_id = 0; - BroadCastInitOp(gpu_id); + BroadcastInitOp(gpu_id); auto in_var = local_scope_[gpu_id]->Var("input"); auto in_lod_tensor = in_var->GetMutable(); @@ -122,12 +122,12 @@ TEST_F(BroadCastTester, BroadCastTestLodTensor) { } } - BroadCastDestroy(); + BroadcastDestroy(); } -TEST_F(BroadCastTester, BroadCastTestSelectedRows) { +TEST_F(BroadcastTester, BroadcastTestSelectedRows) { int gpu_id = 0; - BroadCastInitOp(gpu_id); + BroadcastInitOp(gpu_id); auto in_var = local_scope_[gpu_id]->Var("input"); auto in_selected_rows = in_var->GetMutable(); @@ -170,5 +170,5 @@ TEST_F(BroadCastTester, BroadCastTestSelectedRows) { } } - BroadCastDestroy(); + BroadcastDestroy(); } -- GitLab