Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f1d0a8ae
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看板
未验证
提交
f1d0a8ae
编写于
11月 01, 2019
作者:
J
juncaipeng
提交者:
GitHub
11月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add int8 benchmark, test=develop (#2338)
上级
32a38a86
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
8 deletion
+19
-8
lite/api/benchmark.cc
lite/api/benchmark.cc
+11
-7
lite/tools/benchmark.sh
lite/tools/benchmark.sh
+8
-1
未找到文件。
lite/api/benchmark.cc
浏览文件 @
f1d0a8ae
...
@@ -32,7 +32,9 @@ DEFINE_string(input_shape,
...
@@ -32,7 +32,9 @@ DEFINE_string(input_shape,
DEFINE_string
(
result_filename
,
""
,
"save test result"
);
DEFINE_string
(
result_filename
,
""
,
"save test result"
);
DEFINE_bool
(
run_model_optimize
,
DEFINE_bool
(
run_model_optimize
,
false
,
false
,
"apply model_optimize_tool to model, use optimized model to test"
);
"if set true, apply model_optimize_tool to model, use optimized "
"model to test"
);
DEFINE_bool
(
is_quantized_model
,
false
,
"if set true, test the quantized model"
);
namespace
paddle
{
namespace
paddle
{
namespace
lite_api
{
namespace
lite_api
{
...
@@ -42,12 +44,14 @@ void OutputOptModel(const std::string& load_model_dir,
...
@@ -42,12 +44,14 @@ void OutputOptModel(const std::string& load_model_dir,
const
std
::
vector
<
std
::
vector
<
int64_t
>>&
input_shapes
)
{
const
std
::
vector
<
std
::
vector
<
int64_t
>>&
input_shapes
)
{
lite_api
::
CxxConfig
config
;
lite_api
::
CxxConfig
config
;
config
.
set_model_dir
(
load_model_dir
);
config
.
set_model_dir
(
load_model_dir
);
config
.
set_valid_places
({
std
::
vector
<
Place
>
vaild_places
=
{
Place
{
TARGET
(
kARM
),
PRECISION
(
kFloat
)},
Place
{
TARGET
(
kARM
),
PRECISION
(
kFloat
)},
Place
{
TARGET
(
kX86
),
PRECISION
(
kFloat
)},
Place
{
TARGET
(
kARM
),
PRECISION
(
kInt8
)},
Place
{
TARGET
(
kOpenCL
),
PRECISION
(
kFloat
)}};
Place
{
TARGET
(
kX86
),
PRECISION
(
kFloat
)},
if
(
FLAGS_is_quantized_model
)
{
Place
{
TARGET
(
kOpenCL
),
PRECISION
(
kFloat
)},
vaild_places
.
insert
(
vaild_places
.
begin
(),
});
Place
{
TARGET
(
kARM
),
PRECISION
(
kInt8
)});
}
config
.
set_valid_places
(
vaild_places
);
auto
predictor
=
lite_api
::
CreatePaddlePredictor
(
config
);
auto
predictor
=
lite_api
::
CreatePaddlePredictor
(
config
);
int
ret
=
system
(
int
ret
=
system
(
...
...
lite/tools/benchmark.sh
浏览文件 @
f1d0a8ae
...
@@ -8,6 +8,7 @@ then
...
@@ -8,6 +8,7 @@ then
echo
"Usage:"
echo
"Usage:"
echo
" sh benchmark.sh <benchmark_bin_path> <benchmark_models_path> <result_filename>"
echo
" sh benchmark.sh <benchmark_bin_path> <benchmark_models_path> <result_filename>"
echo
" sh benchmark.sh <benchmark_bin_path> <benchmark_models_path> <result_filename> <is_run_model_optimize: [true|false]>"
echo
" sh benchmark.sh <benchmark_bin_path> <benchmark_models_path> <result_filename> <is_run_model_optimize: [true|false]>"
echo
" sh benchmark.sh <benchmark_bin_path> <benchmark_models_path> <result_filename> <is_run_model_optimize: [true|false]> <is_run_quantized_model: [trur|false]>"
exit
exit
fi
fi
...
@@ -20,6 +21,7 @@ RESULT_FILENAME=$3
...
@@ -20,6 +21,7 @@ RESULT_FILENAME=$3
WARMUP
=
10
WARMUP
=
10
REPEATS
=
30
REPEATS
=
30
IS_RUN_MODEL_OPTIMIZE
=
false
IS_RUN_MODEL_OPTIMIZE
=
false
IS_RUN_QUANTIZED_MODEL
=
false
NUM_THREADS_LIST
=(
1 2 4
)
NUM_THREADS_LIST
=(
1 2 4
)
MODELS_LIST
=
$(
ls
$MODELS_DIR
)
MODELS_LIST
=
$(
ls
$MODELS_DIR
)
...
@@ -28,6 +30,10 @@ if [ $# -gt 3 ];
...
@@ -28,6 +30,10 @@ if [ $# -gt 3 ];
then
then
IS_RUN_MODEL_OPTIMIZE
=
$4
IS_RUN_MODEL_OPTIMIZE
=
$4
fi
fi
if
[
$#
-gt
4
]
;
then
IS_RUN_QUANTIZED_MODEL
=
$5
fi
# Adb push benchmark_bin, models
# Adb push benchmark_bin, models
adb push
$BENCHMARK_BIN
$ANDROID_DIR
/benchmark_bin
adb push
$BENCHMARK_BIN
$ANDROID_DIR
/benchmark_bin
...
@@ -46,7 +52,8 @@ for threads in ${NUM_THREADS_LIST[@]}; do
...
@@ -46,7 +52,8 @@ for threads in ${NUM_THREADS_LIST[@]}; do
--repeats=
$REPEATS
\
--repeats=
$REPEATS
\
--threads=
$threads
\
--threads=
$threads
\
--result_filename=
$ANDROID_DIR
/
$RESULT_FILENAME
\
--result_filename=
$ANDROID_DIR
/
$RESULT_FILENAME
\
--run_model_optimize=
$IS_RUN_MODEL_OPTIMIZE
"
--run_model_optimize=
$IS_RUN_MODEL_OPTIMIZE
\
--is_quantized_model=
$IS_RUN_QUANTIZED_MODEL
"
done
done
adb shell
"echo >>
$ANDROID_DIR
/
$RESULT_FILENAME
"
adb shell
"echo >>
$ANDROID_DIR
/
$RESULT_FILENAME
"
done
done
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录