Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
081ce13e
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看板
提交
081ce13e
编写于
3月 19, 2019
作者:
W
wangguibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test cases
Change-Id: Ibfa31d682c996fe127c31b06e60de3e91406eaf2
上级
e7cd288c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
44 addition
and
5 deletion
+44
-5
sdk-cpp/demo/text_classification.cpp
sdk-cpp/demo/text_classification.cpp
+5
-1
serving/op/text_classification_op.cpp
serving/op/text_classification_op.cpp
+39
-4
未找到文件。
sdk-cpp/demo/text_classification.cpp
浏览文件 @
081ce13e
...
@@ -203,6 +203,7 @@ int main(int argc, char **argv) {
...
@@ -203,6 +203,7 @@ int main(int argc, char **argv) {
api
.
thrd_initialize
();
api
.
thrd_initialize
();
uint64_t
elapse_ms
=
0
;
uint64_t
elapse_ms
=
0
;
int
batch_count
=
0
;
while
(
true
)
{
while
(
true
)
{
api
.
thrd_clear
();
api
.
thrd_clear
();
...
@@ -219,6 +220,8 @@ int main(int argc, char **argv) {
...
@@ -219,6 +220,8 @@ int main(int argc, char **argv) {
break
;
break
;
}
}
++
batch_count
;
timeval
start
;
timeval
start
;
gettimeofday
(
&
start
,
NULL
);
gettimeofday
(
&
start
,
NULL
);
...
@@ -251,9 +254,10 @@ int main(int argc, char **argv) {
...
@@ -251,9 +254,10 @@ int main(int argc, char **argv) {
}
}
LOG
(
INFO
)
<<
"Elapse ms "
<<
elapse_ms
;
LOG
(
INFO
)
<<
"Elapse ms "
<<
elapse_ms
;
LOG
(
INFO
)
<<
"Exe ms per batch "
<<
elapse_ms
/
batch_count
;
double
qps
=
(
static_cast
<
double
>
(
g_pred_labels
.
size
())
/
elapse_ms
)
*
1000
;
double
qps
=
(
static_cast
<
double
>
(
g_pred_labels
.
size
())
/
elapse_ms
)
*
1000
;
LOG
(
INFO
)
<<
"QPS: "
<<
qps
<<
"/s"
;
LOG
(
INFO
)
<<
"QPS: "
<<
qps
/
FLAGS_batch_size
<<
"/s"
;
LOG
(
INFO
)
<<
"Accuracy "
LOG
(
INFO
)
<<
"Accuracy "
<<
static_cast
<
double
>
(
correct
)
/
g_pred_labels
.
size
();
<<
static_cast
<
double
>
(
correct
)
/
g_pred_labels
.
size
();
...
...
serving/op/text_classification_op.cpp
浏览文件 @
081ce13e
...
@@ -27,6 +27,43 @@ using baidu::paddle_serving::predictor::text_classification::Response;
...
@@ -27,6 +27,43 @@ using baidu::paddle_serving::predictor::text_classification::Response;
using
baidu
::
paddle_serving
::
predictor
::
text_classification
::
TextReqInstance
;
using
baidu
::
paddle_serving
::
predictor
::
text_classification
::
TextReqInstance
;
using
baidu
::
paddle_serving
::
predictor
::
text_classification
::
Request
;
using
baidu
::
paddle_serving
::
predictor
::
text_classification
::
Request
;
int
inference_real
(
TextClassificationOp
::
TensorVector
*
in
,
TextClassificationOp
::
TensorVector
*
out
,
int
sample_size
)
{
if
(
predictor
::
InferManager
::
instance
().
infer
(
TEXT_CLASSIFICATION_MODEL_NAME
,
in
,
out
,
sample_size
))
{
LOG
(
ERROR
)
<<
"Failed do infer in fluid model: "
<<
TEXT_CLASSIFICATION_MODEL_NAME
;
return
-
1
;
}
return
0
;
}
int
inference_fake
(
TextClassificationOp
::
TensorVector
*
in
,
TextClassificationOp
::
TensorVector
*
out
,
int
sample_size
)
{
paddle
::
PaddleTensor
lod_tensor
;
lod_tensor
.
dtype
=
paddle
::
PaddleDType
::
FLOAT32
;
lod_tensor
.
data
.
Resize
(
sample_size
*
sizeof
(
float
)
*
2
);
float
*
data_ptr
=
reinterpret_cast
<
float
*>
(
lod_tensor
.
data
.
data
());
for
(
int
i
=
0
;
i
<
sample_size
;
++
i
)
{
*
(
data_ptr
+
i
*
2
)
=
0.500
;
*
(
data_ptr
+
i
*
2
+
1
)
=
0.500
;
}
lod_tensor
.
lod
.
resize
(
1
);
lod_tensor
.
lod
[
0
].
push_back
(
0
);
lod_tensor
.
lod
[
0
].
push_back
(
sample_size
);
lod_tensor
.
shape
.
push_back
(
sample_size
);
lod_tensor
.
shape
.
push_back
(
2
);
out
->
push_back
(
lod_tensor
);
return
0
;
}
int
TextClassificationOp
::
inference
()
{
int
TextClassificationOp
::
inference
()
{
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
...
@@ -72,10 +109,8 @@ int TextClassificationOp::inference() {
...
@@ -72,10 +109,8 @@ int TextClassificationOp::inference() {
}
}
// call paddle fluid model for inferencing
// call paddle fluid model for inferencing
if
(
predictor
::
InferManager
::
instance
().
infer
(
TEXT_CLASSIFICATION_MODEL_NAME
,
in
,
out
,
sample_size
))
{
if
(
inference_fake
(
in
,
out
,
sample_size
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed do infer in fluid model: "
<<
TEXT_CLASSIFICATION_MODEL_NAME
;
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录