Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
61b22ada
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看板
提交
61b22ada
编写于
7月 05, 2020
作者:
W
WangXi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize performance of server response
Signed-off-by:
N
WangXi
<
wangxi16@baidu.com
>
上级
33a32af7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
31 addition
and
53 deletion
+31
-53
core/general-server/op/general_response_op.cpp
core/general-server/op/general_response_op.cpp
+31
-53
未找到文件。
core/general-server/op/general_response_op.cpp
浏览文件 @
61b22ada
...
...
@@ -114,72 +114,50 @@ int GeneralResponseOp::inference() {
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
shape
.
size
();
++
j
)
{
cap
*=
in
->
at
(
idx
).
shape
[
j
];
}
if
(
in
->
at
(
idx
).
dtype
==
paddle
::
PaddleDType
::
INT64
)
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
auto
dtype
=
in
->
at
(
idx
).
dtype
;
if
(
dtype
==
paddle
::
PaddleDType
::
INT64
)
{
VLOG
(
2
)
<<
"Prepare int64 var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"]."
;
int64_t
*
data_ptr
=
static_cast
<
int64_t
*>
(
in
->
at
(
idx
).
data
.
data
());
if
(
model_config
->
_is_lod_fetch
[
idx
])
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
lod
[
0
].
size
();
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_lod
(
in
->
at
(
idx
).
lod
[
0
][
j
]);
}
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_int64_data
(
data_ptr
[
j
]);
}
}
else
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_int64_data
(
data_ptr
[
j
]);
}
}
VLOG
(
2
)
<<
"fetch var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"] ready"
;
var_idx
++
;
}
else
if
(
in
->
at
(
idx
).
dtype
==
paddle
::
PaddleDType
::
FLOAT32
)
{
// from
// https://stackoverflow.com/questions/15499641/copy-a-stdvector-to-a-repeated-field-from-protobuf-with-memcpy
// `Swap` method is faster than `{}` method.
google
::
protobuf
::
RepeatedField
<
int64_t
>
tmp_data
(
data_ptr
,
data_ptr
+
cap
);
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
mutable_int64_data
()
->
Swap
(
&
tmp_data
);
}
else
if
(
dtype
==
paddle
::
PaddleDType
::
FLOAT32
)
{
VLOG
(
2
)
<<
"Prepare float var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"]."
;
float
*
data_ptr
=
static_cast
<
float
*>
(
in
->
at
(
idx
).
data
.
data
());
if
(
model_config
->
_is_lod_fetch
[
idx
])
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
lod
[
0
].
size
();
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_lod
(
in
->
at
(
idx
).
lod
[
0
][
j
]);
}
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_float_data
(
data_ptr
[
j
]);
}
}
else
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_float_data
(
data_ptr
[
j
]);
}
}
VLOG
(
2
)
<<
"fetch var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"] ready"
;
var_idx
++
;
}
else
if
(
in
->
at
(
idx
).
dtype
==
paddle
::
PaddleDType
::
INT32
)
{
google
::
protobuf
::
RepeatedField
<
float
>
tmp_data
(
data_ptr
,
data_ptr
+
cap
);
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
mutable_float_data
()
->
Swap
(
&
tmp_data
);
}
else
if
(
dtype
==
paddle
::
PaddleDType
::
INT32
)
{
VLOG
(
2
)
<<
"Prepare int32 var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"]."
;
int32_t
*
data_ptr
=
static_cast
<
int32_t
*>
(
in
->
at
(
idx
).
data
.
data
());
google
::
protobuf
::
RepeatedField
<
int32_t
>
tmp_data
(
data_ptr
,
data_ptr
+
cap
);
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
mutable_int_data
()
->
Swap
(
&
tmp_data
);
}
if
(
model_config
->
_is_lod_fetch
[
idx
])
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
lod
[
0
].
size
();
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_lod
(
in
->
at
(
idx
).
lod
[
0
][
j
]);
}
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_int_data
(
data_ptr
[
j
]);
}
}
else
{
FetchInst
*
fetch_p
=
output
->
mutable_insts
(
0
);
for
(
int
j
=
0
;
j
<
cap
;
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_int_data
(
data_ptr
[
j
]);
}
}
VLOG
(
2
)
<<
"fetch var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"] ready"
;
var_idx
++
;
}
}
}
if
(
req
->
profile_server
())
{
int64_t
end
=
timeline
.
TimeStampUS
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录