Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1caba6ff
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
未验证
提交
1caba6ff
编写于
5月 14, 2020
作者:
H
huzhiqiang
提交者:
GitHub
5月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Framework][Internal] Add set_passes_internal inference for CxxConfig (#3623)
上级
8b100da1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
3 deletion
+26
-3
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+1
-1
lite/api/opt_base.cc
lite/api/opt_base.cc
+7
-0
lite/api/opt_base.h
lite/api/opt_base.h
+5
-1
lite/api/paddle_api.h
lite/api/paddle_api.h
+11
-1
lite/api/python/pybind/pybind.cc
lite/api/python/pybind/pybind.cc
+2
-0
未找到文件。
lite/api/cxx_api_impl.cc
浏览文件 @
1caba6ff
...
...
@@ -35,7 +35,7 @@ namespace lite {
void
CxxPaddleApiImpl
::
Init
(
const
lite_api
::
CxxConfig
&
config
)
{
config_
=
config
;
auto
places
=
config
.
valid_places
();
std
::
vector
<
std
::
string
>
passes
{}
;
std
::
vector
<
std
::
string
>
passes
=
config
.
get_passes_internal
()
;
#ifdef LITE_WITH_CUDA
// if kCUDA is included in valid places, it should be initialized first,
// otherwise skip this step.
...
...
lite/api/opt_base.cc
浏览文件 @
1caba6ff
...
...
@@ -40,6 +40,11 @@ void OptBase::SetModelType(std::string optimize_out_type) {
}
}
void
OptBase
::
SetPassesInternal
(
const
std
::
vector
<
std
::
string
>&
passes_internal
)
{
opt_config_
.
set_passes_internal
(
passes_internal
);
}
void
OptBase
::
SetValidPlaces
(
const
std
::
string
&
valid_places
)
{
valid_places_
.
clear
();
auto
target_reprs
=
lite
::
Split
(
valid_places
,
","
);
...
...
@@ -110,11 +115,13 @@ void OptBase::Run() {
void
OptBase
::
RunOptimize
(
const
std
::
string
&
model_dir_path
,
const
std
::
string
&
model_path
,
const
std
::
string
&
param_path
,
const
std
::
string
&
model_type
,
const
std
::
string
&
valid_places
,
const
std
::
string
&
optimized_out_path
)
{
SetModelDir
(
model_dir_path
);
SetModelFile
(
model_path
);
SetParamFile
(
param_path
);
SetModelType
(
model_type
);
SetValidPlaces
(
valid_places
);
SetOptimizeOut
(
optimized_out_path
);
CheckIfModelSupported
(
false
);
...
...
lite/api/opt_base.h
浏览文件 @
1caba6ff
...
...
@@ -51,12 +51,16 @@ class LITE_API OptBase {
void
SetOptimizeOut
(
const
std
::
string
&
lite_out_name
);
void
RecordModelInfo
(
bool
record_strip_info
=
true
);
// set optimized_model type
void
SetModelType
(
std
::
string
model_type
);
void
SetModelType
(
std
::
string
model_type
=
"naive_buffer"
);
// internal inference for developer, not recommanded.
// choose methods of model optimizing.
void
SetPassesInternal
(
const
std
::
vector
<
std
::
string
>
&
passes_internal
=
{});
// transform and save the optimized model
void
Run
();
void
RunOptimize
(
const
std
::
string
&
model_dir_path
=
""
,
const
std
::
string
&
model_path
=
""
,
const
std
::
string
&
param_path
=
""
,
const
std
::
string
&
model_type
=
""
,
const
std
::
string
&
valid_places
=
""
,
const
std
::
string
&
optimized_out_path
=
""
);
// fuctions of printing info
...
...
lite/api/paddle_api.h
浏览文件 @
1caba6ff
...
...
@@ -137,6 +137,7 @@ class LITE_API CxxConfig : public ConfigBase {
std
::
vector
<
Place
>
valid_places_
;
std
::
string
model_file_
;
std
::
string
param_file_
;
std
::
vector
<
std
::
string
>
passes_internal_
{};
bool
model_from_memory_
{
false
};
#ifdef LITE_WITH_X86
int
x86_math_library_math_threads_
=
1
;
...
...
@@ -165,7 +166,16 @@ class LITE_API CxxConfig : public ConfigBase {
param_file_
=
std
::
string
(
param_buffer
,
param_buffer
+
param_buffer_size
);
model_from_memory_
=
true
;
}
// internal inference to choose passes for model optimizing,
// it's designed for internal developer and not recommanded
// for comman users.
void
set_passes_internal
(
const
std
::
vector
<
std
::
string
>&
passes_internal
=
{})
{
passes_internal_
=
passes_internal
;
}
const
std
::
vector
<
std
::
string
>&
get_passes_internal
()
const
{
return
passes_internal_
;
}
const
std
::
vector
<
Place
>&
valid_places
()
const
{
return
valid_places_
;
}
std
::
string
model_file
()
const
{
return
model_file_
;
}
std
::
string
param_file
()
const
{
return
param_file_
;
}
...
...
lite/api/python/pybind/pybind.cc
浏览文件 @
1caba6ff
...
...
@@ -65,6 +65,7 @@ void BindLiteOpt(py::module *m) {
.
def
(
"set_optimize_out"
,
&
OptBase
::
SetOptimizeOut
)
.
def
(
"set_model_type"
,
&
OptBase
::
SetModelType
)
.
def
(
"record_model_info"
,
&
OptBase
::
RecordModelInfo
)
.
def
(
"set_passes_internal"
,
&
OptBase
::
SetPassesInternal
)
.
def
(
"run"
,
&
OptBase
::
Run
)
.
def
(
"run_optimize"
,
&
OptBase
::
RunOptimize
)
.
def
(
"help"
,
&
OptBase
::
PrintHelpInfo
)
...
...
@@ -124,6 +125,7 @@ void BindLiteCxxConfig(py::module *m) {
.
def
(
"param_file"
,
&
CxxConfig
::
param_file
)
.
def
(
"set_valid_places"
,
&
CxxConfig
::
set_valid_places
)
.
def
(
"set_model_buffer"
,
&
CxxConfig
::
set_model_buffer
)
.
def
(
"set_passes_internal"
,
&
CxxConfig
::
set_passes_internal
)
.
def
(
"model_from_memory"
,
&
CxxConfig
::
model_from_memory
);
#ifdef LITE_WITH_ARM
cxx_config
.
def
(
"set_threads"
,
&
CxxConfig
::
set_threads
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录