Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
62d2d295
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看板
提交
62d2d295
编写于
4月 25, 2020
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make serving compatible with grpc
上级
372800b8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
17 addition
and
12 deletion
+17
-12
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+7
-4
core/predictor/common/macros.h
core/predictor/common/macros.h
+3
-3
core/sdk-cpp/include/stub_impl.h
core/sdk-cpp/include/stub_impl.h
+4
-2
core/sdk-cpp/include/stub_impl.hpp
core/sdk-cpp/include/stub_impl.hpp
+3
-3
未找到文件。
core/general-client/src/general_model.cpp
浏览文件 @
62d2d295
...
@@ -119,7 +119,7 @@ int PredictorClient::create_predictor_by_desc(const std::string &sdk_desc) {
...
@@ -119,7 +119,7 @@ int PredictorClient::create_predictor_by_desc(const std::string &sdk_desc) {
LOG
(
ERROR
)
<<
"Predictor Creation Failed"
;
LOG
(
ERROR
)
<<
"Predictor Creation Failed"
;
return
-
1
;
return
-
1
;
}
}
_api
.
thrd_initialize
();
//
_api.thrd_initialize();
return
0
;
return
0
;
}
}
...
@@ -130,7 +130,7 @@ int PredictorClient::create_predictor() {
...
@@ -130,7 +130,7 @@ int PredictorClient::create_predictor() {
LOG
(
ERROR
)
<<
"Predictor Creation Failed"
;
LOG
(
ERROR
)
<<
"Predictor Creation Failed"
;
return
-
1
;
return
-
1
;
}
}
_api
.
thrd_initialize
();
//
_api.thrd_initialize();
return
0
;
return
0
;
}
}
...
@@ -152,7 +152,7 @@ int PredictorClient::batch_predict(
...
@@ -152,7 +152,7 @@ int PredictorClient::batch_predict(
int
fetch_name_num
=
fetch_name
.
size
();
int
fetch_name_num
=
fetch_name
.
size
();
_api
.
thrd_
clear
();
_api
.
thrd_
initialize
();
std
::
string
variant_tag
;
std
::
string
variant_tag
;
_predictor
=
_api
.
fetch_predictor
(
"general_model"
,
&
variant_tag
);
_predictor
=
_api
.
fetch_predictor
(
"general_model"
,
&
variant_tag
);
predict_res_batch
.
set_variant_tag
(
variant_tag
);
predict_res_batch
.
set_variant_tag
(
variant_tag
);
...
@@ -247,8 +247,9 @@ int PredictorClient::batch_predict(
...
@@ -247,8 +247,9 @@ int PredictorClient::batch_predict(
}
else
{
}
else
{
client_infer_end
=
timeline
.
TimeStampUS
();
client_infer_end
=
timeline
.
TimeStampUS
();
postprocess_start
=
client_infer_end
;
postprocess_start
=
client_infer_end
;
VLOG
(
2
)
<<
"get model output num"
;
uint32_t
model_num
=
res
.
outputs_size
();
uint32_t
model_num
=
res
.
outputs_size
();
VLOG
(
2
)
<<
"model num: "
<<
model_num
;
for
(
uint32_t
m_idx
=
0
;
m_idx
<
model_num
;
++
m_idx
)
{
for
(
uint32_t
m_idx
=
0
;
m_idx
<
model_num
;
++
m_idx
)
{
VLOG
(
2
)
<<
"process model output index: "
<<
m_idx
;
VLOG
(
2
)
<<
"process model output index: "
<<
m_idx
;
auto
output
=
res
.
outputs
(
m_idx
);
auto
output
=
res
.
outputs
(
m_idx
);
...
@@ -326,6 +327,8 @@ int PredictorClient::batch_predict(
...
@@ -326,6 +327,8 @@ int PredictorClient::batch_predict(
fprintf
(
stderr
,
"%s
\n
"
,
oss
.
str
().
c_str
());
fprintf
(
stderr
,
"%s
\n
"
,
oss
.
str
().
c_str
());
}
}
_api
.
thrd_clear
();
return
0
;
return
0
;
}
}
...
...
core/predictor/common/macros.h
浏览文件 @
62d2d295
...
@@ -27,9 +27,9 @@ namespace predictor {
...
@@ -27,9 +27,9 @@ namespace predictor {
}
}
#endif
#endif
#ifdef WITH_GPU
//
#ifdef WITH_GPU
#define USE_PTHREAD
//
#define USE_PTHREAD
#endif
//
#endif
#ifdef USE_PTHREAD
#ifdef USE_PTHREAD
...
...
core/sdk-cpp/include/stub_impl.h
浏览文件 @
62d2d295
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include <vector>
#include <vector>
#include "core/sdk-cpp/include/common.h"
#include "core/sdk-cpp/include/common.h"
#include "core/sdk-cpp/include/endpoint_config.h"
#include "core/sdk-cpp/include/endpoint_config.h"
#include "core/sdk-cpp/include/macros.h"
#include "core/sdk-cpp/include/predictor.h"
#include "core/sdk-cpp/include/predictor.h"
#include "core/sdk-cpp/include/stub.h"
#include "core/sdk-cpp/include/stub.h"
...
@@ -245,7 +246,7 @@ class StubImpl : public Stub {
...
@@ -245,7 +246,7 @@ class StubImpl : public Stub {
const
brpc
::
ChannelOptions
&
options
);
const
brpc
::
ChannelOptions
&
options
);
StubTLS
*
get_tls
()
{
StubTLS
*
get_tls
()
{
return
static_cast
<
StubTLS
*>
(
bthread_getspecific
(
_bthread_key
));
return
static_cast
<
StubTLS
*>
(
THREAD_GETSPECIFIC
(
_bthread_key
));
}
}
private:
private:
...
@@ -262,7 +263,8 @@ class StubImpl : public Stub {
...
@@ -262,7 +263,8 @@ class StubImpl : public Stub {
uint32_t
_package_size
;
uint32_t
_package_size
;
// tls handlers
// tls handlers
bthread_key_t
_bthread_key
;
// bthread_key_t _bthread_key;
THREAD_KEY_T
_bthread_key
;
// bvar variables
// bvar variables
std
::
map
<
std
::
string
,
BvarWrapper
*>
_ltc_bvars
;
std
::
map
<
std
::
string
,
BvarWrapper
*>
_ltc_bvars
;
...
...
core/sdk-cpp/include/stub_impl.hpp
浏览文件 @
62d2d295
...
@@ -70,7 +70,7 @@ int StubImpl<T, C, R, I, O>::initialize(const VariantInfo& var,
...
@@ -70,7 +70,7 @@ int StubImpl<T, C, R, I, O>::initialize(const VariantInfo& var,
_endpoint
=
ep
;
_endpoint
=
ep
;
if
(
bthread_key_create
(
&
_bthread_key
,
NULL
)
!=
0
)
{
if
(
THREAD_KEY_CREATE
(
&
_bthread_key
,
NULL
)
!=
0
)
{
LOG
(
FATAL
)
<<
"Failed create key for stub tls"
;
LOG
(
FATAL
)
<<
"Failed create key for stub tls"
;
return
-
1
;
return
-
1
;
}
}
...
@@ -132,13 +132,13 @@ int StubImpl<T, C, R, I, O>::initialize(const VariantInfo& var,
...
@@ -132,13 +132,13 @@ int StubImpl<T, C, R, I, O>::initialize(const VariantInfo& var,
template
<
typename
T
,
typename
C
,
typename
R
,
typename
I
,
typename
O
>
template
<
typename
T
,
typename
C
,
typename
R
,
typename
I
,
typename
O
>
int
StubImpl
<
T
,
C
,
R
,
I
,
O
>::
thrd_initialize
()
{
int
StubImpl
<
T
,
C
,
R
,
I
,
O
>::
thrd_initialize
()
{
if
(
bthread_getspecific
(
_bthread_key
)
!=
NULL
)
{
if
(
THREAD_GETSPECIFIC
(
_bthread_key
)
!=
NULL
)
{
LOG
(
WARNING
)
<<
"Already thread initialized for stub"
;
LOG
(
WARNING
)
<<
"Already thread initialized for stub"
;
return
0
;
return
0
;
}
}
StubTLS
*
tls
=
new
(
std
::
nothrow
)
StubTLS
();
StubTLS
*
tls
=
new
(
std
::
nothrow
)
StubTLS
();
if
(
!
tls
||
bthread_setspecific
(
_bthread_key
,
tls
)
!=
0
)
{
if
(
!
tls
||
THREAD_SETSPECIFIC
(
_bthread_key
,
tls
)
!=
0
)
{
LOG
(
FATAL
)
<<
"Failed binding tls data to bthread_key"
;
LOG
(
FATAL
)
<<
"Failed binding tls data to bthread_key"
;
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录