Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
2c73d5ce
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看板
未验证
提交
2c73d5ce
编写于
5月 12, 2022
作者:
S
ShiningZhang
提交者:
GitHub
5月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1778 from ShiningZhang/dev
add tuned_dynamic_shape_info for pipeline
上级
86dcf947
4164ad25
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
11 deletion
+52
-11
python/paddle_serving_app/local_predict.py
python/paddle_serving_app/local_predict.py
+13
-4
python/pipeline/local_service_handler.py
python/pipeline/local_service_handler.py
+14
-4
python/pipeline/operator.py
python/pipeline/operator.py
+19
-3
python/pipeline/pipeline_server.py
python/pipeline/pipeline_server.py
+6
-0
未找到文件。
python/paddle_serving_app/local_predict.py
浏览文件 @
2c73d5ce
...
@@ -93,7 +93,9 @@ class LocalPredictor(object):
...
@@ -93,7 +93,9 @@ class LocalPredictor(object):
use_ascend_cl
=
False
,
use_ascend_cl
=
False
,
min_subgraph_size
=
3
,
min_subgraph_size
=
3
,
dynamic_shape_info
=
{},
dynamic_shape_info
=
{},
use_calib
=
False
):
use_calib
=
False
,
collect_shape_range_info
=
""
,
tuned_dynamic_shape_info
=
""
):
"""
"""
Load model configs and create the paddle predictor by Paddle Inference API.
Load model configs and create the paddle predictor by Paddle Inference API.
...
@@ -160,12 +162,14 @@ class LocalPredictor(object):
...
@@ -160,12 +162,14 @@ class LocalPredictor(object):
"use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, "
"use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{}"
.
"use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{},"
"collect_shape_range_info:{},tuned_dynamic_shape_info:{}"
.
format
(
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_num
,
format
(
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_num
,
mem_optim
,
ir_optim
,
use_trt
,
use_lite
,
use_xpu
,
precision
,
mem_optim
,
ir_optim
,
use_trt
,
use_lite
,
use_xpu
,
precision
,
use_calib
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
use_calib
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
use_feed_fetch_ops
,
use_ascend_cl
,
mkldnn_bf16_op_list
,
use_feed_fetch_ops
,
use_ascend_cl
,
min_subgraph_size
,
dynamic_shape_info
))
min_subgraph_size
,
dynamic_shape_info
,
collect_shape_range_info
,
tuned_dynamic_shape_info
))
self
.
feed_names_
=
[
var
.
alias_name
for
var
in
model_conf
.
feed_var
]
self
.
feed_names_
=
[
var
.
alias_name
for
var
in
model_conf
.
feed_var
]
self
.
fetch_names_
=
[
var
.
alias_name
for
var
in
model_conf
.
fetch_var
]
self
.
fetch_names_
=
[
var
.
alias_name
for
var
in
model_conf
.
fetch_var
]
...
@@ -213,6 +217,8 @@ class LocalPredictor(object):
...
@@ -213,6 +217,8 @@ class LocalPredictor(object):
if
mkldnn_op_list
is
not
None
:
if
mkldnn_op_list
is
not
None
:
config
.
set_mkldnn_op
(
mkldnn_op_list
)
config
.
set_mkldnn_op
(
mkldnn_op_list
)
# set gpu
# set gpu
if
collect_shape_range_info
!=
""
:
config
.
collect_shape_range_info
(
collect_shape_range_info
)
if
not
use_gpu
:
if
not
use_gpu
:
config
.
disable_gpu
()
config
.
disable_gpu
()
else
:
else
:
...
@@ -226,6 +232,9 @@ class LocalPredictor(object):
...
@@ -226,6 +232,9 @@ class LocalPredictor(object):
use_static
=
False
,
use_static
=
False
,
use_calib_mode
=
use_calib
)
use_calib_mode
=
use_calib
)
if
tuned_dynamic_shape_info
!=
""
:
config
.
enable_tuned_tensorrt_dynamic_shape
(
tuned_dynamic_shape_info
,
True
)
@
ErrorCatch
@
ErrorCatch
@
ParamChecker
@
ParamChecker
def
dynamic_shape_info_helper
(
dynamic_shape_info
:
lambda
dynamic_shape_info
:
check_dynamic_shape_info
(
dynamic_shape_info
)):
def
dynamic_shape_info_helper
(
dynamic_shape_info
:
lambda
dynamic_shape_info
:
check_dynamic_shape_info
(
dynamic_shape_info
)):
...
@@ -235,7 +244,7 @@ class LocalPredictor(object):
...
@@ -235,7 +244,7 @@ class LocalPredictor(object):
print
(
"dynamic_shape_info configure error, it should contain [min_input_shape', 'max_input_shape', 'opt_input_shape' {}"
.
format
(
resp
.
err_msg
))
print
(
"dynamic_shape_info configure error, it should contain [min_input_shape', 'max_input_shape', 'opt_input_shape' {}"
.
format
(
resp
.
err_msg
))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
if
len
(
dynamic_shape_info
):
if
len
(
dynamic_shape_info
)
and
tuned_dynamic_shape_info
==
""
:
config
.
set_trt_dynamic_shape_info
(
config
.
set_trt_dynamic_shape_info
(
dynamic_shape_info
[
'min_input_shape'
],
dynamic_shape_info
[
'min_input_shape'
],
dynamic_shape_info
[
'max_input_shape'
],
dynamic_shape_info
[
'max_input_shape'
],
...
...
python/pipeline/local_service_handler.py
浏览文件 @
2c73d5ce
...
@@ -53,7 +53,9 @@ class LocalServiceHandler(object):
...
@@ -53,7 +53,9 @@ class LocalServiceHandler(object):
mkldnn_bf16_op_list
=
None
,
mkldnn_bf16_op_list
=
None
,
min_subgraph_size
=
3
,
min_subgraph_size
=
3
,
dynamic_shape_info
=
{},
dynamic_shape_info
=
{},
use_calib
=
False
):
use_calib
=
False
,
collect_shape_range_info
=
""
,
tuned_dynamic_shape_info
=
""
):
"""
"""
Initialization of localservicehandler
Initialization of localservicehandler
...
@@ -99,6 +101,8 @@ class LocalServiceHandler(object):
...
@@ -99,6 +101,8 @@ class LocalServiceHandler(object):
self
.
min_subgraph_size
=
3
self
.
min_subgraph_size
=
3
self
.
dynamic_shape_info
=
{}
self
.
dynamic_shape_info
=
{}
self
.
_use_calib
=
False
self
.
_use_calib
=
False
self
.
collect_shape_range_info
=
""
self
.
tuned_dynamic_shape_info
=
""
if
device_type
==
-
1
:
if
device_type
==
-
1
:
# device_type is not set, determined by `devices`,
# device_type is not set, determined by `devices`,
...
@@ -179,6 +183,8 @@ class LocalServiceHandler(object):
...
@@ -179,6 +183,8 @@ class LocalServiceHandler(object):
self
.
_mkldnn_op_list
=
mkldnn_op_list
self
.
_mkldnn_op_list
=
mkldnn_op_list
self
.
_mkldnn_bf16_op_list
=
mkldnn_bf16_op_list
self
.
_mkldnn_bf16_op_list
=
mkldnn_bf16_op_list
self
.
_use_calib
=
use_calib
self
.
_use_calib
=
use_calib
self
.
collect_shape_range_info
=
collect_shape_range_info
self
.
tuned_dynamic_shape_info
=
tuned_dynamic_shape_info
_LOGGER
.
info
(
_LOGGER
.
info
(
"Models({}) will be launched by device {}. use_gpu:{}, "
"Models({}) will be launched by device {}. use_gpu:{}, "
...
@@ -187,14 +193,16 @@ class LocalServiceHandler(object):
...
@@ -187,14 +193,16 @@ class LocalServiceHandler(object):
"client_type:{}, fetch_names:{}, precision:{}, use_calib:{}, "
"client_type:{}, fetch_names:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{},"
"mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{},"
"is_set_dynamic_shape_info:{}"
.
format
(
"is_set_dynamic_shape_info:{},collect_shape_range_info:{},"
"tuned_dynamic_shape_info:{}"
.
format
(
model_config
,
self
.
_device_name
,
self
.
_use_gpu
,
self
.
_use_trt
,
model_config
,
self
.
_device_name
,
self
.
_use_gpu
,
self
.
_use_trt
,
self
.
_use_lite
,
self
.
_use_xpu
,
device_type
,
self
.
_devices
,
self
.
self
.
_use_lite
,
self
.
_use_xpu
,
device_type
,
self
.
_devices
,
self
.
_mem_optim
,
self
.
_ir_optim
,
self
.
_use_profile
,
self
.
_thread_num
,
_mem_optim
,
self
.
_ir_optim
,
self
.
_use_profile
,
self
.
_thread_num
,
self
.
_client_type
,
self
.
_fetch_names
,
self
.
_precision
,
self
.
self
.
_client_type
,
self
.
_fetch_names
,
self
.
_precision
,
self
.
_use_calib
,
self
.
_use_mkldnn
,
self
.
_mkldnn_cache_capacity
,
self
.
_use_calib
,
self
.
_use_mkldnn
,
self
.
_mkldnn_cache_capacity
,
self
.
_mkldnn_op_list
,
self
.
_mkldnn_bf16_op_list
,
self
.
_use_ascend_cl
,
_mkldnn_op_list
,
self
.
_mkldnn_bf16_op_list
,
self
.
_use_ascend_cl
,
self
.
min_subgraph_size
,
bool
(
len
(
self
.
dynamic_shape_info
))))
self
.
min_subgraph_size
,
bool
(
len
(
self
.
dynamic_shape_info
)),
self
.
collect_shape_range_info
,
self
.
tuned_dynamic_shape_info
))
def
get_fetch_list
(
self
):
def
get_fetch_list
(
self
):
return
self
.
_fetch_names
return
self
.
_fetch_names
...
@@ -254,7 +262,9 @@ class LocalServiceHandler(object):
...
@@ -254,7 +262,9 @@ class LocalServiceHandler(object):
use_ascend_cl
=
self
.
_use_ascend_cl
,
use_ascend_cl
=
self
.
_use_ascend_cl
,
min_subgraph_size
=
self
.
min_subgraph_size
,
min_subgraph_size
=
self
.
min_subgraph_size
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
use_calib
=
self
.
_use_calib
)
use_calib
=
self
.
_use_calib
,
collect_shape_range_info
=
self
.
collect_shape_range_info
,
tuned_dynamic_shape_info
=
self
.
tuned_dynamic_shape_info
)
return
self
.
_local_predictor_client
return
self
.
_local_predictor_client
def
get_client_config
(
self
):
def
get_client_config
(
self
):
...
...
python/pipeline/operator.py
浏览文件 @
2c73d5ce
...
@@ -121,6 +121,8 @@ class Op(object):
...
@@ -121,6 +121,8 @@ class Op(object):
self
.
_succ_close_op
=
False
self
.
_succ_close_op
=
False
self
.
dynamic_shape_info
=
{}
self
.
dynamic_shape_info
=
{}
self
.
set_dynamic_shape_info
()
self
.
set_dynamic_shape_info
()
self
.
collect_shape_range_info
=
""
self
.
tuned_dynamic_shape_info
=
""
def
set_dynamic_shape_info
(
self
):
def
set_dynamic_shape_info
(
self
):
"""
"""
...
@@ -235,6 +237,14 @@ class Op(object):
...
@@ -235,6 +237,14 @@ class Op(object):
"mkldnn_bf16_op_list"
)
"mkldnn_bf16_op_list"
)
self
.
min_subgraph_size
=
local_service_conf
.
get
(
self
.
min_subgraph_size
=
local_service_conf
.
get
(
"min_subgraph_size"
)
"min_subgraph_size"
)
self
.
collect_shape_range_info
=
local_service_conf
.
get
(
"collect_shape_range_info"
)
self
.
tuned_dynamic_shape_info
=
local_service_conf
.
get
(
"tuned_dynamic_shape_info"
)
if
self
.
collect_shape_range_info
is
None
:
self
.
collect_shape_range_info
=
""
if
self
.
tuned_dynamic_shape_info
is
None
:
self
.
tuned_dynamic_shape_info
=
""
if
self
.
model_config
is
None
:
if
self
.
model_config
is
None
:
self
.
with_serving
=
False
self
.
with_serving
=
False
...
@@ -259,7 +269,9 @@ class Op(object):
...
@@ -259,7 +269,9 @@ class Op(object):
mkldnn_bf16_op_list
=
self
.
mkldnn_bf16_op_list
,
mkldnn_bf16_op_list
=
self
.
mkldnn_bf16_op_list
,
min_subgraph_size
=
self
.
min_subgraph_size
,
min_subgraph_size
=
self
.
min_subgraph_size
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
use_calib
=
self
.
use_calib
)
use_calib
=
self
.
use_calib
,
collect_shape_range_info
=
self
.
collect_shape_range_info
,
tuned_dynamic_shape_info
=
self
.
tuned_dynamic_shape_info
)
service_handler
.
prepare_server
()
# get fetch_list
service_handler
.
prepare_server
()
# get fetch_list
serivce_ports
=
service_handler
.
get_port_list
()
serivce_ports
=
service_handler
.
get_port_list
()
self
.
_server_endpoints
=
[
self
.
_server_endpoints
=
[
...
@@ -290,7 +302,9 @@ class Op(object):
...
@@ -290,7 +302,9 @@ class Op(object):
mkldnn_bf16_op_list
=
self
.
mkldnn_bf16_op_list
,
mkldnn_bf16_op_list
=
self
.
mkldnn_bf16_op_list
,
min_subgraph_size
=
self
.
min_subgraph_size
,
min_subgraph_size
=
self
.
min_subgraph_size
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
dynamic_shape_info
=
self
.
dynamic_shape_info
,
use_calib
=
self
.
use_calib
)
use_calib
=
self
.
use_calib
,
collect_shape_range_info
=
self
.
collect_shape_range_info
,
tuned_dynamic_shape_info
=
self
.
tuned_dynamic_shape_info
)
if
self
.
_client_config
is
None
:
if
self
.
_client_config
is
None
:
self
.
_client_config
=
service_handler
.
get_client_config
(
self
.
_client_config
=
service_handler
.
get_client_config
(
)
)
...
@@ -1387,7 +1401,9 @@ class Op(object):
...
@@ -1387,7 +1401,9 @@ class Op(object):
mkldnn_bf16_op_list
=
mkldnn_bf16_op_list
,
mkldnn_bf16_op_list
=
mkldnn_bf16_op_list
,
min_subgraph_size
=
min_subgraph_size
,
min_subgraph_size
=
min_subgraph_size
,
dynamic_shape_info
=
dynamic_shape_info
,
dynamic_shape_info
=
dynamic_shape_info
,
use_calib
=
use_calib
)
use_calib
=
use_calib
,
collect_shape_range_info
=
self
.
collect_shape_range_info
,
tuned_dynamic_shape_info
=
self
.
tuned_dynamic_shape_info
)
_LOGGER
.
info
(
"Init cuda env in process {}"
.
format
(
_LOGGER
.
info
(
"Init cuda env in process {}"
.
format
(
concurrency_idx
))
concurrency_idx
))
...
...
python/pipeline/pipeline_server.py
浏览文件 @
2c73d5ce
...
@@ -261,6 +261,8 @@ class PipelineServer(object):
...
@@ -261,6 +261,8 @@ class PipelineServer(object):
"use_mkldnn"
:
False
,
"use_mkldnn"
:
False
,
"mkldnn_cache_capacity"
:
0
,
"mkldnn_cache_capacity"
:
0
,
"min_subgraph_size"
:
3
,
"min_subgraph_size"
:
3
,
"collect_shape_range_info"
:
""
,
"tuned_dynamic_shape_info"
:
""
,
},
},
}
}
for
op
in
self
.
_used_op
:
for
op
in
self
.
_used_op
:
...
@@ -422,6 +424,8 @@ class ServerYamlConfChecker(object):
...
@@ -422,6 +424,8 @@ class ServerYamlConfChecker(object):
"use_mkldnn"
:
False
,
"use_mkldnn"
:
False
,
"mkldnn_cache_capacity"
:
0
,
"mkldnn_cache_capacity"
:
0
,
"min_subgraph_size"
:
3
,
"min_subgraph_size"
:
3
,
"collect_shape_range_info"
:
""
,
"tuned_dynamic_shape_info"
:
""
,
}
}
conf_type
=
{
conf_type
=
{
"model_config"
:
str
,
"model_config"
:
str
,
...
@@ -438,6 +442,8 @@ class ServerYamlConfChecker(object):
...
@@ -438,6 +442,8 @@ class ServerYamlConfChecker(object):
"mkldnn_op_list"
:
list
,
"mkldnn_op_list"
:
list
,
"mkldnn_bf16_op_list"
:
list
,
"mkldnn_bf16_op_list"
:
list
,
"min_subgraph_size"
:
int
,
"min_subgraph_size"
:
int
,
"collect_shape_range_info"
:
str
,
"tuned_dynamic_shape_info"
:
str
,
}
}
conf_qualification
=
{
"thread_num"
:
(
">="
,
1
),
}
conf_qualification
=
{
"thread_num"
:
(
">="
,
1
),
}
ServerYamlConfChecker
.
check_conf
(
conf
,
default_conf
,
conf_type
,
ServerYamlConfChecker
.
check_conf
(
conf
,
default_conf
,
conf_type
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录