Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
3d619b9b
S
Serving
项目概览
PaddlePaddle
/
Serving
接近 2 年 前同步成功
通知
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看板
提交
3d619b9b
编写于
12月 18, 2019
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/develop' into develop
上级
85948602
dcd32841
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
103 addition
and
117 deletion
+103
-117
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+1
-1
demo-client/src/ximage.cpp
demo-client/src/ximage.cpp
+3
-2
demo-serving/CMakeLists.txt
demo-serving/CMakeLists.txt
+1
-1
demo-serving/op/bert_service_op.h
demo-serving/op/bert_service_op.h
+0
-8
demo-serving/op/classify_op.h
demo-serving/op/classify_op.h
+0
-8
demo-serving/op/ctr_prediction_op.h
demo-serving/op/ctr_prediction_op.h
+0
-8
demo-serving/op/reader_op.h
demo-serving/op/reader_op.h
+0
-9
demo-serving/op/text_classification_op.h
demo-serving/op/text_classification_op.h
+0
-8
elastic-ctr/client/demo/elastic_ctr.py
elastic-ctr/client/demo/elastic_ctr.py
+5
-9
elastic-ctr/serving/CMakeLists.txt
elastic-ctr/serving/CMakeLists.txt
+1
-1
elastic-ctr/serving/op/elastic_ctr_prediction_op.cpp
elastic-ctr/serving/op/elastic_ctr_prediction_op.cpp
+87
-38
elastic-ctr/serving/op/elastic_ctr_prediction_op.h
elastic-ctr/serving/op/elastic_ctr_prediction_op.h
+2
-8
inferencer-fluid-cpu/include/fluid_cpu_engine.h
inferencer-fluid-cpu/include/fluid_cpu_engine.h
+0
-8
inferencer-fluid-gpu/include/fluid_gpu_engine.h
inferencer-fluid-gpu/include/fluid_gpu_engine.h
+0
-8
kvdb/include/kvdb/kvdb_impl.h
kvdb/include/kvdb/kvdb_impl.h
+1
-0
predictor/src/pdserving.cpp
predictor/src/pdserving.cpp
+2
-0
未找到文件。
cmake/paddlepaddle.cmake
浏览文件 @
3d619b9b
...
@@ -62,7 +62,7 @@ ExternalProject_Add(
...
@@ -62,7 +62,7 @@ ExternalProject_Add(
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/include
${
PADDLE_INSTALL_DIR
}
/include &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/include
${
PADDLE_INSTALL_DIR
}
/include &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/lib
${
PADDLE_INSTALL_DIR
}
/lib &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/lib
${
PADDLE_INSTALL_DIR
}
/lib &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/third_party
${
PADDLE_INSTALL_DIR
}
/third_party &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/third_party
${
PADDLE_INSTALL_DIR
}
/third_party &&
${
CMAKE_COMMAND
}
-E copy
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so.
0
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so
${
CMAKE_COMMAND
}
-E copy
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so.
1
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so
)
)
INCLUDE_DIRECTORIES
(
${
PADDLE_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
PADDLE_INCLUDE_DIR
}
)
...
...
demo-client/src/ximage.cpp
浏览文件 @
3d619b9b
...
@@ -162,7 +162,8 @@ int main(int argc, char** argv) {
...
@@ -162,7 +162,8 @@ int main(int argc, char** argv) {
api
.
thrd_initialize
();
api
.
thrd_initialize
();
while
(
true
)
{
int
count
=
0
;
while
(
count
<
10
)
{
timeval
start
;
timeval
start
;
gettimeofday
(
&
start
,
NULL
);
gettimeofday
(
&
start
,
NULL
);
...
@@ -200,7 +201,7 @@ int main(int argc, char** argv) {
...
@@ -200,7 +201,7 @@ int main(int argc, char** argv) {
print_res
(
req
,
res
,
predictor
->
tag
(),
elapse_ms
);
print_res
(
req
,
res
,
predictor
->
tag
(),
elapse_ms
);
res
.
Clear
();
res
.
Clear
();
usleep
(
50
)
;
++
count
;
}
// while (true)
}
// while (true)
api
.
thrd_finalize
();
api
.
thrd_finalize
();
...
...
demo-serving/CMakeLists.txt
浏览文件 @
3d619b9b
...
@@ -90,7 +90,7 @@ if (${WITH_MKL})
...
@@ -90,7 +90,7 @@ if (${WITH_MKL})
install
(
FILES
install
(
FILES
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libmklml_intel.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libmklml_intel.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libiomp5.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libiomp5.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mkldnn/lib/libmkldnn.so.
0
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mkldnn/lib/libmkldnn.so.
1
DESTINATION
DESTINATION
${
PADDLE_SERVING_INSTALL_DIR
}
/demo/serving/bin
)
${
PADDLE_SERVING_INSTALL_DIR
}
/demo/serving/bin
)
endif
()
endif
()
demo-serving/op/bert_service_op.h
浏览文件 @
3d619b9b
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
#pragma once
#pragma once
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "demo-serving/bert_service.pb.h"
#include "demo-serving/bert_service.pb.h"
#include <sys/time.h>
#include <sys/time.h>
...
...
demo-serving/op/classify_op.h
浏览文件 @
3d619b9b
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
#pragma once
#pragma once
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "demo-serving/image_class.pb.h"
#include "demo-serving/image_class.pb.h"
namespace
baidu
{
namespace
baidu
{
...
...
demo-serving/op/ctr_prediction_op.h
浏览文件 @
3d619b9b
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
#pragma once
#pragma once
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "demo-serving/ctr_prediction.pb.h"
#include "demo-serving/ctr_prediction.pb.h"
namespace
baidu
{
namespace
baidu
{
...
...
demo-serving/op/reader_op.h
浏览文件 @
3d619b9b
...
@@ -27,16 +27,7 @@
...
@@ -27,16 +27,7 @@
#include "opencv/cv.hpp"
#include "opencv/cv.hpp"
#include "opencv/cxcore.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "opencv/highgui.h"
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
demo-serving/op/text_classification_op.h
浏览文件 @
3d619b9b
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
#pragma once
#pragma once
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "demo-serving/text_classification.pb.h"
#include "demo-serving/text_classification.pb.h"
namespace
baidu
{
namespace
baidu
{
...
...
elastic-ctr/client/demo/elastic_ctr.py
浏览文件 @
3d619b9b
...
@@ -105,13 +105,11 @@ def data_reader(data_file, samples, labels):
...
@@ -105,13 +105,11 @@ def data_reader(data_file, samples, labels):
for
i
in
range
(
0
,
len
(
features
)):
for
i
in
range
(
0
,
len
(
features
)):
if
slots
[
i
]
in
sample
:
if
slots
[
i
]
in
sample
:
sample
[
slots
[
i
]]
=
[
sample
[
slots
[
i
]].
append
(
int
(
features
[
i
])
%
sample
[
slots
[
i
]]
+
str2long
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
)
CTR_EMBEDDING_TABLE_SIZE
]
else
:
else
:
sample
[
slots
[
i
]]
=
[
sample
[
slots
[
i
]]
=
[
str2long
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
int
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
]
]
for
x
in
SLOTS
:
for
x
in
SLOTS
:
...
@@ -142,11 +140,11 @@ if __name__ == "__main__":
...
@@ -142,11 +140,11 @@ if __name__ == "__main__":
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
ret
=
data_reader
(
sys
.
argv
[
4
],
samples
,
labels
)
ret
=
data_reader
(
sys
.
argv
[
4
],
samples
,
labels
)
print
(
len
(
samples
))
correct
=
0
correct
=
0
wrong_label_1_count
=
0
wrong_label_1_count
=
0
result_list
=
[]
result_list
=
[]
for
i
in
range
(
0
,
len
(
samples
)
-
BATCH_SIZE
,
BATCH_SIZE
):
#for i in range(0, len(samples) - BATCH_SIZE, BATCH_SIZE):
for
i
in
range
(
0
,
len
(
samples
),
BATCH_SIZE
):
api
.
clear
()
api
.
clear
()
batch
=
samples
[
i
:
i
+
BATCH_SIZE
]
batch
=
samples
[
i
:
i
+
BATCH_SIZE
]
instances
=
[]
instances
=
[]
...
@@ -181,7 +179,5 @@ if __name__ == "__main__":
...
@@ -181,7 +179,5 @@ if __name__ == "__main__":
# (i + idx, pred, labels[i + idx], x["prob0"], x["prob1"]))
# (i + idx, pred, labels[i + idx], x["prob0"], x["prob1"]))
pass
pass
idx
=
idx
+
1
idx
=
idx
+
1
#print("Acc=%f" % (float(correct) / len(samples)))
print
(
"auc = "
,
auc
(
labels
,
result_list
)
)
print
(
"auc = "
,
auc
(
labels
,
result_list
)
)
elastic-ctr/serving/CMakeLists.txt
浏览文件 @
3d619b9b
...
@@ -53,7 +53,7 @@ if (${WITH_MKL})
...
@@ -53,7 +53,7 @@ if (${WITH_MKL})
install
(
FILES
install
(
FILES
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libmklml_intel.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libmklml_intel.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libiomp5.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mklml/lib/libiomp5.so
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mkldnn/lib/libmkldnn.so.
0
${
CMAKE_BINARY_DIR
}
/third_party/install/Paddle/third_party/install/mkldnn/lib/libmkldnn.so.
1
DESTINATION
DESTINATION
${
PADDLE_SERVING_INSTALL_DIR
}
/elastic_ctr/serving/bin
)
${
PADDLE_SERVING_INSTALL_DIR
}
/elastic_ctr/serving/bin
)
endif
()
endif
()
elastic-ctr/serving/op/elastic_ctr_prediction_op.cpp
浏览文件 @
3d619b9b
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "elastic-ctr/serving/op/elastic_ctr_prediction_op.h"
#include "elastic-ctr/serving/op/elastic_ctr_prediction_op.h"
#include <algorithm>
#include <algorithm>
#include <string>
#include <string>
#include <iomanip>
#include "cube/cube-api/include/cube_api.h"
#include "cube/cube-api/include/cube_api.h"
#include "predictor/framework/infer.h"
#include "predictor/framework/infer.h"
#include "predictor/framework/kv_manager.h"
#include "predictor/framework/kv_manager.h"
...
@@ -70,17 +71,65 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -70,17 +71,65 @@ int ElasticCTRPredictionOp::inference() {
return
0
;
return
0
;
}
}
Samples
samples
;
samples
.
resize
(
req
->
instances_size
());
for
(
int
i
=
0
;
i
<
req
->
instances_size
();
++
i
)
{
const
ReqInstance
&
req_instance
=
req
->
instances
(
i
);
for
(
int
j
=
0
;
j
<
req_instance
.
slots_size
();
++
j
)
{
const
Slot
&
slot
=
req_instance
.
slots
(
j
);
for
(
int
k
=
0
;
k
<
slot
.
feasigns
().
size
();
++
k
)
{
int
slot_id
=
strtol
(
slot
.
slot_name
().
c_str
(),
NULL
,
10
);
samples
[
i
][
slot_id
].
push_back
(
slot
.
feasigns
(
k
));
}
}
}
// Verify all request instances have same slots
// Verify all request instances have same slots
int
slot_num
=
req
->
instances
(
0
).
slots_size
();
std
::
vector
<
int
>
slot_ids
;
#if 1
for
(
auto
x
:
samples
[
0
])
{
LOG
(
INFO
)
<<
"slot_num ="
<<
slot_num
;
slot_ids
.
push_back
(
x
.
first
);
#endif
}
for
(
int
i
=
1
;
i
<
req
->
instances_size
();
++
i
)
{
std
::
sort
(
slot_ids
.
begin
(),
slot_ids
.
end
());
if
(
req
->
instances
(
i
).
slots_size
()
!=
slot_num
)
{
// use of slot_map:
//
// Example:
// slot_ids: 1, 20, 50, 100
//
// Then
// slot_map[1] = 0
// slot_map[20] = 1
// slot_map[50] = 2
// slot_map[100] = 3
//
// Later we use slot_map to index into lod_tenor array
//
std
::
map
<
int
,
int
>
slot_map
;
int
index
=
0
;
for
(
auto
slot_id
:
slot_ids
)
{
slot_map
[
slot_id
]
=
index
;
++
index
;
}
for
(
size_t
i
=
1
;
i
<
samples
.
size
();
++
i
)
{
if
(
samples
[
i
].
size
()
!=
slot_ids
.
size
())
{
LOG
(
WARNING
)
<<
"Req "
<<
i
LOG
(
WARNING
)
<<
"Req "
<<
i
<<
" has different slot num with that of req 0"
;
<<
" has different slot num with that of req 0"
;
fill_response_with_message
(
fill_response_with_message
(
res
,
-
1
,
"Req intance has varying slot numbers"
);
res
,
-
1
,
"Req intance has varying slot numbers"
);
return
0
;
}
for
(
auto
slot
:
samples
[
i
])
{
int
id
=
slot
.
first
;
auto
x
=
std
::
find
(
slot_ids
.
begin
(),
slot_ids
.
end
(),
id
);
if
(
x
==
slot_ids
.
end
())
{
std
::
ostringstream
oss
;
oss
<<
"Req instance "
<<
i
<<
" has an outlier slot id: "
<<
id
;
fill_response_with_message
(
res
,
-
1
,
oss
.
str
().
c_str
());
return
0
;
}
}
}
}
}
...
@@ -115,30 +164,27 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -115,30 +164,27 @@ int ElasticCTRPredictionOp::inference() {
// Level of details of each feature slot
// Level of details of each feature slot
std
::
vector
<
std
::
vector
<
size_t
>>
feature_slot_lods
;
std
::
vector
<
std
::
vector
<
size_t
>>
feature_slot_lods
;
feature_slot_lods
.
resize
(
slot_
num
);
feature_slot_lods
.
resize
(
slot_
ids
.
size
()
);
// Number of feature signs in each slot
// Number of feature signs in each slot
std
::
vector
<
int
>
feature_slot_sizes
;
std
::
vector
<
int
>
feature_slot_sizes
;
feature_slot_sizes
.
resize
(
slot_
num
);
feature_slot_sizes
.
resize
(
slot_
ids
.
size
()
);
// Iterate over each feature slot
// Iterate over each feature slot
for
(
int
i
=
0
;
i
<
slot_num
;
++
i
)
{
for
(
auto
slot_id
:
slot_ids
)
{
feature_slot_lods
[
i
].
push_back
(
0
);
feature_slot_lods
[
slot_map
[
slot_id
]
].
push_back
(
0
);
feature_slot_sizes
[
i
]
=
0
;
feature_slot_sizes
[
slot_map
[
slot_id
]
]
=
0
;
// Extract feature i values from each instance si
// Extract feature i values from each instance si
for
(
int
si
=
0
;
si
<
sample_size
;
++
si
)
{
for
(
size_t
si
=
0
;
si
<
samples
.
size
();
++
si
)
{
#if 1
Sample
&
sample
=
samples
[
si
];
LOG
(
INFO
)
<<
"slot "
<<
i
<<
" sample "
<<
si
;
std
::
vector
<
int64_t
>
&
slot
=
sample
[
slot_id
];
#endif
feature_slot_lods
[
slot_map
[
slot_id
]].
push_back
(
feature_slot_lods
[
slot_map
[
slot_id
]].
back
()
+
const
ReqInstance
&
req_instance
=
req
->
instances
(
si
);
slot
.
size
());
const
Slot
&
slot
=
req_instance
.
slots
(
i
);
feature_slot_sizes
[
slot_map
[
slot_id
]]
+=
slot
.
size
();
feature_slot_lods
[
i
].
push_back
(
feature_slot_lods
[
i
].
back
()
+
slot
.
feasigns_size
());
for
(
size_t
j
=
0
;
j
<
slot
.
size
();
++
j
)
{
feature_slot_sizes
[
i
]
+=
slot
.
feasigns_size
();
keys
.
push_back
(
slot
[
j
]);
for
(
int
j
=
0
;
j
<
slot
.
feasigns_size
();
++
j
)
{
keys
.
push_back
(
slot
.
feasigns
(
j
));
}
}
}
}
}
}
...
@@ -234,10 +280,9 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -234,10 +280,9 @@ int ElasticCTRPredictionOp::inference() {
return
0
;
return
0
;
}
}
for
(
in
t
i
=
0
;
i
<
keys
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
keys
.
size
();
++
i
)
{
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
oss
<<
keys
[
i
]
<<
": "
;
oss
<<
keys
[
i
]
<<
": "
;
const
char
*
value
=
(
values
[
i
].
buff
.
data
());
if
(
values
[
i
].
buff
.
size
()
!=
if
(
values
[
i
].
buff
.
size
()
!=
sizeof
(
float
)
*
CTR_PREDICTION_EMBEDDING_SIZE
)
{
sizeof
(
float
)
*
CTR_PREDICTION_EMBEDDING_SIZE
)
{
LOG
(
WARNING
)
<<
"Key "
<<
keys
[
i
]
<<
" has values less than "
LOG
(
WARNING
)
<<
"Key "
<<
keys
[
i
]
<<
" has values less than "
...
@@ -256,21 +301,20 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -256,21 +301,20 @@ int ElasticCTRPredictionOp::inference() {
// Fill feature embedding into feed tensors
// Fill feature embedding into feed tensors
std
::
vector
<
paddle
::
PaddleTensor
>
lod_tensors
;
std
::
vector
<
paddle
::
PaddleTensor
>
lod_tensors
;
lod_tensors
.
resize
(
slot_
num
);
lod_tensors
.
resize
(
slot_
ids
.
size
()
);
const
ReqInstance
&
instance
=
req
->
instances
(
0
);
for
(
auto
slot_id
:
slot_ids
)
{
for
(
int
i
=
0
;
i
<
slot_num
;
++
i
)
{
paddle
::
PaddleTensor
&
lod_tensor
=
lod_tensors
[
slot_map
[
slot_id
]];
paddle
::
PaddleTensor
&
lod_tensor
=
lod_tensors
[
i
];
char
name
[
VARIABLE_NAME_LEN
];
char
name
[
VARIABLE_NAME_LEN
];
snprintf
(
name
,
snprintf
(
name
,
VARIABLE_NAME_LEN
,
VARIABLE_NAME_LEN
,
"embedding_%
s
.tmp_0"
,
"embedding_%
d
.tmp_0"
,
instance
.
slots
(
i
).
slot_name
().
c_str
()
);
slot_id
);
lod_tensor
.
name
=
std
::
string
(
name
);
lod_tensor
.
name
=
std
::
string
(
name
);
lod_tensor
s
[
i
]
.
dtype
=
paddle
::
PaddleDType
::
FLOAT32
;
lod_tensor
.
dtype
=
paddle
::
PaddleDType
::
FLOAT32
;
std
::
vector
<
std
::
vector
<
size_t
>>
&
lod
=
lod_tensor
s
[
i
]
.
lod
;
std
::
vector
<
std
::
vector
<
size_t
>>
&
lod
=
lod_tensor
.
lod
;
lod
.
resize
(
1
);
lod
.
resize
(
1
);
lod
[
0
].
push_back
(
0
);
lod
[
0
].
push_back
(
0
);
}
}
...
@@ -278,11 +322,11 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -278,11 +322,11 @@ int ElasticCTRPredictionOp::inference() {
int
base
=
0
;
int
base
=
0
;
// Iterate over all slots
// Iterate over all slots
for
(
int
i
=
0
;
i
<
slot_num
;
++
i
)
{
for
(
auto
slot_id
:
slot_ids
)
{
paddle
::
PaddleTensor
&
lod_tensor
=
lod_tensors
[
i
];
paddle
::
PaddleTensor
&
lod_tensor
=
lod_tensors
[
slot_map
[
slot_id
]
];
std
::
vector
<
std
::
vector
<
size_t
>>
&
lod
=
lod_tensor
.
lod
;
std
::
vector
<
std
::
vector
<
size_t
>>
&
lod
=
lod_tensor
.
lod
;
lod
[
0
]
=
feature_slot_lods
[
i
];
lod
[
0
]
=
feature_slot_lods
[
slot_map
[
slot_id
]
];
lod_tensor
.
shape
=
{
lod
[
0
].
back
(),
CTR_PREDICTION_EMBEDDING_SIZE
};
lod_tensor
.
shape
=
{
lod
[
0
].
back
(),
CTR_PREDICTION_EMBEDDING_SIZE
};
lod_tensor
.
data
.
Resize
(
lod
[
0
].
back
()
*
sizeof
(
float
)
*
lod_tensor
.
data
.
Resize
(
lod
[
0
].
back
()
*
sizeof
(
float
)
*
...
@@ -290,7 +334,7 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -290,7 +334,7 @@ int ElasticCTRPredictionOp::inference() {
int
offset
=
0
;
int
offset
=
0
;
// Copy all slot i feature embeddings to lod_tensor[i]
// Copy all slot i feature embeddings to lod_tensor[i]
for
(
uint32_t
j
=
0
;
j
<
feature_slot_sizes
[
i
];
++
j
)
{
for
(
uint32_t
j
=
0
;
j
<
feature_slot_sizes
[
slot_map
[
slot_id
]
];
++
j
)
{
float
*
data_ptr
=
static_cast
<
float
*>
(
lod_tensor
.
data
.
data
())
+
offset
;
float
*
data_ptr
=
static_cast
<
float
*>
(
lod_tensor
.
data
.
data
())
+
offset
;
int
idx
=
base
+
j
;
int
idx
=
base
+
j
;
...
@@ -303,19 +347,24 @@ int ElasticCTRPredictionOp::inference() {
...
@@ -303,19 +347,24 @@ int ElasticCTRPredictionOp::inference() {
return 0;
return 0;
#else
#else
// sizeof(float) * CTR_PREDICTION_EMBEDDING_SIZE = 36
// sizeof(float) * CTR_PREDICTION_EMBEDDING_SIZE = 36
#if 1
LOG
(
INFO
)
<<
"values["
<<
idx
<<
"].buff.size != 36"
;
#endif
values
[
idx
].
buff
.
append
(
36
,
'0'
);
values
[
idx
].
buff
.
append
(
36
,
'0'
);
#endif
#endif
}
}
memcpy
(
data_ptr
,
values
[
idx
].
buff
.
data
(),
values
[
idx
].
buff
.
size
());
memcpy
(
data_ptr
,
values
[
idx
].
buff
.
data
(),
values
[
idx
].
buff
.
size
());
offset
+=
CTR_PREDICTION_EMBEDDING_SIZE
;
offset
+=
CTR_PREDICTION_EMBEDDING_SIZE
;
}
}
in
->
push_back
(
lod_tensor
);
in
->
push_back
(
lod_tensor
);
// Bump base counter
// Bump base counter
base
+=
feature_slot_sizes
[
i
];
base
+=
feature_slot_sizes
[
slot_map
[
slot_id
]
];
}
}
#else
#else
// Fill all tensors
// Fill all tensors
...
...
elastic-ctr/serving/op/elastic_ctr_prediction_op.h
浏览文件 @
3d619b9b
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
#pragma once
#pragma once
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "elastic-ctr/serving/elastic_ctr_prediction.pb.h"
#include "elastic-ctr/serving/elastic_ctr_prediction.pb.h"
namespace
baidu
{
namespace
baidu
{
...
@@ -41,6 +33,8 @@ class ElasticCTRPredictionOp
...
@@ -41,6 +33,8 @@ class ElasticCTRPredictionOp
baidu
::
paddle_serving
::
predictor
::
elastic_ctr
::
Response
>
{
baidu
::
paddle_serving
::
predictor
::
elastic_ctr
::
Response
>
{
public:
public:
typedef
std
::
vector
<
paddle
::
PaddleTensor
>
TensorVector
;
typedef
std
::
vector
<
paddle
::
PaddleTensor
>
TensorVector
;
typedef
std
::
map
<
int
,
std
::
vector
<
int64_t
>>
Sample
;
typedef
std
::
vector
<
Sample
>
Samples
;
DECLARE_OP
(
ElasticCTRPredictionOp
);
DECLARE_OP
(
ElasticCTRPredictionOp
);
...
...
inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
3d619b9b
...
@@ -21,15 +21,7 @@
...
@@ -21,15 +21,7 @@
#include <vector>
#include <vector>
#include "configure/include/configure_parser.h"
#include "configure/include/configure_parser.h"
#include "configure/inferencer_configure.pb.h"
#include "configure/inferencer_configure.pb.h"
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "predictor/framework/infer.h"
#include "predictor/framework/infer.h"
namespace
baidu
{
namespace
baidu
{
...
...
inferencer-fluid-gpu/include/fluid_gpu_engine.h
浏览文件 @
3d619b9b
...
@@ -23,15 +23,7 @@
...
@@ -23,15 +23,7 @@
#include <vector>
#include <vector>
#include "configure/include/configure_parser.h"
#include "configure/include/configure_parser.h"
#include "configure/inferencer_configure.pb.h"
#include "configure/inferencer_configure.pb.h"
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include "predictor/framework/infer.h"
#include "predictor/framework/infer.h"
DECLARE_int32
(
gpuid
);
DECLARE_int32
(
gpuid
);
...
...
kvdb/include/kvdb/kvdb_impl.h
浏览文件 @
3d619b9b
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include <memory>
#include <memory>
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <functional>
class
AbstractKVDB
;
class
AbstractKVDB
;
class
FileReader
;
class
FileReader
;
class
ParamDict
;
class
ParamDict
;
...
...
predictor/src/pdserving.cpp
浏览文件 @
3d619b9b
...
@@ -215,8 +215,10 @@ int main(int argc, char** argv) {
...
@@ -215,8 +215,10 @@ int main(int argc, char** argv) {
}
}
LOG
(
INFO
)
<<
"Succ initialize cube"
;
LOG
(
INFO
)
<<
"Succ initialize cube"
;
#ifndef BCLOUD
// FATAL messages are output to stderr
// FATAL messages are output to stderr
FLAGS_stderrthreshold
=
3
;
FLAGS_stderrthreshold
=
3
;
#endif
if
(
ServerManager
::
instance
().
start_and_wait
()
!=
0
)
{
if
(
ServerManager
::
instance
().
start_and_wait
()
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed start server and wait!"
;
LOG
(
ERROR
)
<<
"Failed start server and wait!"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录