Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
6324cfe9
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看板
提交
6324cfe9
编写于
2月 19, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add timeline for batch_predict
上级
77dd8f88
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
11 deletion
+49
-11
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+45
-2
python/paddle_serving_client/__init__.py
python/paddle_serving_client/__init__.py
+4
-9
未找到文件。
core/general-client/src/general_model.cpp
浏览文件 @
6324cfe9
...
...
@@ -145,7 +145,7 @@ std::vector<std::vector<float>> PredictorClient::predict(
int64_t
preprocess_start
=
timeline
.
TimeStampUS
();
// we save infer_us at fetch_result[fetch_name.size()]
fetch_result
.
resize
(
fetch_name
.
size
()
+
1
);
fetch_result
.
resize
(
fetch_name
.
size
());
_api
.
thrd_clear
();
_predictor
=
_api
.
fetch_predictor
(
"general_model"
);
...
...
@@ -276,7 +276,11 @@ std::vector<std::vector<std::vector<float>>> PredictorClient::batch_predict(
if
(
fetch_name
.
size
()
==
0
)
{
return
fetch_result_batch
;
}
fetch_result_batch
.
resize
(
batch_size
+
1
);
Timer
timeline
;
int64_t
preprocess_start
=
timeline
.
TimeStampUS
();
fetch_result_batch
.
resize
(
batch_size
);
int
fetch_name_num
=
fetch_name
.
size
();
for
(
int
bi
=
0
;
bi
<
batch_size
;
bi
++
)
{
fetch_result_batch
[
bi
].
resize
(
fetch_name_num
);
...
...
@@ -349,13 +353,30 @@ std::vector<std::vector<std::vector<float>>> PredictorClient::batch_predict(
<<
"itn feed value prepared"
;
}
int64_t
preprocess_end
=
timeline
.
TimeStampUS
();
int64_t
client_infer_start
=
timeline
.
TimeStampUS
();
Response
res
;
int64_t
client_infer_end
=
0
;
int64_t
postprocess_start
=
0
;
int64_t
postprocess_end
=
0
;
if
(
FLAGS_profile_client
)
{
if
(
FLAGS_profile_server
)
{
req
.
set_profile_server
(
true
);
}
}
res
.
Clear
();
if
(
_predictor
->
inference
(
&
req
,
&
res
)
!=
0
)
{
LOG
(
ERROR
)
<<
"failed call predictor with req: "
<<
req
.
ShortDebugString
();
exit
(
-
1
);
}
else
{
client_infer_end
=
timeline
.
TimeStampUS
();
postprocess_start
=
client_infer_end
;
for
(
int
bi
=
0
;
bi
<
batch_size
;
bi
++
)
{
for
(
auto
&
name
:
fetch_name
)
{
int
idx
=
_fetch_name_to_idx
[
name
];
...
...
@@ -372,8 +393,30 @@ std::vector<std::vector<std::vector<float>>> PredictorClient::batch_predict(
}
}
}
postprocess_end
=
timeline
.
TimeStampUS
();
}
if
(
FLAGS_profile_client
)
{
std
::
ostringstream
oss
;
oss
<<
"PROFILE
\t
"
<<
"prepro_0:"
<<
preprocess_start
<<
" "
<<
"prepro_1:"
<<
preprocess_end
<<
" "
<<
"client_infer_0:"
<<
client_infer_start
<<
" "
<<
"client_infer_1:"
<<
client_infer_end
<<
" "
;
if
(
FLAGS_profile_server
)
{
int
op_num
=
res
.
profile_time_size
()
/
2
;
for
(
int
i
=
0
;
i
<
op_num
;
++
i
)
{
oss
<<
"op"
<<
i
<<
"_0:"
<<
res
.
profile_time
(
i
*
2
)
<<
" "
;
oss
<<
"op"
<<
i
<<
"_1:"
<<
res
.
profile_time
(
i
*
2
+
1
)
<<
" "
;
}
}
oss
<<
"postpro_0:"
<<
postprocess_start
<<
" "
;
oss
<<
"postpro_1:"
<<
postprocess_end
;
fprintf
(
stderr
,
"%s
\n
"
,
oss
.
str
().
c_str
());
}
return
fetch_result_batch
;
}
...
...
python/paddle_serving_client/__init__.py
浏览文件 @
6324cfe9
...
...
@@ -89,8 +89,8 @@ class Client(object):
self
.
client_handle_
=
PredictorClient
()
self
.
client_handle_
.
init
(
path
)
read_env_flags
=
[
"profile_client"
,
"profile_server"
]
self
.
client_handle_
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
self
.
client_handle_
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
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
.
feed_shapes_
=
[
var
.
shape
for
var
in
model_conf
.
feed_var
]
...
...
@@ -183,18 +183,13 @@ class Client(object):
fetch_names
)
result_map_batch
=
[]
for
result
in
result_batch
[:
-
1
]
:
for
result
in
result_batch
:
result_map
=
{}
for
i
,
name
in
enumerate
(
fetch_names
):
result_map
[
name
]
=
result
[
i
]
result_map_batch
.
append
(
result_map
)
infer_time
=
result_batch
[
-
1
][
0
][
0
]
if
profile
:
return
result_map_batch
,
infer_time
else
:
return
result_map_batch
return
result_map_batch
def
release
(
self
):
self
.
client_handle_
.
destroy_predictor
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录