Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
4d406d26
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看板
未验证
提交
4d406d26
编写于
8月 12, 2019
作者:
M
MRXLT
提交者:
GitHub
8月 12, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4 from PaddlePaddle/develop
update from origin
上级
1705f05c
85f71b12
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
23 deletion
+58
-23
cube/cube-agent/src/agent/work.go
cube/cube-agent/src/agent/work.go
+10
-2
demo-client/src/ctr_prediction.cpp
demo-client/src/ctr_prediction.cpp
+7
-3
demo-serving/conf/gflags.conf
demo-serving/conf/gflags.conf
+1
-1
demo-serving/op/ctr_prediction_op.cpp
demo-serving/op/ctr_prediction_op.cpp
+40
-17
未找到文件。
cube/cube-agent/src/agent/work.go
浏览文件 @
4d406d26
...
...
@@ -834,9 +834,17 @@ func GetFileName(source string) (fileName string) {
}
func
checkMd5
(
file
string
,
fileMd5
string
)
(
err
error
)
{
md5Cmd
:=
fmt
.
Sprintf
(
"./scripts/md5_checker %s %s"
,
file
,
fileMd5
)
cmd
:=
fmt
.
Sprintf
(
"md5sum %s | awk '{print $1}'"
,
file
)
stdout
,
_
,
_
:=
pipeline
.
Run
(
exec
.
Command
(
"/bin/sh"
,
"-c"
,
cmd
))
real_md5
:=
stdout
.
String
()
cmd
=
fmt
.
Sprintf
(
"cat %s | awk '{print $1}'"
,
fileMd5
)
stdout
,
_
,
_
=
pipeline
.
Run
(
exec
.
Command
(
"/bin/sh"
,
"-c"
,
cmd
))
given_md5
:=
stdout
.
String
()
_
,
_
,
err
=
pipeline
.
Run
(
exec
.
Command
(
"/bin/sh"
,
"-c"
,
md5Cmd
))
if
real_md5
!=
given_md5
{
logex
.
Warningf
(
"checkMd5 failed real_md5[%s] given_md5[%s]"
,
real_md5
,
given_md5
)
err
=
errors
.
New
(
"checkMd5 failed"
)
}
return
}
...
...
demo-client/src/ctr_prediction.cpp
浏览文件 @
4d406d26
...
...
@@ -30,7 +30,7 @@ using baidu::paddle_serving::predictor::ctr_prediction::Response;
using
baidu
::
paddle_serving
::
predictor
::
ctr_prediction
::
CTRReqInstance
;
using
baidu
::
paddle_serving
::
predictor
::
ctr_prediction
::
CTRResInstance
;
int
batch_size
=
1
;
int
batch_size
=
1
6
;
int
sparse_num
=
26
;
int
dense_num
=
13
;
int
thread_num
=
1
;
...
...
@@ -95,8 +95,12 @@ int create_req(Request* req,
return
-
1
;
}
// add data
std
::
vector
<
std
::
string
>
feature_list
=
split
(
data_list
[
data_index
+
i
],
"
\t
"
);
// avoid out of boundary
int
cur_index
=
data_index
+
i
;
if
(
cur_index
>=
data_list
.
size
())
{
cur_index
=
cur_index
%
data_list
.
size
();
}
std
::
vector
<
std
::
string
>
feature_list
=
split
(
data_list
[
cur_index
],
"
\t
"
);
for
(
int
fi
=
0
;
fi
<
dense_num
;
fi
++
)
{
if
(
feature_list
[
fi
]
==
""
)
{
ins
->
add_dense_ids
(
0.0
);
...
...
demo-serving/conf/gflags.conf
浏览文件 @
4d406d26
--
enable_model_toolkit
--
enable_cube
=
fals
e
--
enable_cube
=
tru
e
demo-serving/op/ctr_prediction_op.cpp
浏览文件 @
4d406d26
...
...
@@ -263,28 +263,51 @@ int CTRPredictionOp::inference() {
return
0
;
}
if
(
out
->
size
()
!=
sample_size
)
{
LOG
(
ERROR
)
<<
"Output tensor size not equal that of input"
;
fill_response_with_message
(
res
,
-
1
,
"Output size != input size"
);
if
(
out
->
size
()
!=
1
)
{
LOG
(
ERROR
)
<<
"Model returned number of fetch tensor more than 1"
;
fill_response_with_message
(
res
,
-
1
,
"Model returned number of fetch tensor more than 1"
);
return
0
;
}
for
(
size_t
i
=
0
;
i
<
out
->
size
();
++
i
)
{
int
dim1
=
out
->
at
(
i
).
shape
[
0
];
int
dim2
=
out
->
at
(
i
).
shape
[
1
];
int
output_shape_dim
=
out
->
at
(
0
).
shape
.
size
();
if
(
output_shape_dim
!=
2
)
{
LOG
(
ERROR
)
<<
"Fetch LoDTensor should be shape of [sample_size, 2]"
;
fill_response_with_message
(
res
,
-
1
,
"Fetch LoDTensor should be shape of [sample_size, 2]"
);
return
0
;
}
if
(
out
->
at
(
i
).
dtype
!=
paddle
::
PaddleDType
::
FLOAT32
)
{
LOG
(
ERROR
)
<<
"Expected data type float"
;
fill_response_with_message
(
res
,
-
1
,
"Expected data type float"
);
return
0
;
}
if
(
out
->
at
(
0
).
dtype
!=
paddle
::
PaddleDType
::
FLOAT32
)
{
LOG
(
ERROR
)
<<
"Fetch LoDTensor data type should be FLOAT32"
;
fill_response_with_message
(
res
,
-
1
,
"Fetch LoDTensor data type should be FLOAT32"
);
return
0
;
}
float
*
data
=
static_cast
<
float
*>
(
out
->
at
(
i
).
data
.
data
());
for
(
int
j
=
0
;
j
<
dim1
;
++
j
)
{
CTRResInstance
*
res_instance
=
res
->
add_predictions
();
res_instance
->
set_prob0
(
data
[
j
*
dim2
]);
res_instance
->
set_prob1
(
data
[
j
*
dim2
+
1
]);
}
int
dim1
=
out
->
at
(
0
).
shape
[
0
];
int
dim2
=
out
->
at
(
0
).
shape
[
1
];
if
(
dim1
!=
sample_size
)
{
LOG
(
ERROR
)
<<
"Returned result count not equal to sample_size"
;
fill_response_with_message
(
res
,
-
1
,
"Returned result count not equal to sample size"
);
return
0
;
}
if
(
dim2
!=
2
)
{
LOG
(
ERROR
)
<<
"Returned result is not expected, should be 2 floats for "
"each sample"
;
fill_response_with_message
(
res
,
-
1
,
"Retunred result is not 2 floats for each sample"
);
return
0
;
}
float
*
data
=
static_cast
<
float
*>
(
out
->
at
(
0
).
data
.
data
());
for
(
int
i
=
0
;
i
<
dim1
;
++
i
)
{
CTRResInstance
*
res_instance
=
res
->
add_predictions
();
res_instance
->
set_prob0
(
data
[
i
*
dim2
]);
res_instance
->
set_prob1
(
data
[
i
*
dim2
+
1
]);
}
for
(
size_t
i
=
0
;
i
<
in
->
size
();
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录