diff --git a/lite/api/cxx_api_bin.cc b/lite/api/cxx_api_bin.cc index 8c929e9c8700a65c868e2facd763b0ec36719e23..eec17cc30e308e7169b7d8c394c0e47eee0c1c3e 100644 --- a/lite/api/cxx_api_bin.cc +++ b/lite/api/cxx_api_bin.cc @@ -67,7 +67,7 @@ void Run(const char* model_dir, int repeat) { int main(int argc, char** argv) { CHECK_EQ(argc, 3) << "usage: ./cmd "; - paddle::lite::Run(argv[1], std::stoi(argv[2])); + paddle::lite::Run(argv[1], atoi(argv[2])); return 0; } diff --git a/lite/api/model_test.cc b/lite/api/model_test.cc index ed4ab75366a0ab669fb8fe6e1d15ad9fd2f5aef5..b0f7a0479f0db91b816838f9d0ee1cc31b9b232a 100644 --- a/lite/api/model_test.cc +++ b/lite/api/model_test.cc @@ -138,7 +138,7 @@ void Run(const std::vector>& input_shapes, std::ofstream out(FLAGS_arg_name + ".txt"); for (size_t i = 0; i < arg_num; ++i) { sum += arg_tensor->data()[i]; - out << std::to_string(arg_tensor->data()[i]) << "\n"; + out << paddle::lite::to_string(arg_tensor->data()[i]) << "\n"; } LOG(INFO) << FLAGS_arg_name << " shape is " << os.str() << ", mean value is " << sum * 1. / arg_num; diff --git a/lite/api/model_test_classify.cc b/lite/api/model_test_classify.cc index bea0ab15e49dc55e0a8f5f29d455b5504345cf19..375d249476bf5323d69ea41c3f11d07e9c8bc711 100644 --- a/lite/api/model_test_classify.cc +++ b/lite/api/model_test_classify.cc @@ -250,7 +250,7 @@ void Run(const std::vector>& input_shapes, std::ofstream out(FLAGS_arg_name + ".txt"); for (size_t i = 0; i < arg_num; ++i) { sum += arg_tensor->data()[i]; - out << std::to_string(arg_tensor->data()[i]) << "\n"; + out << paddle::lite::to_string(arg_tensor->data()[i]) << "\n"; } LOG(INFO) << FLAGS_arg_name << " shape is " << os.str() << ", mean value is " << sum * 1. / arg_num; diff --git a/lite/api/model_test_detection.cc b/lite/api/model_test_detection.cc index 36a23999d33b38d8c54f604850bf5d4120ce3d72..f9be12b2c78c623a2b2c9852850576cc11815bd3 100644 --- a/lite/api/model_test_detection.cc +++ b/lite/api/model_test_detection.cc @@ -264,7 +264,7 @@ void Run(const std::vector>& input_shapes, std::ofstream out(FLAGS_arg_name + ".txt"); for (size_t i = 0; i < arg_num; ++i) { sum += arg_tensor->data()[i]; - out << std::to_string(arg_tensor->data()[i]) << "\n"; + out << paddle::lite::to_string(arg_tensor->data()[i]) << "\n"; } LOG(INFO) << FLAGS_arg_name << " shape is " << os.str() << ", mean value is " << sum * 1. / arg_num; diff --git a/lite/backends/fpga/KD/debugger.hpp b/lite/backends/fpga/KD/debugger.hpp index 9b1189c407d6d601bb3e5ba8172b1455f04710fd..83b8dff70eb8de7cf1d117585d47118fed539a15 100755 --- a/lite/backends/fpga/KD/debugger.hpp +++ b/lite/backends/fpga/KD/debugger.hpp @@ -106,7 +106,7 @@ inline void read_from_file(lite::Tensor* t, const std::string& path) { inline void save_float(float* data, const std::string& name, int len) { static int counter = 0; - std::string old_string = std::to_string(counter); + std::string old_string = paddle::lite::to_string(counter); std::string new_string = std::string(3 - old_string.length(), '0') + old_string; diff --git a/lite/backends/fpga/KD/tensor.hpp b/lite/backends/fpga/KD/tensor.hpp index 988bc1bb507036de8f13a6c6549c549718bd1256..12a60bd27da832b338dc6b1ca11b1c7d6aa192e4 100644 --- a/lite/backends/fpga/KD/tensor.hpp +++ b/lite/backends/fpga/KD/tensor.hpp @@ -351,10 +351,10 @@ class Tensor { void printScale(std::string type) { printScale(); } std::string dimsFileName() { - return std::to_string(shape_->num()) + "_" + - std::to_string(shape_->channel()) + "_" + - std::to_string(shape_->height()) + "_" + - std::to_string(shape_->width()) + ".txt"; + return paddle::lite::to_string(shape_->num()) + "_" + + paddle::lite::to_string(shape_->channel()) + "_" + + paddle::lite::to_string(shape_->height()) + "_" + + paddle::lite::to_string(shape_->width()) + ".txt"; } void saveToFile() { std::string path = dimsFileName(); } @@ -374,7 +374,7 @@ class Tensor { invalidate(); std::ofstream ofs; static int counter = 0; - std::string npath = std::to_string(counter) + "_" + path; + std::string npath = paddle::lite::to_string(counter) + "_" + path; counter++; save_file_with_name(npath); } diff --git a/lite/backends/x86/jit/gen/blas.h b/lite/backends/x86/jit/gen/blas.h index 39920195b245e1c44ff68ab91af94d25c949bd02..4317d558c6252e9163bc545cba4859fbcb89f804 100644 --- a/lite/backends/x86/jit/gen/blas.h +++ b/lite/backends/x86/jit/gen/blas.h @@ -17,6 +17,7 @@ #include #include "glog/logging.h" #include "lite/backends/x86/jit/gen/jitcode.h" +#include "lite/utils/string.h" namespace paddle { namespace lite { @@ -64,7 +65,7 @@ class VXXJitCode : public JitCode { base += "_Vec"; } base += (with_relu_ ? "_Relu" : ""); - base += "_D" + std::to_string(num_); + base += "_D" + paddle::lite::to_string(num_); return base; } void genCode() override; diff --git a/lite/backends/x86/jit/gen/embseqpool.h b/lite/backends/x86/jit/gen/embseqpool.h index 7cae76f9dd99cf904e831b196bd493623ff7eb1d..999960ece4170d561419ad24bd94c512ce167eb0 100644 --- a/lite/backends/x86/jit/gen/embseqpool.h +++ b/lite/backends/x86/jit/gen/embseqpool.h @@ -47,7 +47,7 @@ class EmbSeqPoolJitCode : public JitCode { } else if (type_ == SeqPoolType::kSqrt) { base += "_Sqrt"; } - base += ("_W" + std::to_string(tbl_w_)); + base += ("_W" + paddle::lite::to_string(tbl_w_)); return base; } void genCode() override; diff --git a/lite/backends/x86/jit/gen/matmul.h b/lite/backends/x86/jit/gen/matmul.h index b1b302b7904a5d92952f4385c483eccdc5df3592..e7be6750cf0d232b41d3be61001eb0af4c52a129 100644 --- a/lite/backends/x86/jit/gen/matmul.h +++ b/lite/backends/x86/jit/gen/matmul.h @@ -38,8 +38,8 @@ class MatMulJitCode : public JitCode { std::string name() const override { std::string base = "MatMulJitCode"; - base = base + "_M" + std::to_string(m_) + "_N" + std::to_string(n_) + "_K" + - std::to_string(k_); + base = base + "_M" + paddle::lite::to_string(m_) + "_N" + + paddle::lite::to_string(n_) + "_K" + paddle::lite::to_string(k_); return base; } void genCode() override; diff --git a/lite/backends/x86/jit/gen/seqpool.h b/lite/backends/x86/jit/gen/seqpool.h index 346179cfbbd0e8291dc17b266366c5df07114b7f..60e27993057b58eb8a4a07fcd0a368fc0a9441fc 100644 --- a/lite/backends/x86/jit/gen/seqpool.h +++ b/lite/backends/x86/jit/gen/seqpool.h @@ -47,7 +47,7 @@ class SeqPoolJitCode : public JitCode { } else if (type_ == SeqPoolType::kSqrt) { base += "_Sqrt"; } - base += ("_W" + std::to_string(w_)); + base += ("_W" + paddle::lite::to_string(w_)); return base; } void genCode() override; diff --git a/lite/core/mir/graph_visualize_pass.cc b/lite/core/mir/graph_visualize_pass.cc index d3e7a625a7a768936db178b3c325e6ac84a0057e..28ec814fa85451b5292bfde6bddc6b64b57b2f08 100644 --- a/lite/core/mir/graph_visualize_pass.cc +++ b/lite/core/mir/graph_visualize_pass.cc @@ -48,13 +48,16 @@ std::string Visualize(mir::SSAGraph* graph) { auto attr_type = op_info->GetAttrType(attr_name); switch (attr_type) { case AttrType::INT: - os << ":int:" << std::to_string(op_info->GetAttr(attr_name)); + os << ":int:" + << paddle::lite::to_string(op_info->GetAttr(attr_name)); break; case AttrType::FLOAT: - os << ":float:" << std::to_string(op_info->GetAttr(attr_name)); + os << ":float:" + << paddle::lite::to_string(op_info->GetAttr(attr_name)); break; case AttrType::BOOLEAN: - os << ":int:" << std::to_string(op_info->GetAttr(attr_name)); + os << ":int:" + << paddle::lite::to_string(op_info->GetAttr(attr_name)); break; case AttrType::STRING: os << ":string: \"" diff --git a/lite/core/mir/memory_optimize_pass.cc b/lite/core/mir/memory_optimize_pass.cc index fe2971777c12121d15eb99c4761965a71af2bfc2..38293ede76ed35bf05767ce1333947b7dfdbc4ac 100644 --- a/lite/core/mir/memory_optimize_pass.cc +++ b/lite/core/mir/memory_optimize_pass.cc @@ -238,7 +238,7 @@ void MemoryOptimizePass::PerformReusePlan( if (reuse_table.count(name) && reuse_table.at(name) != name) { auto replace_name = reuse_table.at(name); input_node->AsArg().name = - replace_name + "(" + std::to_string(node_append_idx) + ")"; + replace_name + "(" + paddle::lite::to_string(node_append_idx) + ")"; node_append_idx++; } } @@ -262,7 +262,7 @@ void MemoryOptimizePass::PerformReusePlan( if (reuse_table.count(name) && reuse_table.at(name) != name) { auto replace_name = reuse_table.at(name); out_node->AsArg().name = - replace_name + "(" + std::to_string(node_append_idx) + ")"; + replace_name + "(" + paddle::lite::to_string(node_append_idx) + ")"; node_append_idx++; } } diff --git a/lite/core/mir/subgraph/subgraph_detector.cc b/lite/core/mir/subgraph/subgraph_detector.cc index 64a87c705cd7d8ab80c9b07e1ac17912a000008f..6844fd96688d5086b47d66a32f770a757f56fda4 100644 --- a/lite/core/mir/subgraph/subgraph_detector.cc +++ b/lite/core/mir/subgraph/subgraph_detector.cc @@ -66,11 +66,11 @@ std::string SubgraphVisualizer::operator()() { } else { exists_ops[op_type]++; } - auto op_name = op_type + std::to_string(exists_ops[op_type]); + auto op_name = op_type + paddle::lite::to_string(exists_ops[op_type]); std::string op_color = "white"; if (subgraph_indices.count(node)) { auto subgraph_idx = subgraph_indices[node]; - op_name += "_subgraph_" + std::to_string(subgraph_idx); + op_name += "_subgraph_" + paddle::lite::to_string(subgraph_idx); op_color = subgraph_colors[subgraph_idx % subgraph_colors.size()]; } dot.AddNode(op_name, diff --git a/lite/core/mir/subgraph/subgraph_detector_test.cc b/lite/core/mir/subgraph/subgraph_detector_test.cc index e96a080d574fbdf4dbf05d79c28e64b2148a98e2..974772a9839c1e089359be3ae98e1833645ccd7a 100644 --- a/lite/core/mir/subgraph/subgraph_detector_test.cc +++ b/lite/core/mir/subgraph/subgraph_detector_test.cc @@ -39,7 +39,7 @@ std::vector AddFCDesc( CHECK_EQ(input_var_names.size(), 1); CHECK_EQ(wshape.size(), 2); static int id = 0; - std::string prefix = "fc_" + std::to_string(id); + std::string prefix = "fc_" + paddle::lite::to_string(id); auto* op_desc = block_desc->AddOp(); auto* wgt = block_desc->AddVar(); @@ -76,7 +76,7 @@ std::vector AddElementwiseAddDesc( const std::vector& input_Y_names) { // CHECK_EQ(input_var_names.size(), 2); static int id = 0; - std::string prefix = "elementwise_add_" + std::to_string(id); + std::string prefix = "elementwise_add_" + paddle::lite::to_string(id); auto* op_desc = block_desc->AddOp(); auto* out = block_desc->AddVar(); @@ -100,7 +100,7 @@ std::vector AddFeedDesc( const std::vector& input_X_names) { // CHECK_EQ(input_var_names.size(), 1); static int id = 0; - std::string prefix = "feed_" + std::to_string(id); + std::string prefix = "feed_" + paddle::lite::to_string(id); auto* op_desc = block_desc->AddOp(); auto* out = block_desc->AddVar(); @@ -123,7 +123,7 @@ std::vector AddFetchDesc( const std::vector& input_X_names) { // CHECK_EQ(input_var_names.size(), 1); static int id = 0; - std::string prefix = "fetch_" + std::to_string(id); + std::string prefix = "fetch_" + paddle::lite::to_string(id); auto* op_desc = block_desc->AddOp(); auto* out = block_desc->AddVar(); diff --git a/lite/core/mir/type_precision_cast_pass.cc b/lite/core/mir/type_precision_cast_pass.cc index 25b367e73c4e27132b41cb2b5ec83b64a4bf226d..ecccf89fa76287a3f30756f7138fcce229e8f337 100644 --- a/lite/core/mir/type_precision_cast_pass.cc +++ b/lite/core/mir/type_precision_cast_pass.cc @@ -201,7 +201,8 @@ void PrecisionCastPass::AddCastInst(const Type& from, CHECK(in->IsArg()); // auto node_id = [&] { return graph->nodes().size(); }; auto cast_op_output_name = in->AsArg().name + "/precision_trans"; - // in->AsArg().name + "/precision_trans/" + std::to_string(node_id()); + // in->AsArg().name + "/precision_trans/" + + // paddle::lite::to_string(node_id()); auto* cast_op_output_arg = graph->NewArgumentNode(cast_op_output_name); cast_op_output_arg->AsArg().type = LiteType::GetTensorTy(from.target(), to.precision(), from.layout()); diff --git a/lite/core/profile/precision_profiler.h b/lite/core/profile/precision_profiler.h index 5d6acc60d0fb98a5ac95c5d6a57a044d6c945d81..324719e744817f58c7a990e45416de6b98bef03e 100644 --- a/lite/core/profile/precision_profiler.h +++ b/lite/core/profile/precision_profiler.h @@ -263,8 +263,8 @@ class PrecisionProfiler { &mean, &std_dev, out_name); - mean_str = std::to_string(mean); - std_dev_str = std::to_string(std_dev); + mean_str = paddle::lite::to_string(mean); + std_dev_str = paddle::lite::to_string(std_dev); } std::string kernel_info = op_name + ":" + kernel_place; std::string output_arg_info = out_name + ":" + @@ -294,8 +294,8 @@ class PrecisionProfiler { &mean, &std_dev, out_name); - mean_str = std::to_string(mean); - std_dev_str = std::to_string(std_dev); + mean_str = paddle::lite::to_string(mean); + std_dev_str = paddle::lite::to_string(std_dev); } std::string kernel_info = op_name + ":" + kernel_place; std::string output_arg_info = out_name + ":" + diff --git a/lite/core/program_fake_utils.h b/lite/core/program_fake_utils.h index edcbb101aa5ddb090cc585a16597967cb5114936..fbee253872237bce08f3f67b948da79becbae21a 100644 --- a/lite/core/program_fake_utils.h +++ b/lite/core/program_fake_utils.h @@ -30,9 +30,9 @@ Program FakeProgram() { auto add_fc = [&](int id, std::string x) { // create variables - std::string w1 = "w" + std::to_string(id); - std::string b1 = "b" + std::to_string(id); - std::string out1 = "out" + std::to_string(id); + std::string w1 = "w" + paddle::lite::to_string(id); + std::string b1 = "b" + paddle::lite::to_string(id); + std::string out1 = "out" + paddle::lite::to_string(id); auto w1v = program.scope()->Var(w1)->GetMutable(); auto b1v = program.scope()->Var(b1)->GetMutable(); auto out1v = program.scope()->Var(out1)->GetMutable(); diff --git a/lite/core/version.h.in b/lite/core/version.h.in index d34c32073b852a50b5d26984ed4812ac4f38a870..da2d5f3ed99631973d97a94741e1711391237261 100644 --- a/lite/core/version.h.in +++ b/lite/core/version.h.in @@ -53,9 +53,9 @@ static std::string version() { static int64_t int_version(const std::string& version) { const std::vector vec = Split(version, "."); if (vec.size() == 3) { - return std::stoi(vec[0]) * MAJOR_COEFF + - std::stoi(vec[1]) * MINOR_COEFF + - std::stoi(vec[2]) * PATCH_COEFF; + return atoi(vec[0].c_str()) * MAJOR_COEFF + + atoi(vec[1].c_str()) * MINOR_COEFF + + atoi(vec[2].c_str()) * PATCH_COEFF; } return -1; } diff --git a/lite/demo/cxx/mask_detection/mask_detection.cc b/lite/demo/cxx/mask_detection/mask_detection.cc index 67014aef9d1797312bffc05712b57357c4d8204c..27cabdd808c87de5ac041cec9c7fd482f8f098e0 100644 --- a/lite/demo/cxx/mask_detection/mask_detection.cc +++ b/lite/demo/cxx/mask_detection/mask_detection.cc @@ -207,7 +207,8 @@ void RunModel(std::string det_model_file, cv::Mat roi = crop_img(img, rec_clip, classify_w, classify_h); // uncomment two lines below, save roi img to disk - // std::string roi_name = "roi_" + std::to_string(i) + ".jpg"; + // std::string roi_name = "roi_" + paddle::lite::to_string(i) + // + ".jpg"; // imwrite(roi_name, roi); // Do PreProcess @@ -240,7 +241,7 @@ void RunModel(std::string det_model_file, roi_color = cv::Scalar(0, 0, 255); prob = 1 - prob; } - std::string prob_str = std::to_string(prob * 100); + std::string prob_str = paddle::lite::to_string(prob * 100); int point_idx = prob_str.find_last_of("."); text += prob_str.substr(0, point_idx + 3) + "%"; diff --git a/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc b/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc index 150bcd231c27c25d8510fc8dfa3281a8351514dd..6f900850557d5545a6de8e4cc7ba983e589dd5f1 100644 --- a/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc +++ b/lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc @@ -32,7 +32,7 @@ int64_t ShapeProduction(const shape_t& shape) { std::string ShapePrint(const shape_t& shape) { std::string shape_str{""}; for (auto i : shape) { - shape_str += std::to_string(i) + " "; + shape_str += paddle::lite::to_string(i) + " "; } return shape_str; } diff --git a/lite/demo/cxx/ssd_detection/ssd_detection.cc b/lite/demo/cxx/ssd_detection/ssd_detection.cc index 0be4561cd8d083f26e562c2346da217bb4b48283..e5f815affbbe8e777760f08668719bd89527b37d 100644 --- a/lite/demo/cxx/ssd_detection/ssd_detection.cc +++ b/lite/demo/cxx/ssd_detection/ssd_detection.cc @@ -126,7 +126,7 @@ std::vector detect_object(const float* data, if (w > 0 && h > 0 && obj.prob <= 1) { rect_out.push_back(obj); cv::rectangle(image, rec_clip, cv::Scalar(0, 0, 255), 2, cv::LINE_AA); - std::string str_prob = std::to_string(obj.prob); + std::string str_prob = paddle::lite::to_string(obj.prob); std::string text = std::string(class_names[obj.class_id]) + ": " + str_prob.substr(0, str_prob.find(".") + 4); int font_face = cv::FONT_HERSHEY_COMPLEX_SMALL; diff --git a/lite/demo/cxx/yolov3_detection/yolov3_detection.cc b/lite/demo/cxx/yolov3_detection/yolov3_detection.cc index d34319050392c74c3fa552bd24c0ea24245ced99..d488643f5a6599af4d8dba9e12f21bceed2c8029 100644 --- a/lite/demo/cxx/yolov3_detection/yolov3_detection.cc +++ b/lite/demo/cxx/yolov3_detection/yolov3_detection.cc @@ -146,7 +146,7 @@ std::vector detect_object(const float* data, if (w > 0 && h > 0 && obj.prob <= 1) { rect_out.push_back(obj); cv::rectangle(image, rec_clip, cv::Scalar(0, 0, 255), 1, cv::LINE_AA); - std::string str_prob = std::to_string(obj.prob); + std::string str_prob = paddle::lite::to_string(obj.prob); std::string text = std::string(class_names[obj.class_id]) + ": " + str_prob.substr(0, str_prob.find(".") + 4); int font_face = cv::FONT_HERSHEY_COMPLEX_SMALL; diff --git a/lite/gen_code/gen_code.cc b/lite/gen_code/gen_code.cc index 0d8f4d0d192f3563d00bb66778ca4e13a17b93b1..6c43f6e0116d9adfc4fc6f315d5653b2634dfe7b 100644 --- a/lite/gen_code/gen_code.cc +++ b/lite/gen_code/gen_code.cc @@ -111,11 +111,11 @@ void Module::AddOpDescHelper(const std::string &op_id, switch (type) { case AttrType::INT: - return std::to_string(desc.GetAttr(name)); + return paddle::lite::to_string(desc.GetAttr(name)); case AttrType::FLOAT: - return std::to_string(desc.GetAttr(name)); + return paddle::lite::to_string(desc.GetAttr(name)); case AttrType::BOOLEAN: - return std::to_string(desc.GetAttr(name)); + return paddle::lite::to_string(desc.GetAttr(name)); case AttrType::STRING: return "\"" + desc.GetAttr(name) + "\""; case AttrType::FLOATS: { diff --git a/lite/gen_code/gen_code.h b/lite/gen_code/gen_code.h index 58a7959f4eb34cb438bf0e25b49b36110435cc6b..d316eac43f99664fa71cba54b3ab5360852300a0 100644 --- a/lite/gen_code/gen_code.h +++ b/lite/gen_code/gen_code.h @@ -153,16 +153,16 @@ class Module { private: std::string WeightUniqueName() const { - return "w_" + std::to_string(weight_counter_++); + return "w_" + paddle::lite::to_string(weight_counter_++); } std::string TmpVarUniqueName() const { - return "tmp_" + std::to_string(tmp_var_counter_++); + return "tmp_" + paddle::lite::to_string(tmp_var_counter_++); } std::string OpUniqueName() const { - return "op_" + std::to_string(op_counter_++); + return "op_" + paddle::lite::to_string(op_counter_++); } std::string KernelUniqueName() const { - return "kernel_" + std::to_string(kernel_counter_++); + return "kernel_" + paddle::lite::to_string(kernel_counter_++); } std::string DataRepr(const std::string &raw_data, PrecisionType dtype); diff --git a/lite/kernels/bm/bridges/utility.cc b/lite/kernels/bm/bridges/utility.cc index aa61462d046e1d21b49517a6362b54a884a6b6de..ffbefa137b9c9caab388fcee865469cea87b83e4 100644 --- a/lite/kernels/bm/bridges/utility.cc +++ b/lite/kernels/bm/bridges/utility.cc @@ -33,7 +33,7 @@ std::string UniqueName(const std::string& prefix) { counter = ++(it->second); } - return prefix + "_" + std::to_string(counter); + return prefix + "_" + paddle::lite::to_string(counter); } bool HasInputArg(const OpInfo* op_info, diff --git a/lite/kernels/npu/bridges/graph.h b/lite/kernels/npu/bridges/graph.h index cc4a7e2a7ce062090ca890d90e21aa643e37a0d3..67d8a2b1cc708f7530532840df3e71770b5a3695 100644 --- a/lite/kernels/npu/bridges/graph.h +++ b/lite/kernels/npu/bridges/graph.h @@ -87,7 +87,8 @@ class Graph { auto idx = Add(name, node); CHECK_GE(idx, 1); // Generate a unique name for the created HiAI IR - node->set_data(std::make_shared(name + "__" + std::to_string(idx))); + node->set_data( + std::make_shared(name + "__" + paddle::lite::to_string(idx))); return node; } diff --git a/lite/kernels/npu/bridges/split_op.cc b/lite/kernels/npu/bridges/split_op.cc index 44786220d7dd7fa24e012073e63935d6c824eb98..ef2bdb68fa9988b6a1985a34d22320193256de7b 100644 --- a/lite/kernels/npu/bridges/split_op.cc +++ b/lite/kernels/npu/bridges/split_op.cc @@ -64,10 +64,12 @@ int SplitConverter(void* ctx, OpLite* op, KernelBase* kernel) { split_op->create_dynamic_output_y(out_names.size()); int idx = 1; for (auto& out_name : out_names) { - auto zero_node = graph->Add(out_name + "/zero" + std::to_string(idx), 0); + auto zero_node = + graph->Add(out_name + "/zero" + paddle::lite::to_string(idx), 0); auto add_node = graph->Add(out_name); auto add_op = add_node->data(); - add_op->set_input_x1(*split_node->data(), "y" + std::to_string(idx)); + add_op->set_input_x1(*split_node->data(), + "y" + paddle::lite::to_string(idx)); add_op->set_input_x2(*zero_node->data()); idx++; } diff --git a/lite/kernels/xpu/bridges/graph.cc b/lite/kernels/xpu/bridges/graph.cc index 43aaad3402b7873dbaa67d4c4897b5378e098500..4af8a2bd3464efaaec6937996445736068f0f656 100644 --- a/lite/kernels/xpu/bridges/graph.cc +++ b/lite/kernels/xpu/bridges/graph.cc @@ -49,7 +49,7 @@ std::shared_ptr Graph::Add(const std::string& name, CHECK_GE(idx, 1); node->set_data(std::make_shared(layer)); // Generate a unique name for the current XTCL layer - builder_.SetLayer(name + "__" + std::to_string(idx)); + builder_.SetLayer(name + "__" + paddle::lite::to_string(idx)); return node; } diff --git a/lite/model_parser/naive_buffer/naive_buffer_test.cc b/lite/model_parser/naive_buffer/naive_buffer_test.cc index 8b6ffb4dcf481bbb8df92e7e15c1d569d575bcae..98789e8006817fceb4745bffd0c095da7ad360fc 100644 --- a/lite/model_parser/naive_buffer/naive_buffer_test.cc +++ b/lite/model_parser/naive_buffer/naive_buffer_test.cc @@ -155,7 +155,7 @@ TEST(ListBuilder, basic) { for (int i = 0; i < num_elems; i++) { auto* elem = li.New(); - elem->set("elem-" + std::to_string(i)); + elem->set("elem-" + paddle::lite::to_string(i)); } li.Save(); table.SaveToFile("2.bf"); @@ -169,7 +169,7 @@ TEST(ListBuilder, basic) { li1.Load(); for (int i = 0; i < num_elems; i++) { - ASSERT_EQ(li1.Get(i).data(), "elem-" + std::to_string(i)); + ASSERT_EQ(li1.Get(i).data(), "elem-" + paddle::lite::to_string(i)); } } diff --git a/lite/tests/kernels/concat_compute_test.cc b/lite/tests/kernels/concat_compute_test.cc index 3e30035f1011405ad9beffefd0df91132747a609..18e4701bdf3e99fbb6f76ed9ac78bbbbfda60a1c 100644 --- a/lite/tests/kernels/concat_compute_test.cc +++ b/lite/tests/kernels/concat_compute_test.cc @@ -128,7 +128,7 @@ class ConcateComputeTester : public arena::TestCase { for (int i = 0; i < x_dims_.production(); i++) { x_data[i] = static_cast(i + n); } - const std::string x_name = "x_tensor_" + std::to_string(n); + const std::string x_name = "x_tensor_" + paddle::lite::to_string(n); x_vct_.push_back(x_name); SetCommonTensor(x_name, x_dims_, x_data.data()); } diff --git a/lite/tests/kernels/fill_constant_compute_test.cc b/lite/tests/kernels/fill_constant_compute_test.cc index 465b7becffe967ab77d0c1a237fe6a4951031b3a..bc2cfce7842c935898bd9ecddc6c2d0ac4c39af5 100644 --- a/lite/tests/kernels/fill_constant_compute_test.cc +++ b/lite/tests/kernels/fill_constant_compute_test.cc @@ -52,7 +52,8 @@ class FillConstantComputeTester : public arena::TestCase { is_use_shape_tensor_list_(is_use_shape_tensor_list) { if (is_use_shape_tensor_list) { for (int i = 0; i < shape.size(); i++) { - shape_tensor_list_.push_back(shape_tensor_ + std::to_string(i)); + shape_tensor_list_.push_back(shape_tensor_ + + paddle::lite::to_string(i)); } } } diff --git a/lite/tests/kernels/reshape_compute_test.cc b/lite/tests/kernels/reshape_compute_test.cc index 1b20c8eaa2164eaf4d658fba72c28b860b5bea74..4fba28e2ab982b1f15e48c95dfa247b2ea56c1ae 100644 --- a/lite/tests/kernels/reshape_compute_test.cc +++ b/lite/tests/kernels/reshape_compute_test.cc @@ -45,7 +45,8 @@ class ReshapeComputeTester : public arena::TestCase { : TestCase(place, alias), dims_(dims) { if (is_shape_tensor_vct) { for (size_t i = 0; i < shape.size(); i++) { - shape_tensor_vct_.emplace_back(op_type_ + "/shape" + std::to_string(i)); + shape_tensor_vct_.emplace_back(op_type_ + "/shape" + + paddle::lite::to_string(i)); } } else if (is_shape_tensor) { shape_tensor_ = op_type_ + "/shape"; diff --git a/lite/tests/kernels/slice_compute_test.cc b/lite/tests/kernels/slice_compute_test.cc index e8c63e2d729c931578de555cdf16cb066cd40e06..4d698ebc0d42a34cf07a85735c09bd49b3fb1284 100644 --- a/lite/tests/kernels/slice_compute_test.cc +++ b/lite/tests/kernels/slice_compute_test.cc @@ -168,8 +168,9 @@ class SliceComputeTester : public arena::TestCase { std::vector ends_tensor_list_; for (int i = 0; i < starts_.size(); ++i) { starts_tensor_list_.push_back("starts_tensor_list_" + - std::to_string(i)); - ends_tensor_list_.push_back("ends_tensor_list_" + std::to_string(i)); + paddle::lite::to_string(i)); + ends_tensor_list_.push_back("ends_tensor_list_" + + paddle::lite::to_string(i)); } op_desc->SetInput("StartsTensorList", {starts_tensor_list_}); op_desc->SetInput("EndsTensorList", {ends_tensor_list_}); @@ -203,15 +204,15 @@ class SliceComputeTester : public arena::TestCase { } else if (use_tensor_list_) { Scope& scope_ = this->scope(); for (int i = 0; i < starts_.size(); ++i) { - auto* tensor = - scope_.NewTensor("starts_tensor_list_" + std::to_string(i)); + auto* tensor = scope_.NewTensor("starts_tensor_list_" + + paddle::lite::to_string(i)); tensor->Resize(DDim({1})); auto* d = tensor->mutable_data(); d[0] = starts_[i]; } for (int i = 0; i < ends_.size(); ++i) { auto* tensor = - scope_.NewTensor("ends_tensor_list_" + std::to_string(i)); + scope_.NewTensor("ends_tensor_list_" + paddle::lite::to_string(i)); tensor->Resize(DDim({1})); auto* d = tensor->mutable_data(); d[0] = ends_[i]; diff --git a/lite/tests/kernels/unsqueeze_compute_test.cc b/lite/tests/kernels/unsqueeze_compute_test.cc index aba7bed4f1508d6dc2e813b16450470972b95de4..461ef7215e3ceb779b2522adbd5bb286036a0d8e 100644 --- a/lite/tests/kernels/unsqueeze_compute_test.cc +++ b/lite/tests/kernels/unsqueeze_compute_test.cc @@ -123,7 +123,7 @@ class UnsqueezeComputeTester : public arena::TestCase { } else if (input_axes_flag_ == 3) { std::string name = "axes_tensor_"; for (size_t i = 0; i < axes_.size(); i++) { - name = name + std::to_string(i); + name = name + paddle::lite::to_string(i); axes_tensor_list_.push_back(name); SetCommonTensor(name, DDim({1}), &axes_[i]); } diff --git a/lite/utils/logging.h b/lite/utils/logging.h index c2c999fd70f3eee78c1deaf5ec2c4fea4e4f3fd1..3d97f4dbec1e4973295248c94c4156563dfb4f5d 100644 --- a/lite/utils/logging.h +++ b/lite/utils/logging.h @@ -29,6 +29,7 @@ #include #include #include "lite/utils/replace_stl/stream.h" +#include "lite/utils/string.h" #ifdef LITE_WITH_ANDROID #include @@ -171,7 +172,7 @@ class VLogMessage { if (GLOG_v_int < level_int) { return; } - const char* level = std::to_string(level_int).c_str(); + const char* level = paddle::lite::to_string(level_int).c_str(); paddle::lite::gen_log(log_stream_, file, func, lineno, level); } diff --git a/lite/utils/replace_stl/stream.cc b/lite/utils/replace_stl/stream.cc index e72f2717293d0cc07ac28c6d51dd4d2bb5ae7874..37b02d3c50b8ed78bb8335a1618f753f645fd00b 100644 --- a/lite/utils/replace_stl/stream.cc +++ b/lite/utils/replace_stl/stream.cc @@ -15,6 +15,7 @@ #include "lite/utils/replace_stl/stream.h" #include #include +#include "lite/utils/string.h" #ifdef LITE_ON_TINY_PUBLISH @@ -39,9 +40,9 @@ void ostream::pad(const std::string& text) { #ifdef LITE_SHUTDOWN_LOG #define ADD_DATA_AS_STRING(data_, obj_) #else -#define ADD_DATA_AS_STRING(data_, obj_) \ - std::string text = std::to_string(obj_); \ - pad(text); \ +#define ADD_DATA_AS_STRING(data_, obj_) \ + std::string text = paddle::lite::to_string(obj_); \ + pad(text); \ data_ = data_ + text; #endif diff --git a/lite/utils/string.h b/lite/utils/string.h index d96b2aac20549989afdc730e34af4fc40541329d..5269525b64f473f1018e183613c087886dba97d6 100644 --- a/lite/utils/string.h +++ b/lite/utils/string.h @@ -48,7 +48,14 @@ template static std::string to_string_with_precision(const T& v, const int n = 6) { STL::stringstream ss; ss.precision(n); - // ss << std::fixed << v; + ss << v; + return ss.str(); +} + +template +static std::string to_string(const T& v) { + STL::stringstream ss; + ss << v; return ss.str(); }