Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5c98e002
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看板
提交
5c98e002
编写于
9月 25, 2019
作者:
X
Xiaoyang LI
提交者:
Yan Chunwei
9月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix MobileConfig get mode and threads error (#2134)
上级
845af6e0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
44 addition
and
29 deletion
+44
-29
lite/api/CMakeLists.txt
lite/api/CMakeLists.txt
+16
-16
lite/api/light_api_impl.cc
lite/api/light_api_impl.cc
+25
-5
lite/api/paddle_api.h
lite/api/paddle_api.h
+3
-8
未找到文件。
lite/api/CMakeLists.txt
浏览文件 @
5c98e002
...
...
@@ -176,22 +176,6 @@ if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND WITH_TESTING)
# FPGA_DEPS ${fpga_kernels})
endif
()
# These tests needs CLI arguments, and is not supported in ARM CI.
# TODO(Superjomn) support latter.
lite_cc_test
(
test_light_api SRCS light_api_test.cc
DEPS light_api program mir_passes
CL_DEPS
${
opencl_kernels
}
FPGA_DEPS
${
fpga_kernels
}
ARGS --optimized_model=
${
LITE_MODEL_DIR
}
/lite_naive_model_opt SERIAL
)
lite_cc_test
(
test_apis SRCS apis_test.cc
DEPS cxx_api light_api
${
ops
}
CL_DEPS
${
opencl_kernels
}
X86_DEPS
${
x86_kernels
}
FPGA_DEPS
${
fpga_kernels
}
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/lite_naive_model
--optimized_model=
${
LITE_MODEL_DIR
}
/lite_naive_model_opt SERIAL
)
lite_cc_library
(
paddle_api SRCS paddle_api.cc DEPS op_params tensor
)
#-----------------------------------------------------------------------------------------------------
...
...
@@ -216,6 +200,22 @@ endif()
bundle_static_library
(
paddle_api_light paddle_api_light_bundled bundle_light_api
)
#-----------------------------------------------------------------------------------------------------
# These tests needs CLI arguments, and is not supported in ARM CI.
# TODO(Superjomn) support latter.
lite_cc_test
(
test_light_api SRCS light_api_test.cc
DEPS light_api program mir_passes paddle_api_light
CL_DEPS
${
opencl_kernels
}
FPGA_DEPS
${
fpga_kernels
}
ARGS --optimized_model=
${
LITE_MODEL_DIR
}
/lite_naive_model_opt SERIAL
)
lite_cc_test
(
test_apis SRCS apis_test.cc
DEPS cxx_api light_api
${
ops
}
paddle_api_light
CL_DEPS
${
opencl_kernels
}
X86_DEPS
${
x86_kernels
}
FPGA_DEPS
${
fpga_kernels
}
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/lite_naive_model
--optimized_model=
${
LITE_MODEL_DIR
}
/lite_naive_model_opt SERIAL
)
if
(
LITE_WITH_JAVA AND LITE_WITH_ARM
)
add_subdirectory
(
android
)
endif
()
...
...
lite/api/light_api_impl.cc
浏览文件 @
5c98e002
...
...
@@ -43,11 +43,7 @@ class LightPredictorImpl : public PaddlePredictor {
};
void
LightPredictorImpl
::
Init
(
const
MobileConfig
&
config
)
{
// LightPredictor Only support NaiveBuffer backend in publish lib
#ifdef LITE_WITH_ARM
lite
::
DeviceInfo
::
Init
();
lite
::
DeviceInfo
::
Global
().
SetRunMode
(
config
.
power_mode
(),
config
.
threads
());
#endif
// LightPredictor Only support NaiveBuffer backend in publish lib
raw_predictor_
.
reset
(
new
lite
::
LightPredictor
(
config
.
model_dir
(),
config
.
model_buffer
(),
config
.
param_buffer
(),
...
...
@@ -81,5 +77,29 @@ std::shared_ptr<PaddlePredictor> CreatePaddlePredictor(
return
x
;
}
MobileConfig
::
MobileConfig
(
PowerMode
mode
,
int
threads
)
{
#ifdef LITE_WITH_ARM
lite
::
DeviceInfo
::
Global
().
SetRunMode
(
mode
,
threads
);
mode_
=
lite
::
DeviceInfo
::
Global
().
mode
();
threads_
=
lite
::
DeviceInfo
::
Global
().
threads
();
#endif
}
void
MobileConfig
::
set_power_mode
(
paddle
::
lite_api
::
PowerMode
mode
)
{
#ifdef LITE_WITH_ARM
lite
::
DeviceInfo
::
Global
().
SetRunMode
(
mode
,
threads_
);
mode_
=
lite
::
DeviceInfo
::
Global
().
mode
();
threads_
=
lite
::
DeviceInfo
::
Global
().
threads
();
#endif
}
void
MobileConfig
::
set_threads
(
int
threads
)
{
#ifdef LITE_WITH_ARM
lite
::
DeviceInfo
::
Global
().
SetRunMode
(
mode_
,
threads
);
mode_
=
lite
::
DeviceInfo
::
Global
().
mode
();
threads_
=
lite
::
DeviceInfo
::
Global
().
threads
();
#endif
}
}
// namespace lite_api
}
// namespace paddle
lite/api/paddle_api.h
浏览文件 @
5c98e002
...
...
@@ -136,14 +136,9 @@ class LITE_API MobileConfig : public ConfigBase {
bool
model_from_memory_
{
false
};
public:
MobileConfig
(
Place
preferred_place
=
Place
(
TARGET
(
kARM
),
PRECISION
(
kFloat
),
DATALAYOUT
(
kNCHW
)),
PowerMode
mode
=
LITE_POWER_HIGH
,
int
threads
=
1
)
:
mode_
(
mode
),
threads_
(
threads
)
{}
void
set_power_mode
(
PowerMode
mode
)
{
mode_
=
mode
;
}
void
set_threads
(
int
threads
)
{
threads_
=
threads
;
}
explicit
MobileConfig
(
PowerMode
mode
=
LITE_POWER_NO_BIND
,
int
threads
=
1
);
void
set_power_mode
(
PowerMode
mode
);
void
set_threads
(
int
threads
);
void
set_model_buffer
(
const
char
*
model_buffer
,
size_t
model_buffer_size
,
const
char
*
param_buffer
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录