Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ed7903cd
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ed7903cd
编写于
7月 09, 2021
作者:
K
Kaipeng Deng
提交者:
GitHub
7月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make DataLoader warning less noisy. test=develop (#34001)
上级
8417ad60
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
8 deletion
+16
-8
python/paddle/fluid/dataloader/fetcher.py
python/paddle/fluid/dataloader/fetcher.py
+16
-8
未找到文件。
python/paddle/fluid/dataloader/fetcher.py
浏览文件 @
ed7903cd
...
@@ -14,8 +14,9 @@
...
@@ -14,8 +14,9 @@
import
logging
import
logging
from
..log_helper
import
get_logger
from
..log_helper
import
get_logger
from
collections.abc
import
Sequence
,
Mapping
from
collections.abc
import
Sequenc
e
_WARNING_TO_LOG
=
Tru
e
class
_DatasetFetcher
(
object
):
class
_DatasetFetcher
(
object
):
...
@@ -24,13 +25,17 @@ class _DatasetFetcher(object):
...
@@ -24,13 +25,17 @@ class _DatasetFetcher(object):
self
.
auto_collate_batch
=
auto_collate_batch
self
.
auto_collate_batch
=
auto_collate_batch
self
.
collate_fn
=
collate_fn
self
.
collate_fn
=
collate_fn
self
.
drop_last
=
drop_last
self
.
drop_last
=
drop_last
self
.
_is_warning_logged
=
False
def
fetch
(
self
,
batch_indices
):
def
fetch
(
self
,
batch_indices
):
raise
NotImplementedError
(
"'fetch' not implement for class {}"
.
format
(
raise
NotImplementedError
(
"'fetch' not implement for class {}"
.
format
(
self
.
__class__
.
__name__
))
self
.
__class__
.
__name__
))
def
_log_warning
(
self
):
def
_log_warning
(
self
):
# only log warning on GPU 0 when distributed launch
from
...distributed
import
get_world_size
,
get_rank
if
get_world_size
()
>=
2
and
get_rank
()
!=
0
:
return
warn_str
=
"Detect dataset only contains single fileds, return format "
\
warn_str
=
"Detect dataset only contains single fileds, return format "
\
"changed since Paddle 2.1. In Paddle <= 2.0, DataLoader add "
\
"changed since Paddle 2.1. In Paddle <= 2.0, DataLoader add "
\
"a list surround output data(e.g. return [data]), and in "
\
"a list surround output data(e.g. return [data]), and in "
\
...
@@ -77,10 +82,12 @@ class _IterableDatasetFetcher(_DatasetFetcher):
...
@@ -77,10 +82,12 @@ class _IterableDatasetFetcher(_DatasetFetcher):
if
len
(
data
)
==
0
or
(
self
.
drop_last
and
if
len
(
data
)
==
0
or
(
self
.
drop_last
and
len
(
data
)
<
len
(
batch_indices
)):
len
(
data
)
<
len
(
batch_indices
)):
raise
StopIteration
raise
StopIteration
if
not
isinstance
(
data
[
0
],
Sequence
)
and
not
self
.
_is_warning_logged
:
global
_WARNING_TO_LOG
if
not
isinstance
(
data
[
0
],
(
Sequence
,
Mapping
))
\
and
_WARNING_TO_LOG
:
self
.
_log_warning
()
self
.
_log_warning
()
self
.
_is_warning_logged
=
Tru
e
_WARNING_TO_LOG
=
Fals
e
else
:
else
:
data
=
next
(
self
.
dataset_iter
)
data
=
next
(
self
.
dataset_iter
)
...
@@ -98,10 +105,11 @@ class _MapDatasetFetcher(_DatasetFetcher):
...
@@ -98,10 +105,11 @@ class _MapDatasetFetcher(_DatasetFetcher):
if
self
.
auto_collate_batch
:
if
self
.
auto_collate_batch
:
data
=
[
self
.
dataset
[
idx
]
for
idx
in
batch_indices
]
data
=
[
self
.
dataset
[
idx
]
for
idx
in
batch_indices
]
if
not
isinstance
(
data
[
0
],
global
_WARNING_TO_LOG
Sequence
)
and
not
self
.
_is_warning_logged
:
if
not
isinstance
(
data
[
0
],
(
Sequence
,
Mapping
))
\
and
_WARNING_TO_LOG
:
self
.
_log_warning
()
self
.
_log_warning
()
self
.
_is_warning_logged
=
Tru
e
_WARNING_TO_LOG
=
Fals
e
else
:
else
:
data
=
self
.
dataset
[
batch_indices
]
data
=
self
.
dataset
[
batch_indices
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录