Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ddd34f8a
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看板
提交
ddd34f8a
编写于
11月 08, 2019
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add feed var customize for bert server
上级
f39a454f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
14 deletion
+47
-14
demo-client/src/bert_service.cpp
demo-client/src/bert_service.cpp
+2
-2
demo-serving/op/bert_service_op.cpp
demo-serving/op/bert_service_op.cpp
+31
-6
demo-serving/proto/bert_service.proto
demo-serving/proto/bert_service.proto
+7
-3
sdk-cpp/proto/bert_service.proto
sdk-cpp/proto/bert_service.proto
+7
-3
未找到文件。
demo-client/src/bert_service.cpp
浏览文件 @
ddd34f8a
...
...
@@ -93,9 +93,9 @@ int create_req(Request* req,
ins
->
add_input_masks
(
0.0
);
}
}
ins
->
set_max_seq_len
(
max_seq_len
);
ins
->
set_emb_size
(
emb_size
);
}
req
->
set_max_seq_len
(
max_seq_len
);
req
->
set_emb_size
(
emb_size
);
return
0
;
}
...
...
demo-serving/op/bert_service_op.cpp
浏览文件 @
ddd34f8a
...
...
@@ -28,6 +28,21 @@ using baidu::paddle_serving::predictor::bert_service::BertReqInstance;
using
baidu
::
paddle_serving
::
predictor
::
bert_service
::
Request
;
using
baidu
::
paddle_serving
::
predictor
::
bert_service
::
EmbeddingValues
;
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
str
,
const
std
::
string
&
pattern
)
{
std
::
vector
<
std
::
string
>
res
;
if
(
str
==
""
)
return
res
;
std
::
string
strs
=
str
+
pattern
;
size_t
pos
=
strs
.
find
(
pattern
);
while
(
pos
!=
strs
.
npos
)
{
std
::
string
temp
=
strs
.
substr
(
0
,
pos
);
res
.
push_back
(
temp
);
strs
=
strs
.
substr
(
pos
+
1
,
strs
.
size
());
pos
=
strs
.
find
(
pattern
);
}
return
res
;
}
int
BertServiceOp
::
inference
()
{
timeval
op_start
;
gettimeofday
(
&
op_start
,
NULL
);
...
...
@@ -43,17 +58,27 @@ int BertServiceOp::inference() {
return
0
;
}
const
int64_t
MAX_SEQ_LEN
=
req
->
instances
(
0
).
max_seq_len
();
const
int64_t
EMB_SIZE
=
req
->
instances
(
0
).
emb_size
();
const
int64_t
MAX_SEQ_LEN
=
req
->
max_seq_len
();
const
int64_t
EMB_SIZE
=
req
->
emb_size
();
paddle
::
PaddleTensor
src_ids
;
paddle
::
PaddleTensor
pos_ids
;
paddle
::
PaddleTensor
seg_ids
;
paddle
::
PaddleTensor
input_masks
;
if
(
req
->
has_feed_var_names
())
{
// support paddlehub model
std
::
vector
<
std
::
string
>
feed_list
=
split
(
req
->
feed_var_names
(),
";"
);
src_ids
.
name
=
feed_list
[
0
];
pos_ids
.
name
=
feed_list
[
1
];
seg_ids
.
name
=
feed_list
[
2
];
input_masks
.
name
=
feed_list
[
3
];
}
else
{
src_ids
.
name
=
std
::
string
(
"src_ids"
);
pos_ids
.
name
=
std
::
string
(
"pos_ids"
);
seg_ids
.
name
=
std
::
string
(
"sent_ids"
);
input_masks
.
name
=
std
::
string
(
"input_mask"
);
}
src_ids
.
dtype
=
paddle
::
PaddleDType
::
INT64
;
src_ids
.
shape
=
{
batch_size
,
MAX_SEQ_LEN
,
1
};
...
...
demo-serving/proto/bert_service.proto
浏览文件 @
ddd34f8a
...
...
@@ -25,11 +25,15 @@ message BertReqInstance {
repeated
int64
sentence_type_ids
=
2
;
repeated
int64
position_ids
=
3
;
repeated
float
input_masks
=
4
;
optional
int64
max_seq_len
=
5
;
optional
int64
emb_size
=
6
;
};
message
Request
{
repeated
BertReqInstance
instances
=
1
;
};
message
Request
{
repeated
BertReqInstance
instances
=
1
;
optional
int64
max_seq_len
=
2
;
optional
int64
emb_size
=
3
;
optional
string
feed_var_names
=
4
;
optional
string
fetch_var_names
=
5
;
};
message
EmbeddingValues
{
repeated
float
values
=
1
;
};
...
...
sdk-cpp/proto/bert_service.proto
浏览文件 @
ddd34f8a
...
...
@@ -25,11 +25,15 @@ message BertReqInstance {
repeated
int64
sentence_type_ids
=
2
;
repeated
int64
position_ids
=
3
;
repeated
float
input_masks
=
4
;
optional
int64
max_seq_len
=
5
;
optional
int64
emb_size
=
6
;
};
message
Request
{
repeated
BertReqInstance
instances
=
1
;
};
message
Request
{
repeated
BertReqInstance
instances
=
1
;
optional
int64
max_seq_len
=
2
;
optional
int64
emb_size
=
3
;
optional
string
feed_var_names
=
4
;
optional
string
fetch_var_names
=
5
;
};
message
EmbeddingValues
{
repeated
float
values
=
1
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录