Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
0a9c1f59
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0a9c1f59
编写于
11月 24, 2022
作者:
W
wanghuancoder
提交者:
GitHub
11月 24, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[multiprocessing] Eager tensor support pickle (#48179)
* eager tensot support pickle
上级
3f265815
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
10 addition
and
10 deletion
+10
-10
python/paddle/fluid/dataloader/dataloader_iter.py
python/paddle/fluid/dataloader/dataloader_iter.py
+2
-1
python/paddle/fluid/dataloader/worker.py
python/paddle/fluid/dataloader/worker.py
+7
-9
python/paddle/incubate/__init__.py
python/paddle/incubate/__init__.py
+1
-0
未找到文件。
python/paddle/fluid/dataloader/dataloader_iter.py
浏览文件 @
0a9c1f59
...
@@ -21,7 +21,6 @@ import logging
...
@@ -21,7 +21,6 @@ import logging
import
itertools
import
itertools
import
threading
import
threading
import
numpy
as
np
import
numpy
as
np
import
multiprocessing
from
collections
import
namedtuple
from
collections
import
namedtuple
from
paddle.fluid.framework
import
(
from
paddle.fluid.framework
import
(
_set_expected_place
,
_set_expected_place
,
...
@@ -422,6 +421,8 @@ class _DataLoaderIterMultiProcess(_DataLoaderIterBase):
...
@@ -422,6 +421,8 @@ class _DataLoaderIterMultiProcess(_DataLoaderIterBase):
self
.
_shutdown
=
False
self
.
_shutdown
=
False
def
_init_workers
(
self
):
def
_init_workers
(
self
):
import
paddle.incubate.multiprocessing
as
multiprocessing
# multiprocess worker and indice queue list initial as empty
# multiprocess worker and indice queue list initial as empty
self
.
_workers
=
[]
self
.
_workers
=
[]
self
.
_worker_status
=
[]
self
.
_worker_status
=
[]
...
...
python/paddle/fluid/dataloader/worker.py
浏览文件 @
0a9c1f59
...
@@ -373,21 +373,19 @@ def _worker_loop(
...
@@ -373,21 +373,19 @@ def _worker_loop(
out_queue
.
put
((
idx
,
batch
,
None
))
out_queue
.
put
((
idx
,
batch
,
None
))
batch
,
structure
=
_flatten_batch
(
batch
)
batch
,
structure
=
_flatten_batch
(
batch
)
if
use_shared_memory
:
if
use_shared_memory
:
# NOTE: In eager mode, Tensor._share_memory has no
# effect, fall back to _array_to_share_memory_tensor
def
numpy2lodtensor
(
arr
):
def
tensor_share_memory
(
tensor
):
lodtensor
=
core
.
Tensor
()
if
_in_eager_without_dygraph_check
():
lodtensor
.
set
(
arr
,
core
.
CPUPlace
())
return
core
.
_array_to_share_memory_tensor
(
tensor
)
return
lodtensor
return
tensor
.
_share_memory
()
tensor_list
=
[
tensor_list
=
[
core
.
_array_to_share_memory_
tensor
(
b
)
numpy2lod
tensor
(
b
)
if
isinstance
(
b
,
np
.
ndarray
)
if
isinstance
(
b
,
np
.
ndarray
)
else
tensor_share_memory
(
b
)
else
b
.
value
().
get_tensor
(
)
for
b
in
batch
for
b
in
batch
]
]
out_queue
.
put
((
idx
,
tensor_list
,
structure
))
out_queue
.
put
((
idx
,
tensor_list
,
structure
))
core
.
_remove_tensor_list_mmap_fds
(
tensor_list
)
else
:
else
:
out_queue
.
put
((
idx
,
batch
,
structure
))
out_queue
.
put
((
idx
,
batch
,
structure
))
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
...
...
python/paddle/incubate/__init__.py
浏览文件 @
0a9c1f59
...
@@ -34,6 +34,7 @@ from . import autograd # noqa: F401
...
@@ -34,6 +34,7 @@ from . import autograd # noqa: F401
from
.
import
autotune
# noqa: F401
from
.
import
autotune
# noqa: F401
from
.
import
nn
# noqa: F401
from
.
import
nn
# noqa: F401
from
.
import
asp
# noqa: F401
from
.
import
asp
# noqa: F401
from
.
import
multiprocessing
# noqa: F401
from
..fluid.layers.loss
import
identity_loss
from
..fluid.layers.loss
import
identity_loss
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录