Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a3ac66fb
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看板
提交
a3ac66fb
编写于
2月 18, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add profiling information print in general_model client side
上级
ca4bf74c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
59 addition
and
14 deletion
+59
-14
core/general-client/include/general_model.h
core/general-client/include/general_model.h
+5
-0
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+50
-14
core/general-client/src/pybind_general_model.cpp
core/general-client/src/pybind_general_model.cpp
+4
-0
未找到文件。
core/general-client/include/general_model.h
浏览文件 @
a3ac66fb
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
using
baidu
::
paddle_serving
::
sdk_cpp
::
Predictor
;
using
baidu
::
paddle_serving
::
sdk_cpp
::
Predictor
;
using
baidu
::
paddle_serving
::
sdk_cpp
::
PredictorApi
;
using
baidu
::
paddle_serving
::
sdk_cpp
::
PredictorApi
;
DECLARE_bool
(
profile_client
);
DECLARE_bool
(
profile_server
);
// given some input data, pack into pb, and send request
// given some input data, pack into pb, and send request
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
@@ -45,6 +48,8 @@ class PredictorClient {
...
@@ -45,6 +48,8 @@ class PredictorClient {
PredictorClient
()
{}
PredictorClient
()
{}
~
PredictorClient
()
{}
~
PredictorClient
()
{}
void
init_gflags
(
std
::
vector
<
std
::
string
>
argv
);
int
init
(
const
std
::
string
&
client_conf
);
int
init
(
const
std
::
string
&
client_conf
);
void
set_predictor_conf
(
const
std
::
string
&
conf_path
,
void
set_predictor_conf
(
const
std
::
string
&
conf_path
,
...
...
core/general-client/src/general_model.cpp
浏览文件 @
a3ac66fb
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
#include "core/sdk-cpp/include/predictor_sdk.h"
#include "core/sdk-cpp/include/predictor_sdk.h"
#include "core/util/include/timer.h"
#include "core/util/include/timer.h"
DEFINE_bool
(
profile_client
,
false
,
""
);
DEFINE_bool
(
profile_server
,
false
,
""
);
using
baidu
::
paddle_serving
::
Timer
;
using
baidu
::
paddle_serving
::
Timer
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
Request
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
Request
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
Response
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
Response
;
...
@@ -26,11 +29,30 @@ using baidu::paddle_serving::predictor::general_model::Tensor;
...
@@ -26,11 +29,30 @@ using baidu::paddle_serving::predictor::general_model::Tensor;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
FeedInst
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
FeedInst
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
FetchInst
;
using
baidu
::
paddle_serving
::
predictor
::
general_model
::
FetchInst
;
std
::
once_flag
gflags_init_flag
;
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
namespace
general_model
{
namespace
general_model
{
using
configure
::
GeneralModelConfig
;
using
configure
::
GeneralModelConfig
;
void
PredictorClient
::
init_gflags
(
std
::
vector
<
std
::
string
>
argv
)
{
std
::
call_once
(
gflags_init_flag
,
[
&
]()
{
FLAGS_logtostderr
=
true
;
argv
.
insert
(
argv
.
begin
(),
"dummy"
);
int
argc
=
argv
.
size
();
char
**
arr
=
new
char
*
[
argv
.
size
()];
std
::
string
line
;
for
(
size_t
i
=
0
;
i
<
argv
.
size
();
i
++
)
{
arr
[
i
]
=
&
argv
[
i
][
0
];
line
+=
argv
[
i
];
line
+=
' '
;
}
google
::
ParseCommandLineFlags
(
&
argc
,
&
arr
,
true
);
VLOG
(
2
)
<<
"Init commandline: "
<<
line
;
});
}
int
PredictorClient
::
init
(
const
std
::
string
&
conf_file
)
{
int
PredictorClient
::
init
(
const
std
::
string
&
conf_file
)
{
try
{
try
{
GeneralModelConfig
model_config
;
GeneralModelConfig
model_config
;
...
@@ -190,6 +212,13 @@ std::vector<std::vector<float>> PredictorClient::predict(
...
@@ -190,6 +212,13 @@ std::vector<std::vector<float>> PredictorClient::predict(
int64_t
client_infer_end
=
0
;
int64_t
client_infer_end
=
0
;
int64_t
postprocess_start
=
0
;
int64_t
postprocess_start
=
0
;
int64_t
postprocess_end
=
0
;
int64_t
postprocess_end
=
0
;
if
(
FLAGS_profile_client
)
{
if
(
FLAGS_profile_server
)
{
req
.
set_profile_server
(
true
);
}
}
res
.
Clear
();
res
.
Clear
();
if
(
_predictor
->
inference
(
&
req
,
&
res
)
!=
0
)
{
if
(
_predictor
->
inference
(
&
req
,
&
res
)
!=
0
)
{
LOG
(
ERROR
)
<<
"failed call predictor with req: "
<<
req
.
ShortDebugString
();
LOG
(
ERROR
)
<<
"failed call predictor with req: "
<<
req
.
ShortDebugString
();
...
@@ -211,20 +240,27 @@ std::vector<std::vector<float>> PredictorClient::predict(
...
@@ -211,20 +240,27 @@ std::vector<std::vector<float>> PredictorClient::predict(
postprocess_end
=
timeline
.
TimeStampUS
();
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
;
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
;
VLOG
(
2
)
<<
"preprocess start: "
<<
preprocess_start
;
fprintf
(
stderr
,
"%s
\n
"
,
oss
.
str
().
c_str
());
VLOG
(
2
)
<<
"preprocess end: "
<<
preprocess_end
;
}
VLOG
(
2
)
<<
"client infer start: "
<<
client_infer_start
;
VLOG
(
2
)
<<
"op1 start: "
<<
res
.
profile_time
(
0
);
VLOG
(
2
)
<<
"op1 end: "
<<
res
.
profile_time
(
1
);
VLOG
(
2
)
<<
"op2 start: "
<<
res
.
profile_time
(
2
);
VLOG
(
2
)
<<
"op2 end: "
<<
res
.
profile_time
(
3
);
VLOG
(
2
)
<<
"op3 start: "
<<
res
.
profile_time
(
4
);
VLOG
(
2
)
<<
"op3 end: "
<<
res
.
profile_time
(
5
);
VLOG
(
2
)
<<
"client infer end: "
<<
client_infer_end
;
VLOG
(
2
)
<<
"client postprocess start: "
<<
postprocess_start
;
VLOG
(
2
)
<<
"client postprocess end: "
<<
postprocess_end
;
return
fetch_result
;
return
fetch_result
;
}
}
...
...
core/general-client/src/pybind_general_model.cpp
浏览文件 @
a3ac66fb
...
@@ -31,6 +31,10 @@ PYBIND11_MODULE(serving_client, m) {
...
@@ -31,6 +31,10 @@ PYBIND11_MODULE(serving_client, m) {
)pddoc"
;
)pddoc"
;
py
::
class_
<
PredictorClient
>
(
m
,
"PredictorClient"
,
py
::
buffer_protocol
())
py
::
class_
<
PredictorClient
>
(
m
,
"PredictorClient"
,
py
::
buffer_protocol
())
.
def
(
py
::
init
())
.
def
(
py
::
init
())
.
def
(
"init_gflags"
,
[](
PredictorClient
&
self
,
std
::
vector
<
std
::
string
>
argv
)
{
self
.
init_gflags
(
argv
);
})
.
def
(
"init"
,
.
def
(
"init"
,
[](
PredictorClient
&
self
,
const
std
::
string
&
conf
)
{
[](
PredictorClient
&
self
,
const
std
::
string
&
conf
)
{
return
self
.
init
(
conf
);
return
self
.
init
(
conf
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录