Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
164f2382
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
164f2382
编写于
3月 13, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish code
上级
f9974a4a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
6 addition
and
64 deletion
+6
-64
paddle/fluid/framework/reader.cc
paddle/fluid/framework/reader.cc
+2
-38
paddle/fluid/framework/reader.h
paddle/fluid/framework/reader.h
+2
-23
paddle/fluid/operators/reader/create_double_buffer_reader_op.cc
.../fluid/operators/reader/create_double_buffer_reader_op.cc
+0
-1
paddle/fluid/operators/reader/create_recordio_file_reader_op.cc
.../fluid/operators/reader/create_recordio_file_reader_op.cc
+2
-2
未找到文件。
paddle/fluid/framework/reader.cc
浏览文件 @
164f2382
...
...
@@ -18,45 +18,9 @@ namespace paddle {
namespace
framework
{
ReaderBase
::~
ReaderBase
()
{}
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
ReaderBase
::
SplitReader
(
const
platform
::
PlaceList
&
places
)
{
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
readers
;
FileReader
::
FileReader
(
const
std
::
vector
<
DDim
>
&
dims
)
:
dims_
(
dims
)
{}
auto
mutex
=
std
::
make_shared
<
std
::
mutex
>
();
for
(
size_t
i
=
0
;
i
<
places
.
size
();
++
i
)
{
readers
.
emplace_back
(
new
ThreadSafeReader
(
this
,
mutex
));
}
return
readers
;
}
void
ThreadSafeReader
::
ReadNext
(
std
::
vector
<
LoDTensor
>
*
out
)
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
mutex_
);
reader_
->
ReadNext
(
out
);
}
void
ThreadSafeReader
::
ReInit
()
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
mutex_
);
reader_
->
ReInit
();
}
bool
ThreadSafeReader
::
HasNext
()
const
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
mutex_
);
return
reader_
->
HasNext
();
}
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
ThreadSafeReader
::
SplitReader
(
const
platform
::
PlaceList
&
places
)
{
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
readers
;
for
(
size_t
i
=
0
;
i
<
places
.
size
();
++
i
)
{
readers
.
emplace_back
(
new
ThreadSafeReader
(
reader_
,
mutex_
));
}
return
readers
;
}
FileReaderBase
::
FileReaderBase
(
const
std
::
vector
<
DDim
>
&
dims
)
:
dims_
(
dims
)
{}
void
FileReaderBase
::
ReadNext
(
std
::
vector
<
LoDTensor
>
*
out
)
{
void
FileReader
::
ReadNext
(
std
::
vector
<
LoDTensor
>
*
out
)
{
ReadNextImpl
(
out
);
PADDLE_ENFORCE_EQ
(
out
->
size
(),
dims_
.
size
());
for
(
size_t
i
=
0
;
i
<
dims_
.
size
();
++
i
)
{
...
...
paddle/fluid/framework/reader.h
浏览文件 @
164f2382
...
...
@@ -33,9 +33,6 @@ class ReaderBase {
virtual
bool
HasNext
()
const
=
0
;
virtual
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
SplitReader
(
const
platform
::
PlaceList
&
places
);
virtual
~
ReaderBase
();
};
...
...
@@ -53,27 +50,9 @@ class DecoratedReader : public ReaderBase {
ReaderBase
*
reader_
;
};
class
ThreadSafeReader
:
public
DecoratedReader
{
public:
ThreadSafeReader
(
ReaderBase
*
reader
,
const
std
::
shared_ptr
<
std
::
mutex
>&
mutex
)
:
DecoratedReader
(
reader
),
mutex_
(
mutex
)
{}
void
ReadNext
(
std
::
vector
<
LoDTensor
>*
out
)
override
;
void
ReInit
()
override
;
bool
HasNext
()
const
override
;
std
::
vector
<
std
::
unique_ptr
<
ReaderBase
>>
SplitReader
(
const
platform
::
PlaceList
&
places
)
override
;
private:
std
::
shared_ptr
<
std
::
mutex
>
mutex_
;
};
class
FileReaderBase
:
public
ReaderBase
{
class
FileReader
:
public
ReaderBase
{
public:
explicit
FileReader
Base
(
const
std
::
vector
<
DDim
>&
dims
);
explicit
FileReader
(
const
std
::
vector
<
DDim
>&
dims
);
void
ReadNext
(
std
::
vector
<
LoDTensor
>*
out
)
override
;
...
...
paddle/fluid/operators/reader/create_double_buffer_reader_op.cc
浏览文件 @
164f2382
...
...
@@ -39,7 +39,6 @@ class DoubleBufferReader : public framework::DecoratedReader {
#ifdef PADDLE_WITH_CUDA
ctxs_
.
emplace_back
(
new
platform
::
CUDADeviceContext
(
boost
::
get
<
platform
::
CUDAPlace
>
(
place_
)));
#else
#endif
}
}
...
...
paddle/fluid/operators/reader/create_recordio_file_reader_op.cc
浏览文件 @
164f2382
...
...
@@ -18,11 +18,11 @@
namespace
paddle
{
namespace
operators
{
namespace
reader
{
class
RecordIOFileReader
:
public
framework
::
FileReader
Base
{
class
RecordIOFileReader
:
public
framework
::
FileReader
{
public:
explicit
RecordIOFileReader
(
const
std
::
string
&
filename
,
const
std
::
vector
<
framework
::
DDim
>&
dims
)
:
FileReader
Base
(
dims
),
:
FileReader
(
dims
),
scanner_
(
filename
),
dev_ctx_
(
*
platform
::
DeviceContextPool
::
Instance
().
Get
(
platform
::
CPUPlace
()))
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录