Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
7bca11ca
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7bca11ca
编写于
5月 12, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ir optim for cpu
上级
082fedde
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
1 deletion
+37
-1
core/configure/proto/server_configure.proto
core/configure/proto/server_configure.proto
+1
-0
core/predictor/framework/infer.h
core/predictor/framework/infer.h
+14
-0
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
...inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
+6
-0
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
...inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
+6
-0
python/paddle_serving_server/__init__.py
python/paddle_serving_server/__init__.py
+6
-1
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+4
-0
未找到文件。
core/configure/proto/server_configure.proto
浏览文件 @
7bca11ca
...
...
@@ -43,6 +43,7 @@ message EngineDesc {
optional
bool
enable_memory_optimization
=
13
;
optional
bool
static_optimization
=
14
;
optional
bool
force_update_static_cache
=
15
;
optional
bool
enable_ir_optimization
=
16
;
};
// model_toolkit conf
...
...
core/predictor/framework/infer.h
浏览文件 @
7bca11ca
...
...
@@ -35,6 +35,7 @@ class InferEngineCreationParams {
InferEngineCreationParams
()
{
_path
=
""
;
_enable_memory_optimization
=
false
;
_enable_ir_optimization
=
false
;
_static_optimization
=
false
;
_force_update_static_cache
=
false
;
}
...
...
@@ -45,10 +46,16 @@ class InferEngineCreationParams {
_enable_memory_optimization
=
enable_memory_optimization
;
}
void
set_enable_ir_optimization
(
bool
enable_ir_optimization
)
{
_enable_ir_optimization
=
enable_ir_optimization
;
}
bool
enable_memory_optimization
()
const
{
return
_enable_memory_optimization
;
}
bool
enable_ir_optimization
()
const
{
return
_enable_ir_optimization
;
}
void
set_static_optimization
(
bool
static_optimization
=
false
)
{
_static_optimization
=
static_optimization
;
}
...
...
@@ -68,6 +75,7 @@ class InferEngineCreationParams {
<<
"model_path = "
<<
_path
<<
", "
<<
"enable_memory_optimization = "
<<
_enable_memory_optimization
<<
", "
<<
"enable_ir_optimization = "
<<
_enable_ir_optimization
<<
", "
<<
"static_optimization = "
<<
_static_optimization
<<
", "
<<
"force_update_static_cache = "
<<
_force_update_static_cache
;
}
...
...
@@ -75,6 +83,7 @@ class InferEngineCreationParams {
private:
std
::
string
_path
;
bool
_enable_memory_optimization
;
bool
_enable_ir_optimization
;
bool
_static_optimization
;
bool
_force_update_static_cache
;
};
...
...
@@ -150,6 +159,11 @@ class ReloadableInferEngine : public InferEngine {
force_update_static_cache
=
conf
.
force_update_static_cache
();
}
if
(
conf
.
has_enable_ir_optimization
())
{
_infer_engine_params
.
set_enable_ir_optimization
(
conf
.
enable_ir_optimization
());
}
_infer_engine_params
.
set_path
(
_model_data_path
);
if
(
enable_memory_optimization
)
{
_infer_engine_params
.
set_enable_memory_optimization
(
true
);
...
...
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
7bca11ca
...
...
@@ -194,6 +194,12 @@ class FluidCpuAnalysisDirCore : public FluidFamilyCore {
analysis_config
.
EnableMemoryOptim
();
}
if
(
params
.
enable_ir_optimization
())
{
analysis_config
.
SwitchIrOptim
(
true
);
}
else
{
analysis_config
.
SwitchIrOptim
(
false
);
}
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
_core
=
paddle
::
CreatePaddlePredictor
<
paddle
::
AnalysisConfig
>
(
analysis_config
);
...
...
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
浏览文件 @
7bca11ca
...
...
@@ -198,6 +198,12 @@ class FluidGpuAnalysisDirCore : public FluidFamilyCore {
analysis_config
.
EnableMemoryOptim
();
}
if
(
params
.
enable_ir_optimization
())
{
analysis_config
.
SwitchIrOptim
(
true
);
}
else
{
analysis_config
.
SwitchIrOptim
(
false
);
}
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
_core
=
paddle
::
CreatePaddlePredictor
<
paddle
::
AnalysisConfig
>
(
analysis_config
);
...
...
python/paddle_serving_server/__init__.py
浏览文件 @
7bca11ca
...
...
@@ -127,6 +127,7 @@ class Server(object):
self
.
model_toolkit_conf
=
None
self
.
resource_conf
=
None
self
.
memory_optimization
=
False
self
.
ir_optimization
=
False
self
.
model_conf
=
None
self
.
workflow_fn
=
"workflow.prototxt"
self
.
resource_fn
=
"resource.prototxt"
...
...
@@ -175,6 +176,9 @@ class Server(object):
def
set_memory_optimize
(
self
,
flag
=
False
):
self
.
memory_optimization
=
flag
def
set_ir_optimize
(
self
,
flag
=
False
):
self
.
ir_optimization
=
flag
def
check_local_bin
(
self
):
if
"SERVING_BIN"
in
os
.
environ
:
self
.
use_local_bin
=
True
...
...
@@ -195,6 +199,7 @@ class Server(object):
engine
.
enable_batch_align
=
0
engine
.
model_data_path
=
model_config_path
engine
.
enable_memory_optimization
=
self
.
memory_optimization
engine
.
enable_ir_optimization
=
self
.
ir_optimization
engine
.
static_optimization
=
False
engine
.
force_update_static_cache
=
False
...
...
@@ -244,7 +249,7 @@ class Server(object):
workflow_oi_config_path
=
None
if
isinstance
(
model_config_paths
,
str
):
# If there is only one model path, use the default infer_op.
# Because there are several infer_op type, we need to find
# Because there are several infer_op type, we need to find
# it from workflow_conf.
default_engine_names
=
[
'general_infer_0'
,
'general_dist_kv_infer_0'
,
...
...
python/paddle_serving_server/serve.py
浏览文件 @
7bca11ca
...
...
@@ -41,6 +41,8 @@ def parse_args(): # pylint: disable=doc-string-missing
"--device"
,
type
=
str
,
default
=
"cpu"
,
help
=
"Type of device"
)
parser
.
add_argument
(
"--mem_optim"
,
type
=
bool
,
default
=
False
,
help
=
"Memory optimize"
)
parser
.
add_argument
(
"--ir_optim"
,
type
=
bool
,
default
=
False
,
help
=
"Graph optimize"
)
parser
.
add_argument
(
"--max_body_size"
,
type
=
int
,
...
...
@@ -57,6 +59,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
workdir
=
args
.
workdir
device
=
args
.
device
mem_optim
=
args
.
mem_optim
ir_optim
=
args
.
ir_optim
max_body_size
=
args
.
max_body_size
if
model
==
""
:
...
...
@@ -78,6 +81,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_num_threads
(
thread_num
)
server
.
set_memory_optimize
(
mem_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_port
(
port
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录