Skip to content

Commit 849bd23

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into tile_op_npu
2 parents 23a788c + 6151ccd commit 849bd23

File tree

124 files changed

+4872
-902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+4872
-902
lines changed

paddle/fluid/distributed/common/sparse_sharding_merge.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <vector>
2222

2323
#include <ThreadPool.h>
24-
#include "boost/lexical_cast.hpp"
2524
#include "glog/logging.h"
2625
#include "paddle/fluid/distributed/common/utils.h"
2726
#include "paddle/fluid/framework/blocking_queue.h"
@@ -36,8 +35,6 @@ constexpr int Q_SIZE = 10000;
3635
constexpr int BUCKET = 10;
3736
constexpr char XEOF[] = "EOF";
3837

39-
using boost::lexical_cast;
40-
4138
inline double GetCurrentUS() {
4239
struct timeval time;
4340
gettimeofday(&time, NULL);
@@ -208,8 +205,10 @@ class ShardingMerge {
208205
for (int x = 0; x < embedding_dim; ++x) {
209206
float v = 0.0;
210207
try {
211-
v = lexical_cast<float>(values_str[x]);
212-
} catch (boost::bad_lexical_cast &e) {
208+
v = std::stof(values_str[x]);
209+
} catch (std::invalid_argument &e) {
210+
VLOG(0) << " get unexpected line: " << line;
211+
} catch (std::out_of_range &e) {
213212
VLOG(0) << " get unexpected line: " << line;
214213
}
215214
out->push_back(v);

paddle/fluid/distributed/index_dataset/index_wrapper.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License. */
1717
#include <vector>
1818
#include "paddle/fluid/framework/io/fs.h"
1919

20-
#include <boost/algorithm/string.hpp>
21-
#include <boost/lexical_cast.hpp>
2220
#include "paddle/fluid/distributed/index_dataset/index_wrapper.h"
2321

2422
namespace paddle {
@@ -65,7 +63,7 @@ int TreeIndex::Load(const std::string filename) {
6563
if (item.key() == ".tree_meta") {
6664
meta_.ParseFromString(item.value());
6765
} else {
68-
auto code = boost::lexical_cast<uint64_t>(item.key());
66+
auto code = std::stoull(item.key());
6967
IndexNode node;
7068
node.ParseFromString(item.value());
7169
PADDLE_ENFORCE_NE(node.id(), 0,

paddle/fluid/distributed/table/common_sparse_table.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "paddle/fluid/distributed/table/common_sparse_table.h"
1616
#include <sstream>
1717

18-
#include "boost/lexical_cast.hpp"
1918
#include "glog/logging.h"
2019
#include "paddle/fluid/platform/enforce.h"
2120

@@ -50,8 +49,11 @@ void CommonSparseTable::ProcessALine(const std::vector<std::string>& columns,
5049
float v = 0.0;
5150

5251
try {
53-
v = lexical_cast<float>(va);
54-
} catch (boost::bad_lexical_cast& e) {
52+
v = std::stof(va);
53+
} catch (std::invalid_argument& e) {
54+
VLOG(0) << "id: " << id << " get unexpected value: " << va
55+
<< " and be reset to: 0.0";
56+
} catch (std::out_of_range& e) {
5557
VLOG(0) << "id: " << id << " get unexpected value: " << va
5658
<< " and be reset to: 0.0";
5759
}
@@ -131,7 +133,7 @@ int64_t CommonSparseTable::LoadFromText(
131133

132134
while (std::getline(file, line)) {
133135
auto values = paddle::string::split_string<std::string>(line, "\t");
134-
auto id = lexical_cast<uint64_t>(values[0]);
136+
auto id = std::stoull(values[0]);
135137

136138
if (id % pserver_num != pserver_id) {
137139
VLOG(3) << "will not load " << values[0] << " from " << valuepath
@@ -150,10 +152,9 @@ int64_t CommonSparseTable::LoadFromText(
150152
VALUE* value_instant = block->GetValue(id);
151153

152154
if (values.size() == 5) {
153-
value_instant->count_ = lexical_cast<int>(values[1]);
154-
value_instant->unseen_days_ = lexical_cast<int>(values[2]);
155-
value_instant->is_entry_ =
156-
static_cast<bool>(lexical_cast<int>(values[3]));
155+
value_instant->count_ = std::stoi(values[1]);
156+
value_instant->unseen_days_ = std::stoi(values[2]);
157+
value_instant->is_entry_ = static_cast<bool>(std::stoi(values[3]));
157158
}
158159

159160
std::vector<float*> block_values = block->Get(id, meta.names, meta.dims);

paddle/fluid/distributed/table/common_sparse_table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "paddle/fluid/string/string_helper.h"
3434

3535
#define PSERVER_SAVE_SUFFIX ".shard"
36-
using boost::lexical_cast;
3736

3837
namespace paddle {
3938
namespace distributed {

paddle/fluid/distributed/table/ssd_sparse_table.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ int64_t SSDSparseTable::LoadFromText(
310310

311311
while (std::getline(file, line)) {
312312
auto values = paddle::string::split_string<std::string>(line, "\t");
313-
auto id = lexical_cast<uint64_t>(values[0]);
313+
auto id = std::stoull(values[0]);
314314

315315
if (id % pserver_num != pserver_id) {
316316
VLOG(3) << "will not load " << values[0] << " from " << valuepath
@@ -329,10 +329,9 @@ int64_t SSDSparseTable::LoadFromText(
329329
VALUE* value_instant = block->GetValue(id);
330330

331331
if (values.size() == 5) {
332-
value_instant->count_ = lexical_cast<int>(values[1]);
333-
value_instant->unseen_days_ = lexical_cast<int>(values[2]);
334-
value_instant->is_entry_ =
335-
static_cast<bool>(lexical_cast<int>(values[3]));
332+
value_instant->count_ = std::stoi(values[1]);
333+
value_instant->unseen_days_ = std::stoi(values[2]);
334+
value_instant->is_entry_ = static_cast<bool>(std::stoi(values[3]));
336335
}
337336

338337
std::vector<float*> block_values = block->Get(id, meta.names, meta.dims);

paddle/fluid/framework/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ else()
427427
cc_test(custom_tensor_test SRCS custom_tensor_test.cc DEPS custom_tensor glog)
428428
endif()
429429

430+
#cc_binary(test_executor SRCS test_executor.cc DEPS executor op_registry ${GLOB_OP_LIB} ${GLOB_OPERATOR_DEPS} )
431+
#cc_binary(new_executor SRCS new_exec_test.cc DEPS operator op_registry executor ${GLOB_OP_LIB} ${GLOB_OPERATOR_DEPS} profiler)
432+
430433
set(FLUID_FRAMEWORK_MODULES proto_desc memory lod_tensor executor data_feed_proto layer dynamic_loader custom_operator)
431434

432435
cc_library(paddle_framework DEPS ${FLUID_FRAMEWORK_MODULES})

paddle/fluid/framework/details/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ if(NOT APPLE AND NOT WIN32 AND (WITH_GPU OR WITH_ROCM))
141141
endif()
142142
cc_library(build_strategy SRCS build_strategy.cc DEPS pass_builder ${IR_PASS_DEPS})
143143
cc_test(build_strategy_test SRCS build_strategy_test.cc
144-
DEPS build_strategy op_registry op_proto_maker graph)
144+
DEPS build_strategy op_registry op_proto_maker graph string_helper)
145145

146146
if (WITH_MKLDNN)
147147
target_link_libraries(build_strategy mkldnn_placement_pass)

paddle/fluid/framework/distributed_strategy.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ message DistributedStrategy {
183183
optional bool use_hierarchical_allreduce = 15 [ default = false ];
184184
optional int32 hierarchical_allreduce_inter_nranks = 16 [ default = 1 ];
185185
optional bool sync_batch_norm = 17 [ default = false ];
186-
optional bool fuse_all_reduce_ops = 18 [ default = false ];
186+
optional bool fuse_all_reduce_ops = 18 [ default = true ];
187187
optional int32 fuse_grad_size_in_MB = 19 [ default = 32 ];
188188
optional float fuse_grad_size_in_TFLOPS = 20 [ default = 50 ];
189189
optional bool cudnn_exhaustive_search = 21 [ default = false ];

paddle/fluid/framework/fleet/fleet_wrapper.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void FleetWrapper::HeterPushSparseVars(
262262
int64_t* ids = tensor->data<int64_t>();
263263
int slot = 0;
264264
if (dump_slot) {
265-
slot = boost::lexical_cast<int>(sparse_key_names[i]);
265+
slot = std::stoi(sparse_key_names[i]);
266266
}
267267
Variable* g_var = scope.FindVar(sparse_grad_names[i]);
268268
if (g_var == nullptr) {
@@ -915,12 +915,17 @@ void FleetWrapper::PushSparseVarsWithLabelAsync(
915915
int slot = 0;
916916
if (dump_slot) {
917917
try {
918-
slot = boost::lexical_cast<int>(sparse_key_names[i]);
919-
} catch (boost::bad_lexical_cast const& e) {
918+
slot = std::stoi(sparse_key_names[i]);
919+
} catch (std::invalid_argument const& e) {
920920
PADDLE_THROW(platform::errors::PreconditionNotMet(
921921
"sparse var's name: %s, doesn't support non-integer type name when "
922922
"dump_slot=True",
923923
sparse_key_names[i]));
924+
} catch (std::out_of_range const& e) {
925+
PADDLE_THROW(platform::errors::PreconditionNotMet(
926+
"sparse var's name: %s, integer type name out of range when "
927+
"dump_slot=True",
928+
sparse_key_names[i]));
924929
}
925930
}
926931
Variable* g_var = scope.FindVar(sparse_grad_names[i]);
@@ -1121,7 +1126,7 @@ void FleetWrapper::PushSparseFromTensorWithLabelAsync(
11211126
data[click_index] = static_cast<float>(fea_labels.at(input_idx));
11221127
}
11231128
if (dump_slot) {
1124-
int slot = boost::lexical_cast<int>(input_names[index]);
1129+
int slot = std::stoi(input_names[index]);
11251130
data[0] = static_cast<float>(slot);
11261131
}
11271132
++input_idx;

paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ AdaptivePool2dConvertGlobalPass::AdaptivePool2dConvertGlobalPass() {
6060
.IsStringIn({"NHWC", "NCHW"})
6161
.End()
6262
.AddAttr("padding_algorithm")
63+
.IsOptional()
6364
.IsStringIn({"EXPLICIT", "SAME", "VALID"})
6465
.End();
6566
}

0 commit comments

Comments
 (0)