Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7b5a9d75
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
7b5a9d75
编写于
2月 27, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cache reader
test=develop
上级
69b1ebdf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
3 deletion
+31
-3
paddle/fluid/API.spec
paddle/fluid/API.spec
+1
-0
python/paddle/fluid/reader.py
python/paddle/fluid/reader.py
+4
-2
python/paddle/reader/decorator.py
python/paddle/reader/decorator.py
+26
-1
未找到文件。
paddle/fluid/API.spec
浏览文件 @
7b5a9d75
...
@@ -511,6 +511,7 @@ paddle.fluid.unique_name.guard ArgSpec(args=['new_generator'], varargs=None, key
...
@@ -511,6 +511,7 @@ paddle.fluid.unique_name.guard ArgSpec(args=['new_generator'], varargs=None, key
paddle.fluid.recordio_writer.convert_reader_to_recordio_file ArgSpec(args=['filename', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None))
paddle.fluid.recordio_writer.convert_reader_to_recordio_file ArgSpec(args=['filename', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None))
paddle.fluid.recordio_writer.convert_reader_to_recordio_files ArgSpec(args=['filename', 'batch_per_file', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None))
paddle.fluid.recordio_writer.convert_reader_to_recordio_files ArgSpec(args=['filename', 'batch_per_file', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None))
paddle.fluid.Scope Scope() -> paddle.fluid.core._Scope
paddle.fluid.Scope Scope() -> paddle.fluid.core._Scope
paddle.reader.cache ArgSpec(args=['reader'], varargs=None, keywords=None, defaults=None)
paddle.reader.map_readers ArgSpec(args=['func'], varargs='readers', keywords=None, defaults=None)
paddle.reader.map_readers ArgSpec(args=['func'], varargs='readers', keywords=None, defaults=None)
paddle.reader.buffered ArgSpec(args=['reader', 'size'], varargs=None, keywords=None, defaults=None)
paddle.reader.buffered ArgSpec(args=['reader', 'size'], varargs=None, keywords=None, defaults=None)
paddle.reader.compose ArgSpec(args=[], varargs='readers', keywords='kwargs', defaults=None)
paddle.reader.compose ArgSpec(args=[], varargs='readers', keywords='kwargs', defaults=None)
...
...
python/paddle/fluid/reader.py
浏览文件 @
7b5a9d75
...
@@ -123,7 +123,6 @@ class PyReader(object):
...
@@ -123,7 +123,6 @@ class PyReader(object):
self
.
_use_double_buffer
=
use_double_buffer
self
.
_use_double_buffer
=
use_double_buffer
self
.
_capacity
=
capacity
self
.
_capacity
=
capacity
self
.
_feed_list
=
feed_list
self
.
_feed_list
=
feed_list
self
.
_scope
=
global_scope
()
if
not
self
.
_iterable
:
if
not
self
.
_iterable
:
self
.
_init_non_iterable
()
self
.
_init_non_iterable
()
...
@@ -153,7 +152,7 @@ class PyReader(object):
...
@@ -153,7 +152,7 @@ class PyReader(object):
reader_name
=
PyReader
.
unique_name_generator
(
'create_py_reader'
)
reader_name
=
PyReader
.
unique_name_generator
(
'create_py_reader'
)
double_buffer_name
=
PyReader
.
unique_name_generator
(
'double_buffer'
)
double_buffer_name
=
PyReader
.
unique_name_generator
(
'double_buffer'
)
var
=
self
.
_scope
.
var
(
queue_name
)
var
=
global_scope
()
.
var
(
queue_name
)
self
.
_queue
=
core
.
init_lod_tensor_blocking_queue
(
var
,
self
.
_capacity
)
self
.
_queue
=
core
.
init_lod_tensor_blocking_queue
(
var
,
self
.
_capacity
)
startup_blk
=
default_startup_program
().
current_block
()
startup_blk
=
default_startup_program
().
current_block
()
...
@@ -215,6 +214,9 @@ class PyReader(object):
...
@@ -215,6 +214,9 @@ class PyReader(object):
def
__iter__
(
self
):
def
__iter__
(
self
):
return
self
return
self
def
__next__
(
self
):
return
self
.
next
()
def
next
(
self
):
def
next
(
self
):
ret
=
self
.
_reader
.
read_next
()
ret
=
self
.
_reader
.
read_next
()
if
ret
:
if
ret
:
...
...
python/paddle/reader/decorator.py
浏览文件 @
7b5a9d75
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
__all__
=
[
__all__
=
[
'map_readers'
,
'buffered'
,
'compose'
,
'chain'
,
'shuffle'
,
'
cache'
,
'
map_readers'
,
'buffered'
,
'compose'
,
'chain'
,
'shuffle'
,
'ComposeNotAligned'
,
'firstn'
,
'xmap_readers'
,
'PipeReader'
,
'ComposeNotAligned'
,
'firstn'
,
'xmap_readers'
,
'PipeReader'
,
'multiprocess_reader'
,
'Fake'
'multiprocess_reader'
,
'Fake'
]
]
...
@@ -33,6 +33,31 @@ import zlib
...
@@ -33,6 +33,31 @@ import zlib
import
paddle.compat
as
cpt
import
paddle.compat
as
cpt
def
cache
(
reader
):
"""
Cache the reader data into memory.
Be careful that this method may take long time to process,
and consume lots of memory. :code:`reader()` would only
call once.
Args:
reader (generator): a reader object which yields
data each time.
Returns:
reader (generator): a decorated reader object
which yields data from cached memory.
"""
all_data
=
tuple
(
reader
())
def
__impl__
():
for
item
in
all_data
:
yield
item
return
__impl__
def
map_readers
(
func
,
*
readers
):
def
map_readers
(
func
,
*
readers
):
"""
"""
Creates a data reader that outputs return value of function using
Creates a data reader that outputs return value of function using
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录