Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a8e39a97
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a8e39a97
编写于
2月 02, 2021
作者:
J
Jiawei Wang
提交者:
GitHub
2月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1008 from TeslaZhao/develop
Fix Bugs for batching predict of pipeline
上级
c0d58250
bb546615
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
8 deletion
+38
-8
python/pipeline/operator.py
python/pipeline/operator.py
+38
-8
未找到文件。
python/pipeline/operator.py
浏览文件 @
a8e39a97
...
...
@@ -709,11 +709,39 @@ class Op(object):
# combine samples to batch
one_input
=
preped_data_dict
[
data_ids
[
0
]]
feed_batch
=
[]
feed_dict
=
{}
input_offset
=
None
cur_offset
=
0
input_offset_dict
=
{}
if
isinstance
(
one_input
,
dict
):
# sample input
feed_batch
=
[
preped_data_dict
[
data_id
]
for
data_id
in
data_ids
]
input_offset
=
list
(
range
(
len
(
data_ids
)
+
1
))
if
len
(
data_ids
)
==
1
:
feed_batch
=
[
preped_data_dict
[
data_id
]
for
data_id
in
data_ids
]
else
:
for
data_id
in
data_ids
:
for
key
,
val
in
preped_data_dict
[
data_id
].
items
():
has_val
=
feed_dict
.
get
(
key
)
if
has_val
is
None
:
feed_dict
[
key
]
=
val
continue
# merge 2 np.arrray
if
isinstance
(
val
,
np
.
ndarray
):
feed_dict
[
key
]
=
np
.
append
(
feed_dict
[
key
],
val
,
axis
=
0
)
feed_batch
.
append
(
feed_dict
)
for
data_id
in
data_ids
:
start
=
cur_offset
for
key
,
val
in
preped_data_dict
[
data_id
].
items
():
if
isinstance
(
val
,
(
list
,
np
.
ndarray
)):
cur_offset
+=
len
(
val
)
else
:
cur_offset
+=
1
break
input_offset_dict
[
data_id
]
=
[
start
,
cur_offset
]
elif
isinstance
(
one_input
,
list
):
# batch input
input_offset
=
[
0
]
...
...
@@ -796,8 +824,10 @@ class Op(object):
for
name
in
var_names
:
lod_offset_name
=
"{}.lod"
.
format
(
name
)
if
lod_offset_name
in
var_names
:
_LOGGER
.
debug
(
"(log_id={}) {} {} is LodTensor"
.
format
(
typical_logid
,
op_info_prefix
,
name
))
_LOGGER
.
debug
(
"(log_id={}) {} {} is LodTensor. lod_offset_name:{}"
.
format
(
typical_logid
,
op_info_prefix
,
name
,
lod_offset_name
))
lod_var_names
.
add
(
name
)
lod_offset_names
.
add
(
lod_offset_name
)
...
...
@@ -812,8 +842,8 @@ class Op(object):
lod_offset_name
=
"{}.lod"
.
format
(
name
)
lod_offset
=
midped_batch
[
lod_offset_name
]
for
idx
,
data_id
in
enumerate
(
data_ids
):
data_offset_left
=
input_offset
[
idx
]
data_offset_right
=
input_offset
[
idx
+
1
]
data_offset_left
=
input_offset
_dict
[
data_id
][
0
]
data_offset_right
=
input_offset
_dict
[
data_id
][
1
]
lod_offset_left
=
lod_offset
[
data_offset_left
]
lod_offset_right
=
lod_offset
[
data_offset_right
]
midped_data_dict
[
data_id
][
name
]
=
value
[
...
...
@@ -823,8 +853,8 @@ class Op(object):
else
:
# normal tensor
for
idx
,
data_id
in
enumerate
(
data_ids
):
left
=
input_offset
[
idx
]
right
=
input_offset
[
idx
+
1
]
left
=
input_offset
_dict
[
data_id
][
0
]
right
=
input_offset
_dict
[
data_id
][
1
]
midped_data_dict
[
data_id
][
name
]
=
value
[
left
:
right
]
else
:
midped_data_dict
=
preped_data_dict
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录