Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
caa573f7
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看板
提交
caa573f7
编写于
5月 25, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine serving io
上级
ca754e46
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
26 deletion
+22
-26
core/general-server/op/general_response_op.cpp
core/general-server/op/general_response_op.cpp
+15
-24
python/paddle_serving_client/io/__init__.py
python/paddle_serving_client/io/__init__.py
+7
-2
未找到文件。
core/general-server/op/general_response_op.cpp
浏览文件 @
caa573f7
...
...
@@ -89,50 +89,41 @@ int GeneralResponseOp::inference() {
output
->
set_engine_name
(
pre_name
);
FetchInst
*
fetch_inst
=
output
->
add_insts
();
std
::
map
<
std
::
string
,
int
>
fetch_index_map
;
for
(
int
i
=
0
;
i
<
in
->
size
();
++
i
)
{
VLOG
(
2
)
<<
"index "
<<
i
<<
" var "
<<
in
->
at
(
i
).
name
;
fetch_index_map
.
insert
(
std
::
pair
<
std
::
string
,
int
>
(
in
->
at
(
i
).
name
,
i
));
}
for
(
auto
&
idx
:
fetch_index
)
{
Tensor
*
tensor
=
fetch_inst
->
add_tensor_array
();
tensor
->
set_elem_type
(
1
);
int
true_idx
=
fetch_index_map
[
model_config
->
_fetch_name
[
idx
]];
if
(
model_config
->
_is_lod_fetch
[
idx
])
{
VLOG
(
2
)
<<
"out["
<<
idx
<<
"] "
<<
model_config
->
_fetch_name
[
idx
]
<<
" is lod_tensor"
;
for
(
int
k
=
0
;
k
<
in
->
at
(
true_
idx
).
shape
.
size
();
++
k
)
{
for
(
int
k
=
0
;
k
<
in
->
at
(
idx
).
shape
.
size
();
++
k
)
{
VLOG
(
2
)
<<
"shape["
<<
k
<<
"]: "
<<
in
->
at
(
idx
).
shape
[
k
];
tensor
->
add_shape
(
in
->
at
(
true_
idx
).
shape
[
k
]);
tensor
->
add_shape
(
in
->
at
(
idx
).
shape
[
k
]);
}
}
else
{
VLOG
(
2
)
<<
"out["
<<
idx
<<
"] "
<<
model_config
->
_fetch_name
[
idx
]
<<
" is tensor"
;
for
(
int
k
=
0
;
k
<
in
->
at
(
true_
idx
).
shape
.
size
();
++
k
)
{
VLOG
(
2
)
<<
"shape["
<<
k
<<
"]: "
<<
in
->
at
(
true_
idx
).
shape
[
k
];
tensor
->
add_shape
(
in
->
at
(
true_
idx
).
shape
[
k
]);
for
(
int
k
=
0
;
k
<
in
->
at
(
idx
).
shape
.
size
();
++
k
)
{
VLOG
(
2
)
<<
"shape["
<<
k
<<
"]: "
<<
in
->
at
(
idx
).
shape
[
k
];
tensor
->
add_shape
(
in
->
at
(
idx
).
shape
[
k
]);
}
}
}
int
var_idx
=
0
;
for
(
auto
&
idx
:
fetch_index
)
{
int
true_idx
=
fetch_index_map
[
model_config
->
_fetch_name
[
idx
]];
int
cap
=
1
;
for
(
int
j
=
0
;
j
<
in
->
at
(
true_
idx
).
shape
.
size
();
++
j
)
{
cap
*=
in
->
at
(
true_
idx
).
shape
[
j
];
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
shape
.
size
();
++
j
)
{
cap
*=
in
->
at
(
idx
).
shape
[
j
];
}
if
(
in
->
at
(
true_
idx
).
dtype
==
paddle
::
PaddleDType
::
INT64
)
{
if
(
in
->
at
(
idx
).
dtype
==
paddle
::
PaddleDType
::
INT64
)
{
VLOG
(
2
)
<<
"Prepare float var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"]."
;
int64_t
*
data_ptr
=
static_cast
<
int64_t
*>
(
in
->
at
(
true_idx
).
data
.
data
());
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
(
true_
idx
).
lod
[
0
].
size
();
++
j
)
{
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
lod
[
0
].
size
();
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_lod
(
in
->
at
(
true_
idx
).
lod
[
0
][
j
]);
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
]);
...
...
@@ -145,15 +136,15 @@ int GeneralResponseOp::inference() {
}
VLOG
(
2
)
<<
"fetch var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"] ready"
;
var_idx
++
;
}
else
if
(
in
->
at
(
true_
idx
).
dtype
==
paddle
::
PaddleDType
::
FLOAT32
)
{
}
else
if
(
in
->
at
(
idx
).
dtype
==
paddle
::
PaddleDType
::
FLOAT32
)
{
VLOG
(
2
)
<<
"Prepare float var ["
<<
model_config
->
_fetch_name
[
idx
]
<<
"]."
;
float
*
data_ptr
=
static_cast
<
float
*>
(
in
->
at
(
true_
idx
).
data
.
data
());
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
(
true_
idx
).
lod
[
0
].
size
();
++
j
)
{
for
(
int
j
=
0
;
j
<
in
->
at
(
idx
).
lod
[
0
].
size
();
++
j
)
{
fetch_p
->
mutable_tensor_array
(
var_idx
)
->
add_lod
(
in
->
at
(
true_
idx
).
lod
[
0
][
j
]);
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
]);
...
...
python/paddle_serving_client/io/__init__.py
浏览文件 @
caa573f7
...
...
@@ -33,7 +33,12 @@ def save_model(server_model_folder,
executor
=
Executor
(
place
=
CPUPlace
())
feed_var_names
=
[
feed_var_dict
[
x
].
name
for
x
in
feed_var_dict
]
target_vars
=
list
(
fetch_var_dict
.
values
())
#target_vars = list(fetch_var_dict.values())
target_vars
=
[]
target_var_names
=
[]
for
key
in
sorted
(
fetch_var_dict
.
keys
()):
target_vars
.
append
(
fetch_var_dict
[
key
])
target_var_names
.
append
(
key
)
save_inference_model
(
server_model_folder
,
...
...
@@ -64,7 +69,7 @@ def save_model(server_model_folder,
feed_var
.
shape
.
extend
(
tmp_shape
)
config
.
feed_var
.
extend
([
feed_var
])
for
key
in
fetch_var_dict
:
for
key
in
target_var_names
:
fetch_var
=
model_conf
.
FetchVar
()
fetch_var
.
alias_name
=
key
fetch_var
.
name
=
fetch_var_dict
[
key
].
name
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录