Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5ffdfeda
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5ffdfeda
编写于
3月 24, 2020
作者:
C
cc
提交者:
GitHub
3月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support gnustl, replace string funcs with ours, test=develop (#3263)
上级
73ca2e00
变更
37
隐藏空白更改
内联
并排
Showing
37 changed file
with
91 addition
and
70 deletion
+91
-70
lite/api/cxx_api_bin.cc
lite/api/cxx_api_bin.cc
+1
-1
lite/api/model_test.cc
lite/api/model_test.cc
+1
-1
lite/api/model_test_classify.cc
lite/api/model_test_classify.cc
+1
-1
lite/api/model_test_detection.cc
lite/api/model_test_detection.cc
+1
-1
lite/backends/fpga/KD/debugger.hpp
lite/backends/fpga/KD/debugger.hpp
+1
-1
lite/backends/fpga/KD/tensor.hpp
lite/backends/fpga/KD/tensor.hpp
+5
-5
lite/backends/x86/jit/gen/blas.h
lite/backends/x86/jit/gen/blas.h
+2
-1
lite/backends/x86/jit/gen/embseqpool.h
lite/backends/x86/jit/gen/embseqpool.h
+1
-1
lite/backends/x86/jit/gen/matmul.h
lite/backends/x86/jit/gen/matmul.h
+2
-2
lite/backends/x86/jit/gen/seqpool.h
lite/backends/x86/jit/gen/seqpool.h
+1
-1
lite/core/mir/graph_visualize_pass.cc
lite/core/mir/graph_visualize_pass.cc
+6
-3
lite/core/mir/memory_optimize_pass.cc
lite/core/mir/memory_optimize_pass.cc
+2
-2
lite/core/mir/subgraph/subgraph_detector.cc
lite/core/mir/subgraph/subgraph_detector.cc
+2
-2
lite/core/mir/subgraph/subgraph_detector_test.cc
lite/core/mir/subgraph/subgraph_detector_test.cc
+4
-4
lite/core/mir/type_precision_cast_pass.cc
lite/core/mir/type_precision_cast_pass.cc
+2
-1
lite/core/profile/precision_profiler.h
lite/core/profile/precision_profiler.h
+4
-4
lite/core/program_fake_utils.h
lite/core/program_fake_utils.h
+3
-3
lite/core/version.h.in
lite/core/version.h.in
+3
-3
lite/demo/cxx/mask_detection/mask_detection.cc
lite/demo/cxx/mask_detection/mask_detection.cc
+3
-2
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
+1
-1
lite/demo/cxx/ssd_detection/ssd_detection.cc
lite/demo/cxx/ssd_detection/ssd_detection.cc
+1
-1
lite/demo/cxx/yolov3_detection/yolov3_detection.cc
lite/demo/cxx/yolov3_detection/yolov3_detection.cc
+1
-1
lite/gen_code/gen_code.cc
lite/gen_code/gen_code.cc
+3
-3
lite/gen_code/gen_code.h
lite/gen_code/gen_code.h
+4
-4
lite/kernels/bm/bridges/utility.cc
lite/kernels/bm/bridges/utility.cc
+1
-1
lite/kernels/npu/bridges/graph.h
lite/kernels/npu/bridges/graph.h
+2
-1
lite/kernels/npu/bridges/split_op.cc
lite/kernels/npu/bridges/split_op.cc
+4
-2
lite/kernels/xpu/bridges/graph.cc
lite/kernels/xpu/bridges/graph.cc
+1
-1
lite/model_parser/naive_buffer/naive_buffer_test.cc
lite/model_parser/naive_buffer/naive_buffer_test.cc
+2
-2
lite/tests/kernels/concat_compute_test.cc
lite/tests/kernels/concat_compute_test.cc
+1
-1
lite/tests/kernels/fill_constant_compute_test.cc
lite/tests/kernels/fill_constant_compute_test.cc
+2
-1
lite/tests/kernels/reshape_compute_test.cc
lite/tests/kernels/reshape_compute_test.cc
+2
-1
lite/tests/kernels/slice_compute_test.cc
lite/tests/kernels/slice_compute_test.cc
+6
-5
lite/tests/kernels/unsqueeze_compute_test.cc
lite/tests/kernels/unsqueeze_compute_test.cc
+1
-1
lite/utils/logging.h
lite/utils/logging.h
+2
-1
lite/utils/replace_stl/stream.cc
lite/utils/replace_stl/stream.cc
+4
-3
lite/utils/string.h
lite/utils/string.h
+8
-1
未找到文件。
lite/api/cxx_api_bin.cc
浏览文件 @
5ffdfeda
...
...
@@ -67,7 +67,7 @@ void Run(const char* model_dir, int repeat) {
int
main
(
int
argc
,
char
**
argv
)
{
CHECK_EQ
(
argc
,
3
)
<<
"usage: ./cmd <model_dir> <repeat>"
;
paddle
::
lite
::
Run
(
argv
[
1
],
std
::
s
toi
(
argv
[
2
]));
paddle
::
lite
::
Run
(
argv
[
1
],
a
toi
(
argv
[
2
]));
return
0
;
}
...
...
lite/api/model_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -138,7 +138,7 @@ void Run(const std::vector<std::vector<int64_t>>& input_shapes,
std
::
ofstream
out
(
FLAGS_arg_name
+
".txt"
);
for
(
size_t
i
=
0
;
i
<
arg_num
;
++
i
)
{
sum
+=
arg_tensor
->
data
<
float
>
()[
i
];
out
<<
std
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
out
<<
paddle
::
lite
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
}
LOG
(
INFO
)
<<
FLAGS_arg_name
<<
" shape is "
<<
os
.
str
()
<<
", mean value is "
<<
sum
*
1.
/
arg_num
;
...
...
lite/api/model_test_classify.cc
浏览文件 @
5ffdfeda
...
...
@@ -250,7 +250,7 @@ void Run(const std::vector<std::vector<int64_t>>& input_shapes,
std
::
ofstream
out
(
FLAGS_arg_name
+
".txt"
);
for
(
size_t
i
=
0
;
i
<
arg_num
;
++
i
)
{
sum
+=
arg_tensor
->
data
<
float
>
()[
i
];
out
<<
std
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
out
<<
paddle
::
lite
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
}
LOG
(
INFO
)
<<
FLAGS_arg_name
<<
" shape is "
<<
os
.
str
()
<<
", mean value is "
<<
sum
*
1.
/
arg_num
;
...
...
lite/api/model_test_detection.cc
浏览文件 @
5ffdfeda
...
...
@@ -264,7 +264,7 @@ void Run(const std::vector<std::vector<int64_t>>& input_shapes,
std
::
ofstream
out
(
FLAGS_arg_name
+
".txt"
);
for
(
size_t
i
=
0
;
i
<
arg_num
;
++
i
)
{
sum
+=
arg_tensor
->
data
<
float
>
()[
i
];
out
<<
std
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
out
<<
paddle
::
lite
::
to_string
(
arg_tensor
->
data
<
float
>
()[
i
])
<<
"
\n
"
;
}
LOG
(
INFO
)
<<
FLAGS_arg_name
<<
" shape is "
<<
os
.
str
()
<<
", mean value is "
<<
sum
*
1.
/
arg_num
;
...
...
lite/backends/fpga/KD/debugger.hpp
浏览文件 @
5ffdfeda
...
...
@@ -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
;
...
...
lite/backends/fpga/KD/tensor.hpp
浏览文件 @
5ffdfeda
...
...
@@ -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
);
}
...
...
lite/backends/x86/jit/gen/blas.h
浏览文件 @
5ffdfeda
...
...
@@ -17,6 +17,7 @@
#include <string>
#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
;
...
...
lite/backends/x86/jit/gen/embseqpool.h
浏览文件 @
5ffdfeda
...
...
@@ -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
;
...
...
lite/backends/x86/jit/gen/matmul.h
浏览文件 @
5ffdfeda
...
...
@@ -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
;
...
...
lite/backends/x86/jit/gen/seqpool.h
浏览文件 @
5ffdfeda
...
...
@@ -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
;
...
...
lite/core/mir/graph_visualize_pass.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
<
int
>
(
attr_name
));
os
<<
":int:"
<<
paddle
::
lite
::
to_string
(
op_info
->
GetAttr
<
int
>
(
attr_name
));
break
;
case
AttrType
::
FLOAT
:
os
<<
":float:"
<<
std
::
to_string
(
op_info
->
GetAttr
<
float
>
(
attr_name
));
os
<<
":float:"
<<
paddle
::
lite
::
to_string
(
op_info
->
GetAttr
<
float
>
(
attr_name
));
break
;
case
AttrType
::
BOOLEAN
:
os
<<
":int:"
<<
std
::
to_string
(
op_info
->
GetAttr
<
bool
>
(
attr_name
));
os
<<
":int:"
<<
paddle
::
lite
::
to_string
(
op_info
->
GetAttr
<
bool
>
(
attr_name
));
break
;
case
AttrType
::
STRING
:
os
<<
":string:
\"
"
...
...
lite/core/mir/memory_optimize_pass.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
++
;
}
}
...
...
lite/core/mir/subgraph/subgraph_detector.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
,
...
...
lite/core/mir/subgraph/subgraph_detector_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -39,7 +39,7 @@ std::vector<std::string> 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
<
cpp
::
OpDesc
>
();
auto
*
wgt
=
block_desc
->
AddVar
<
cpp
::
VarDesc
>
();
...
...
@@ -76,7 +76,7 @@ std::vector<std::string> AddElementwiseAddDesc(
const
std
::
vector
<
std
::
string
>&
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
<
cpp
::
OpDesc
>
();
auto
*
out
=
block_desc
->
AddVar
<
cpp
::
VarDesc
>
();
...
...
@@ -100,7 +100,7 @@ std::vector<std::string> AddFeedDesc(
const
std
::
vector
<
std
::
string
>&
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
<
cpp
::
OpDesc
>
();
auto
*
out
=
block_desc
->
AddVar
<
cpp
::
VarDesc
>
();
...
...
@@ -123,7 +123,7 @@ std::vector<std::string> AddFetchDesc(
const
std
::
vector
<
std
::
string
>&
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
<
cpp
::
OpDesc
>
();
auto
*
out
=
block_desc
->
AddVar
<
cpp
::
VarDesc
>
();
...
...
lite/core/mir/type_precision_cast_pass.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
());
...
...
lite/core/profile/precision_profiler.h
浏览文件 @
5ffdfeda
...
...
@@ -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
+
":"
+
...
...
lite/core/program_fake_utils.h
浏览文件 @
5ffdfeda
...
...
@@ -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
<
lite
::
Tensor
>
();
auto
b1v
=
program
.
scope
()
->
Var
(
b1
)
->
GetMutable
<
lite
::
Tensor
>
();
auto
out1v
=
program
.
scope
()
->
Var
(
out1
)
->
GetMutable
<
lite
::
Tensor
>
();
...
...
lite/core/version.h.in
浏览文件 @
5ffdfeda
...
...
@@ -53,9 +53,9 @@ static std::string version() {
static int64_t int_version(const std::string& version) {
const std::vector<std::string> 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;
}
...
...
lite/demo/cxx/mask_detection/mask_detection.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
)
+
"%"
;
...
...
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
;
}
...
...
lite/demo/cxx/ssd_detection/ssd_detection.cc
浏览文件 @
5ffdfeda
...
...
@@ -126,7 +126,7 @@ std::vector<Object> 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
;
...
...
lite/demo/cxx/yolov3_detection/yolov3_detection.cc
浏览文件 @
5ffdfeda
...
...
@@ -146,7 +146,7 @@ std::vector<Object> 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
;
...
...
lite/gen_code/gen_code.cc
浏览文件 @
5ffdfeda
...
...
@@ -111,11 +111,11 @@ void Module::AddOpDescHelper(const std::string &op_id,
switch
(
type
)
{
case
AttrType
::
INT
:
return
std
::
to_string
(
desc
.
GetAttr
<
int
>
(
name
));
return
paddle
::
lite
::
to_string
(
desc
.
GetAttr
<
int
>
(
name
));
case
AttrType
::
FLOAT
:
return
std
::
to_string
(
desc
.
GetAttr
<
float
>
(
name
));
return
paddle
::
lite
::
to_string
(
desc
.
GetAttr
<
float
>
(
name
));
case
AttrType
::
BOOLEAN
:
return
std
::
to_string
(
desc
.
GetAttr
<
bool
>
(
name
));
return
paddle
::
lite
::
to_string
(
desc
.
GetAttr
<
bool
>
(
name
));
case
AttrType
::
STRING
:
return
"
\"
"
+
desc
.
GetAttr
<
std
::
string
>
(
name
)
+
"
\"
"
;
case
AttrType
::
FLOATS
:
{
...
...
lite/gen_code/gen_code.h
浏览文件 @
5ffdfeda
...
...
@@ -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
);
...
...
lite/kernels/bm/bridges/utility.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
,
...
...
lite/kernels/npu/bridges/graph.h
浏览文件 @
5ffdfeda
...
...
@@ -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
<
T
>
(
name
+
"__"
+
std
::
to_string
(
idx
)));
node
->
set_data
(
std
::
make_shared
<
T
>
(
name
+
"__"
+
paddle
::
lite
::
to_string
(
idx
)));
return
node
;
}
...
...
lite/kernels/npu/bridges/split_op.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
<
ge
::
op
::
Add
>
(
out_name
);
auto
add_op
=
add_node
->
data
<
ge
::
op
::
Add
>
();
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
++
;
}
...
...
lite/kernels/xpu/bridges/graph.cc
浏览文件 @
5ffdfeda
...
...
@@ -49,7 +49,7 @@ std::shared_ptr<Node> Graph::Add(const std::string& name,
CHECK_GE
(
idx
,
1
);
node
->
set_data
(
std
::
make_shared
<
xtcl
::
xExpr
>
(
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
;
}
...
...
lite/model_parser/naive_buffer/naive_buffer_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
));
}
}
...
...
lite/tests/kernels/concat_compute_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -128,7 +128,7 @@ class ConcateComputeTester : public arena::TestCase {
for
(
int
i
=
0
;
i
<
x_dims_
.
production
();
i
++
)
{
x_data
[
i
]
=
static_cast
<
float
>
(
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
());
}
...
...
lite/tests/kernels/fill_constant_compute_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
));
}
}
}
...
...
lite/tests/kernels/reshape_compute_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -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"
;
...
...
lite/tests/kernels/slice_compute_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -168,8 +168,9 @@ class SliceComputeTester : public arena::TestCase {
std
::
vector
<
std
::
string
>
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
<
int
>
();
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
<
int
>
();
d
[
0
]
=
ends_
[
i
];
...
...
lite/tests/kernels/unsqueeze_compute_test.cc
浏览文件 @
5ffdfeda
...
...
@@ -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
]);
}
...
...
lite/utils/logging.h
浏览文件 @
5ffdfeda
...
...
@@ -29,6 +29,7 @@
#include <cstring>
#include <string>
#include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h"
#ifdef LITE_WITH_ANDROID
#include <android/log.h>
...
...
@@ -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
);
}
...
...
lite/utils/replace_stl/stream.cc
浏览文件 @
5ffdfeda
...
...
@@ -15,6 +15,7 @@
#include "lite/utils/replace_stl/stream.h"
#include <assert.h>
#include <stdio.h>
#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
...
...
lite/utils/string.h
浏览文件 @
5ffdfeda
...
...
@@ -48,7 +48,14 @@ template <typename T>
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
<
typename
T
>
static
std
::
string
to_string
(
const
T
&
v
)
{
STL
::
stringstream
ss
;
ss
<<
v
;
return
ss
.
str
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录