Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
e9e93be2
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看板
未验证
提交
e9e93be2
编写于
8月 07, 2019
作者:
W
Wang Guibao
提交者:
GitHub
8月 07, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38 from wangguibao/ctr_model_serving
Fix ctr_prediction op
上级
fda47639
a947aab0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
25 deletion
+60
-25
demo-serving/conf/model_toolkit.prototxt
demo-serving/conf/model_toolkit.prototxt
+2
-0
demo-serving/op/ctr_prediction_op.cpp
demo-serving/op/ctr_prediction_op.cpp
+58
-25
未找到文件。
demo-serving/conf/model_toolkit.prototxt
浏览文件 @
e9e93be2
...
@@ -28,4 +28,6 @@ engines {
...
@@ -28,4 +28,6 @@ engines {
runtime_thread_num: 0
runtime_thread_num: 0
batch_infer_size: 0
batch_infer_size: 0
enable_batch_align: 0
enable_batch_align: 0
sparse_param_service_type: REMOTE
sparse_param_service_table_name: "dict"
}
}
demo-serving/op/ctr_prediction_op.cpp
浏览文件 @
e9e93be2
...
@@ -102,42 +102,75 @@ int CTRPredictionOp::inference() {
...
@@ -102,42 +102,75 @@ int CTRPredictionOp::inference() {
predictor
::
KVManager
&
kv_manager
=
predictor
::
KVManager
::
instance
();
predictor
::
KVManager
&
kv_manager
=
predictor
::
KVManager
::
instance
();
const
predictor
::
KVInfo
*
kvinfo
=
const
predictor
::
KVInfo
*
kvinfo
=
kv_manager
.
get_kv_info
(
CTR_PREDICTION_MODEL_NAME
);
kv_manager
.
get_kv_info
(
CTR_PREDICTION_MODEL_NAME
);
if
(
kvinfo
!=
NULL
)
{
if
(
kvinfo
==
NULL
)
{
std
::
string
table_name
;
LOG
(
ERROR
)
<<
"Sparse param service info not found for model "
if
(
kvinfo
->
sparse_param_service_type
!=
configure
::
EngineDesc
::
NONE
)
{
<<
CTR_PREDICTION_MODEL_NAME
table_name
=
kvinfo
->
sparse_param_service_table_name
;
<<
". Maybe forgot to specify sparse_param_service_type and "
<<
"sparse_param_service_table_name in "
<<
"conf/model_toolkit.prototxt"
;
fill_response_with_message
(
res
,
-
1
,
"Sparse param service info not found"
);
return
0
;
}
std
::
string
table_name
;
if
(
kvinfo
->
sparse_param_service_type
!=
configure
::
EngineDesc
::
NONE
)
{
table_name
=
kvinfo
->
sparse_param_service_table_name
;
if
(
table_name
.
empty
())
{
LOG
(
ERROR
)
<<
"sparse_param_service_table_name not specified. "
<<
"Please specify it in conf/model_toolkit.protxt for model "
<<
CTR_PREDICTION_MODEL_NAME
;
fill_response_with_message
(
res
,
-
1
,
"sparse_param_service_table_name not specified"
);
return
0
;
}
}
}
if
(
kvinfo
->
sparse_param_service_type
==
configure
::
EngineDesc
::
LOCAL
)
{
if
(
kvinfo
->
sparse_param_service_type
==
configure
::
EngineDesc
::
LOCAL
)
{
// Query local KV service
// Query local KV service
}
else
if
(
kvinfo
->
sparse_param_service_type
==
LOG
(
ERROR
)
<<
"Local kv service not supported for model "
configure
::
EngineDesc
::
REMOTE
)
{
<<
CTR_PREDICTION_MODEL_NAME
;
int
ret
=
cube
->
seek
(
table_name
,
keys
,
&
values
);
if
(
ret
!=
0
)
{
fill_response_with_message
(
fill_response_with_message
(
res
,
-
1
,
"Query cube for embeddings error"
);
res
,
-
1
,
"Local kv service not supported for this model"
);
LOG
(
ERROR
)
<<
"Query cube for embeddings error"
;
return
0
;
return
-
1
;
}
else
if
(
kvinfo
->
sparse_param_service_type
==
}
configure
::
EngineDesc
::
REMOTE
)
{
int
ret
=
cube
->
seek
(
table_name
,
keys
,
&
values
);
if
(
ret
!=
0
)
{
fill_response_with_message
(
res
,
-
1
,
"Query cube for embeddings error"
);
LOG
(
ERROR
)
<<
"Query cube for embeddings error"
;
return
0
;
}
}
}
#if 0
if
(
values
.
size
()
!=
keys
.
size
())
{
for (int i = 0; i < keys.size(); ++i) {
LOG
(
ERROR
)
<<
"Sparse embeddings not ready; "
std::ostringstream oss;
<<
"maybe forgot to set sparse_param_service_type and "
oss << keys[i] << ": ";
<<
"sparse_param_sevice_table_name for "
const char *value = (values[i].buff.data());
<<
CTR_PREDICTION_MODEL_NAME
if (values[i].buff.size() !=
<<
" in conf/model_toolkit.prototxt"
;
sizeof(float) * CTR_PREDICTION_EMBEDDING_SIZE) {
fill_response_with_message
(
LOG(WARNING) << "Key " << keys[i] << " has values less than "
res
,
-
1
,
"Sparse param service not configured properly"
);
<< CTR_PREDICTION_EMBEDDING_SIZE;
return
0
;
}
}
for
(
int
i
=
0
;
i
<
keys
.
size
();
++
i
)
{
std
::
ostringstream
oss
;
oss
<<
keys
[
i
]
<<
": "
;
const
char
*
value
=
(
values
[
i
].
buff
.
data
());
if
(
values
[
i
].
buff
.
size
()
!=
sizeof
(
float
)
*
CTR_PREDICTION_EMBEDDING_SIZE
)
{
LOG
(
WARNING
)
<<
"Key "
<<
keys
[
i
]
<<
" has values less than "
<<
CTR_PREDICTION_EMBEDDING_SIZE
;
}
#if 0
for (int j = 0; j < values[i].buff.size(); ++j) {
for (int j = 0; j < values[i].buff.size(); ++j) {
oss << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
oss << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
<< (static_cast<int>(value[j]) & 0xff);
<< (static_cast<int>(value[j]) & 0xff);
}
}
LOG(INFO) << oss.str().c_str();
LOG(INFO) << oss.str().c_str();
}
#endif
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录