Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
19dea60d
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 2 年 前同步成功
通知
187
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看板
提交
19dea60d
编写于
4月 02, 2022
作者:
T
TeslaZhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix one bad explaination
上级
dc512ce7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
109 addition
and
86 deletion
+109
-86
python/pipeline/operator.py
python/pipeline/operator.py
+109
-86
未找到文件。
python/pipeline/operator.py
浏览文件 @
19dea60d
...
@@ -35,10 +35,10 @@ else:
...
@@ -35,10 +35,10 @@ else:
raise
Exception
(
"Error Python version"
)
raise
Exception
(
"Error Python version"
)
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
from
.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
check_feed_dict
=
ParamVerify
.
check_feed_dict
check_feed_dict
=
ParamVerify
.
check_feed_dict
check_fetch_list
=
ParamVerify
.
check_fetch_list
check_fetch_list
=
ParamVerify
.
check_fetch_list
from
.proto
import
pipeline_service_pb2
from
.proto
import
pipeline_service_pb2
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
ChannelDataType
,
ChannelStopError
,
ChannelTimeoutError
)
ChannelDataType
,
ChannelStopError
,
ChannelTimeoutError
)
from
.error_catch
import
ProductErrCode
from
.error_catch
import
ProductErrCode
from
.error_catch
import
CustomExceptionCode
as
ChannelDataErrcode
from
.error_catch
import
CustomExceptionCode
as
ChannelDataErrcode
...
@@ -142,7 +142,6 @@ class Op(object):
...
@@ -142,7 +142,6 @@ class Op(object):
fetch_names
=
client
.
fetch_names_
fetch_names
=
client
.
fetch_names_
return
feed_names
,
fetch_names
return
feed_names
,
fetch_names
def
init_from_dict
(
self
,
conf
):
def
init_from_dict
(
self
,
conf
):
"""
"""
Initializing one Op from config.yaml. If server_endpoints exist,
Initializing one Op from config.yaml. If server_endpoints exist,
...
@@ -164,9 +163,10 @@ class Op(object):
...
@@ -164,9 +163,10 @@ class Op(object):
if
self
.
_client_config
is
None
:
if
self
.
_client_config
is
None
:
self
.
_client_config
=
conf
.
get
(
"client_config"
)
self
.
_client_config
=
conf
.
get
(
"client_config"
)
if
self
.
_use_encryption_model
is
None
:
if
self
.
_use_encryption_model
is
None
:
print
(
"config use_encryption model here"
,
conf
.
get
(
"use_encryption_model"
))
print
(
"config use_encryption model here"
,
conf
.
get
(
"use_encryption_model"
))
self
.
_use_encryption_model
=
conf
.
get
(
"use_encryption_model"
)
self
.
_use_encryption_model
=
conf
.
get
(
"use_encryption_model"
)
if
self
.
_encryption_key
is
None
or
self
.
_encryption_key
==
""
:
if
self
.
_encryption_key
is
None
or
self
.
_encryption_key
==
""
:
self
.
_encryption_key
=
conf
.
get
(
"encryption_key"
)
self
.
_encryption_key
=
conf
.
get
(
"encryption_key"
)
if
self
.
_timeout
is
None
:
if
self
.
_timeout
is
None
:
self
.
_timeout
=
conf
[
"timeout"
]
self
.
_timeout
=
conf
[
"timeout"
]
...
@@ -401,14 +401,16 @@ class Op(object):
...
@@ -401,14 +401,16 @@ class Op(object):
if
self
.
client_type
==
'brpc'
:
if
self
.
client_type
==
'brpc'
:
client
=
Client
()
client
=
Client
()
client
.
load_client_config
(
client_config
)
client
.
load_client_config
(
client_config
)
self
.
right_feed_names
,
self
.
right_fetch_names
=
self
.
get_feed_fetch_list
(
client
)
self
.
right_feed_names
,
self
.
right_fetch_names
=
self
.
get_feed_fetch_list
(
client
)
elif
self
.
client_type
==
'pipeline_grpc'
:
elif
self
.
client_type
==
'pipeline_grpc'
:
client
=
PPClient
()
client
=
PPClient
()
elif
self
.
client_type
==
'local_predictor'
:
elif
self
.
client_type
==
'local_predictor'
:
if
self
.
local_predictor
is
None
:
if
self
.
local_predictor
is
None
:
raise
ValueError
(
"local predictor not yet created"
)
raise
ValueError
(
"local predictor not yet created"
)
client
=
self
.
local_predictor
client
=
self
.
local_predictor
self
.
right_feed_names
,
self
.
right_fetch_names
=
self
.
get_feed_fetch_list
(
client
)
self
.
right_feed_names
,
self
.
right_fetch_names
=
self
.
get_feed_fetch_list
(
client
)
else
:
else
:
raise
ValueError
(
"Failed to init client: unknow client "
raise
ValueError
(
"Failed to init client: unknow client "
"type {}"
.
format
(
self
.
client_type
))
"type {}"
.
format
(
self
.
client_type
))
...
@@ -422,7 +424,8 @@ class Op(object):
...
@@ -422,7 +424,8 @@ class Op(object):
print
(
"connect to encryption rpc client"
)
print
(
"connect to encryption rpc client"
)
client
.
use_key
(
self
.
_encryption_key
)
client
.
use_key
(
self
.
_encryption_key
)
client
.
connect
(
server_endpoints
,
encryption
=
True
)
client
.
connect
(
server_endpoints
,
encryption
=
True
)
_LOGGER
.
info
(
"init_client, feed_list:{}, fetch_list: {}"
.
format
(
self
.
right_feed_names
,
self
.
right_fetch_names
))
_LOGGER
.
info
(
"init_client, feed_list:{}, fetch_list: {}"
.
format
(
self
.
right_feed_names
,
self
.
right_fetch_names
))
return
client
return
client
def
get_input_ops
(
self
):
def
get_input_ops
(
self
):
...
@@ -616,13 +619,17 @@ class Op(object):
...
@@ -616,13 +619,17 @@ class Op(object):
call_result
=
None
call_result
=
None
err_code
=
ChannelDataErrcode
.
OK
.
value
err_code
=
ChannelDataErrcode
.
OK
.
value
err_info
=
""
err_info
=
""
@
ErrorCatch
@
ErrorCatch
@
ParamChecker
@
ParamChecker
def
feed_fetch_list_check_helper
(
feed_batch
:
lambda
feed_batch
:
check_feed_dict
(
feed_batch
[
0
],
self
.
right_feed_names
),
def
feed_fetch_list_check_helper
(
fetch_list
:
lambda
fetch_list
:
check_fetch_list
(
fetch_list
,
self
.
right_fetch_names
),
feed_batch
:
lambda
feed_batch
:
check_feed_dict
(
feed_batch
[
0
],
self
.
right_feed_names
),
fetch_list
:
lambda
fetch_list
:
check_fetch_list
(
fetch_list
,
self
.
right_fetch_names
),
log_id
):
log_id
):
return
None
return
None
_
,
resp
=
feed_fetch_list_check_helper
(
feed_batch
,
self
.
_fetch_names
,
log_id
=
typical_logid
)
_
,
resp
=
feed_fetch_list_check_helper
(
feed_batch
,
self
.
_fetch_names
,
log_id
=
typical_logid
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
err_code
=
resp
.
err_no
err_code
=
resp
.
err_no
err_info
=
resp
.
err_msg
err_info
=
resp
.
err_msg
...
@@ -873,6 +880,7 @@ class Op(object):
...
@@ -873,6 +880,7 @@ class Op(object):
preped_data_dict
=
collections
.
OrderedDict
()
preped_data_dict
=
collections
.
OrderedDict
()
err_channeldata_dict
=
collections
.
OrderedDict
()
err_channeldata_dict
=
collections
.
OrderedDict
()
skip_process_dict
=
{}
skip_process_dict
=
{}
@
ErrorCatch
@
ErrorCatch
def
preprocess_help
(
self
,
parsed_data
,
data_id
,
logid_dict
):
def
preprocess_help
(
self
,
parsed_data
,
data_id
,
logid_dict
):
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
self
.
preprocess
(
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
self
.
preprocess
(
...
@@ -884,14 +892,16 @@ class Op(object):
...
@@ -884,14 +892,16 @@ class Op(object):
is_skip_process
=
False
is_skip_process
=
False
prod_errcode
,
prod_errinfo
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
log_id
=
logid_dict
.
get
(
data_id
)
log_id
=
logid_dict
.
get
(
data_id
)
process_res
,
resp
=
preprocess_help
(
self
,
parsed_data
,
data_id
=
data_id
,
process_res
,
resp
=
preprocess_help
(
logid_dict
=
logid_dict
)
self
,
parsed_data
,
data_id
=
data_id
,
logid_dict
=
logid_dict
)
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
process_res
preped_data
,
is_skip_process
,
prod_errcode
,
prod_errinfo
=
process_res
if
is_skip_process
is
True
:
if
is_skip_process
is
True
:
skip_process_dict
[
data_id
]
=
True
skip_process_dict
[
data_id
]
=
True
if
prod_errcode
is
not
None
:
if
prod_errcode
is
not
None
:
_LOGGER
.
error
(
"data_id: {} return product error. Product ErrNo:{}, Product ErrMsg: {}"
.
format
(
data_id
,
prod_errcode
,
prod_errinfo
))
_LOGGER
.
error
(
"data_id: {} return product error. Product ErrNo:{}, Product ErrMsg: {}"
.
format
(
data_id
,
prod_errcode
,
prod_errinfo
))
error_channeldata
=
ChannelData
(
error_channeldata
=
ChannelData
(
error_code
=
ChannelDataErrcode
.
PRODUCT_ERROR
.
value
,
error_code
=
ChannelDataErrcode
.
PRODUCT_ERROR
.
value
,
error_info
=
""
,
error_info
=
""
,
...
@@ -1162,12 +1172,16 @@ class Op(object):
...
@@ -1162,12 +1172,16 @@ class Op(object):
_LOGGER
.
debug
(
"{} Running postprocess"
.
format
(
op_info_prefix
))
_LOGGER
.
debug
(
"{} Running postprocess"
.
format
(
op_info_prefix
))
postped_data_dict
=
collections
.
OrderedDict
()
postped_data_dict
=
collections
.
OrderedDict
()
err_channeldata_dict
=
collections
.
OrderedDict
()
err_channeldata_dict
=
collections
.
OrderedDict
()
@
ErrorCatch
@
ErrorCatch
def
postprocess_help
(
self
,
parsed_data_dict
,
midped_data
,
data_id
,
logid_dict
):
def
postprocess_help
(
self
,
parsed_data_dict
,
midped_data
,
data_id
,
postped_data
,
prod_errcode
,
prod_errinfo
=
self
.
postprocess
(
parsed_data_dict
[
data_id
],
logid_dict
):
midped_data
,
data_id
,
logid_dict
.
get
(
data_id
))
postped_data
,
prod_errcode
,
prod_errinfo
=
self
.
postprocess
(
parsed_data_dict
[
data_id
],
midped_data
,
data_id
,
logid_dict
.
get
(
data_id
))
if
not
isinstance
(
postped_data
,
dict
):
if
not
isinstance
(
postped_data
,
dict
):
raise
CustomException
(
CustomExceptionCode
.
TYPE_ERROR
,
"postprocess should return dict"
,
True
)
raise
CustomException
(
CustomExceptionCode
.
TYPE_ERROR
,
"postprocess should return dict"
,
True
)
return
postped_data
,
prod_errcode
,
prod_errinfo
return
postped_data
,
prod_errcode
,
prod_errinfo
for
data_id
,
midped_data
in
midped_data_dict
.
items
():
for
data_id
,
midped_data
in
midped_data_dict
.
items
():
...
@@ -1175,8 +1189,12 @@ class Op(object):
...
@@ -1175,8 +1189,12 @@ class Op(object):
postped_data
,
err_channeldata
=
None
,
None
postped_data
,
err_channeldata
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
prod_errcode
,
prod_errinfo
=
None
,
None
post_res
,
resp
=
postprocess_help
(
self
,
parsed_data_dict
,
midped_data
,
data_id
post_res
,
resp
=
postprocess_help
(
=
data_id
,
logid_dict
=
logid_dict
)
self
,
parsed_data_dict
,
midped_data
,
data_id
=
data_id
,
logid_dict
=
logid_dict
)
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
==
CustomExceptionCode
.
OK
.
value
:
postped_data
,
prod_errcode
,
prod_errinfo
=
post_res
postped_data
,
prod_errcode
,
prod_errinfo
=
post_res
if
prod_errcode
is
not
None
:
if
prod_errcode
is
not
None
:
...
@@ -1303,10 +1321,10 @@ class Op(object):
...
@@ -1303,10 +1321,10 @@ class Op(object):
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
def
_run
(
self
,
concurrency_idx
,
input_channel
,
output_channels
,
is_thread_op
,
trace_buffer
,
model_config
,
workdir
,
thread_num
,
is_thread_op
,
trace_buffer
,
model_config
,
workdir
,
thread_num
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
precision
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
precision
,
use_mkldnn
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
mkldnn_bf16_op_list
,
is_jump_op
,
output_channels_of_jump_ops
,
is_jump_op
,
output_channels_of_jump_ops
,
min_subgraph_size
,
min_subgraph_size
,
dynamic_shape_info
,
use_calib
):
dynamic_shape_info
,
use_calib
):
"""
"""
_run() is the entry function of OP process / thread model.When client
_run() is the entry function of OP process / thread model.When client
type is local_predictor in process mode, the CUDA environment needs to
type is local_predictor in process mode, the CUDA environment needs to
...
@@ -1344,11 +1362,13 @@ class Op(object):
...
@@ -1344,11 +1362,13 @@ class Op(object):
# init ops
# init ops
profiler
=
None
profiler
=
None
@
ErrorCatch
@
ErrorCatch
def
check_helper
(
self
,
is_thread_op
,
model_config
,
workdir
,
def
check_helper
(
self
,
is_thread_op
,
model_config
,
workdir
,
thread_num
,
thread_num
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
precision
,
precision
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
):
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
):
if
is_thread_op
==
False
and
self
.
client_type
==
"local_predictor"
:
if
is_thread_op
==
False
and
self
.
client_type
==
"local_predictor"
:
self
.
service_handler
=
local_service_handler
.
LocalServiceHandler
(
self
.
service_handler
=
local_service_handler
.
LocalServiceHandler
(
...
@@ -1377,17 +1397,19 @@ class Op(object):
...
@@ -1377,17 +1397,19 @@ class Op(object):
profiler
=
self
.
_initialize
(
is_thread_op
,
concurrency_idx
)
profiler
=
self
.
_initialize
(
is_thread_op
,
concurrency_idx
)
return
profiler
return
profiler
profiler
,
resp
=
check_helper
(
self
,
is_thread_op
,
model_config
,
workdir
,
profiler
,
resp
=
check_helper
(
thread_num
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
self
,
is_thread_op
,
model_config
,
workdir
,
thread_num
,
device_type
,
precision
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
devices
,
mem_optim
,
ir_optim
,
precision
,
use_mkldnn
,
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
)
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
_LOGGER
.
critical
(
_LOGGER
.
critical
(
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
),
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
),
exc_info
=
False
)
exc_info
=
False
)
print
(
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
))
print
(
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
_LOGGER
.
info
(
"{} Succ init"
.
format
(
op_info_prefix
))
_LOGGER
.
info
(
"{} Succ init"
.
format
(
op_info_prefix
))
...
@@ -1583,6 +1605,7 @@ class Op(object):
...
@@ -1583,6 +1605,7 @@ class Op(object):
Returns:
Returns:
TimeProfiler
TimeProfiler
"""
"""
@
ErrorCatch
@
ErrorCatch
def
init_helper
(
self
,
is_thread_op
,
concurrency_idx
):
def
init_helper
(
self
,
is_thread_op
,
concurrency_idx
):
if
is_thread_op
:
if
is_thread_op
:
...
@@ -1910,8 +1933,8 @@ class VirtualOp(Op):
...
@@ -1910,8 +1933,8 @@ class VirtualOp(Op):
\-> E ----------/
\-> E ----------/
DAG view: [[A], [B, E], [C], [D], [F]]
DAG view: [[A], [B, E], [C], [D], [F]]
BUILD DAG: [A -> B -> C -> D ->
E ->
F]
BUILD DAG: [A -> B -> C -> D -> F]
\-> E -> V1-> V2->
V3
/
\-> E -> V1-> V2->/
"""
"""
def
__init__
(
self
,
name
,
concurrency
=
1
):
def
__init__
(
self
,
name
,
concurrency
=
1
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录