From 2e320079d35e140d2c9b01f859bf386fd3cf9304 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Thu, 28 Jun 2018 12:49:41 +0000 Subject: [PATCH] fix bugs --- paddle/fluid/framework/details/data_balance_op_handle.cc | 4 +--- paddle/fluid/framework/details/data_balance_op_handle.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/details/data_balance_op_handle.cc b/paddle/fluid/framework/details/data_balance_op_handle.cc index 786d95acb..24a68506e 100644 --- a/paddle/fluid/framework/details/data_balance_op_handle.cc +++ b/paddle/fluid/framework/details/data_balance_op_handle.cc @@ -81,8 +81,7 @@ void DataBalanceOpHandle::RunImpl() { "The NoDummyInputSize and NoDummyOutputSize should be equal."); int data_num = in_var_handles.size() / places_.size(); WaitInputVarGenerated(); - - std::vector> lod_tensors; + std::vector> lod_tensors(data_num); std::vector device_sizes; for (int i = 0; i < static_cast(in_var_handles.size()); ++i) { PADDLE_ENFORCE_EQ(in_var_handles[i]->name_, out_var_handles[i]->name_, @@ -105,7 +104,6 @@ void DataBalanceOpHandle::RunImpl() { } } const auto &balance_plan = GetBalancePlan(device_sizes); - for (const auto &trans : balance_plan) { for (int data_idx = 0; data_idx < data_num; ++data_idx) { LoDTensor *src_tensor = lod_tensors[data_idx][trans[0]]; diff --git a/paddle/fluid/framework/details/data_balance_op_handle.h b/paddle/fluid/framework/details/data_balance_op_handle.h index 00bc4837d..5552be2e6 100644 --- a/paddle/fluid/framework/details/data_balance_op_handle.h +++ b/paddle/fluid/framework/details/data_balance_op_handle.h @@ -41,8 +41,8 @@ struct DataBalanceOpHandle : public OpHandleBase { std::vector> GetBalancePlan( const std::vector &batch_size_per_device); - const std::vector &local_scopes_; - const std::vector &places_; + const std::vector local_scopes_; + const std::vector places_; }; } // namespace details -- GitLab