Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wk1234123
Paddle
提交
60030e86
P
Paddle
项目概览
wk1234123
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
4
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60030e86
编写于
10月 15, 2018
作者:
Q
Qiao Longfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change the use of FLAGS_reader_queue_speed_test_mode
test=develop
上级
2178ae56
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
26 deletion
+22
-26
paddle/fluid/CMakeLists.txt
paddle/fluid/CMakeLists.txt
+1
-1
paddle/fluid/operators/reader/blocking_queue.h
paddle/fluid/operators/reader/blocking_queue.h
+4
-6
paddle/fluid/operators/reader/lod_tensor_blocking_queue.h
paddle/fluid/operators/reader/lod_tensor_blocking_queue.h
+6
-4
paddle/fluid/operators/reader/reader_blocking_queue_test.cc
paddle/fluid/operators/reader/reader_blocking_queue_test.cc
+9
-14
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-1
未找到文件。
paddle/fluid/CMakeLists.txt
浏览文件 @
60030e86
...
...
@@ -14,4 +14,4 @@ if(WITH_INFERENCE)
add_subdirectory
(
inference
)
endif
()
add_subdirectory
(
train
)
#
add_subdirectory(train)
paddle/fluid/operators/reader/blocking_queue.h
浏览文件 @
60030e86
...
...
@@ -14,14 +14,11 @@
#pragma once
#include <gflags/gflags.h>
#include <condition_variable> // NOLINT
#include <deque>
#include "paddle/fluid/platform/enforce.h"
DECLARE_bool
(
reader_queue_speed_test_mode
);
namespace
paddle
{
namespace
operators
{
namespace
reader
{
...
...
@@ -34,8 +31,8 @@ class BlockingQueue {
// is a workaround and a simplified version of framework::Channel as it
// doesn't support GPU and it implements on buffered blocking queue.
public:
explicit
BlockingQueue
(
size_t
capacity
)
:
capacity_
(
capacity
),
closed_
(
false
)
{
explicit
BlockingQueue
(
size_t
capacity
,
bool
speed_test_mode
=
false
)
:
capacity_
(
capacity
),
speed_test_mode_
(
speed_test_mode
),
closed_
(
false
)
{
PADDLE_ENFORCE_GT
(
capacity_
,
0
,
"The capacity of a reader::BlockingQueue must be greater than 0."
);
...
...
@@ -75,7 +72,7 @@ class BlockingQueue {
if
(
!
queue_
.
empty
())
{
PADDLE_ENFORCE_NOT_NULL
(
elem
);
*
elem
=
queue_
.
front
();
if
(
LIKELY
(
!
FLAGS_reader_queue_speed_test_mode
))
{
if
(
LIKELY
(
!
speed_test_mode_
))
{
queue_
.
pop_front
();
}
send_cv_
.
notify_one
();
...
...
@@ -119,6 +116,7 @@ class BlockingQueue {
private:
size_t
capacity_
;
bool
speed_test_mode_
;
bool
closed_
;
std
::
deque
<
T
>
queue_
;
...
...
paddle/fluid/operators/reader/lod_tensor_blocking_queue.h
浏览文件 @
60030e86
...
...
@@ -33,8 +33,9 @@ class LoDTensorBlockingQueue {
private:
LoDTensorBlockingQueue
(
size_t
capacity
,
const
std
::
vector
<
framework
::
DDim
>&
dims
)
:
queue_
(
capacity
),
dims_
(
dims
)
{}
const
std
::
vector
<
framework
::
DDim
>&
dims
,
bool
speed_test_mode
=
false
)
:
queue_
(
capacity
,
speed_test_mode
),
dims_
(
dims
)
{}
public:
bool
Push
(
const
std
::
vector
<
framework
::
LoDTensor
>&
lod_tensor_vec
)
{
...
...
@@ -69,11 +70,12 @@ class LoDTensorBlockingQueue {
class
LoDTensorBlockingQueueHolder
{
public:
void
InitOnce
(
size_t
capacity
,
const
std
::
vector
<
framework
::
DDim
>&
dims
)
{
void
InitOnce
(
size_t
capacity
,
const
std
::
vector
<
framework
::
DDim
>&
dims
,
bool
speed_test_mode
=
false
)
{
PADDLE_ENFORCE
(
queue_
==
nullptr
,
"LoDTensorBlockingQueueHolder::InitOnce() can only be called once"
);
queue_
.
reset
(
new
LoDTensorBlockingQueue
(
capacity
,
dims
));
queue_
.
reset
(
new
LoDTensorBlockingQueue
(
capacity
,
dims
,
speed_test_mode
));
}
inline
const
std
::
shared_ptr
<
LoDTensorBlockingQueue
>&
GetQueue
()
const
{
...
...
paddle/fluid/operators/reader/reader_blocking_queue_test.cc
浏览文件 @
60030e86
...
...
@@ -20,10 +20,6 @@
#include "paddle/fluid/operators/reader/blocking_queue.h"
DEFINE_bool
(
reader_queue_speed_test_mode
,
false
,
"If set true, the queue.pop will only get data from queue but not "
"remove the data from queue for speed testing"
);
using
paddle
::
operators
::
reader
::
BlockingQueue
;
TEST
(
BlockingQueue
,
CapacityTest
)
{
...
...
@@ -222,27 +218,26 @@ TEST(BlockingQueue, MyClassTest) {
EXPECT_EQ
(
a
.
val_
,
b
.
val_
);
}
TEST
(
BlockingQueue
,
reader_queue_speed_test_mode_flag
)
{
FLAGS_reader_queue_speed_test_mode
=
false
;
TEST
(
BlockingQueue
,
speed_test_mode
)
{
size_t
queue_size
=
10
;
BlockingQueue
<
size_t
>
q
(
queue_siz
e
);
BlockingQueue
<
size_t
>
q
1
(
queue_size
,
fals
e
);
for
(
size_t
i
=
0
;
i
<
queue_size
;
++
i
)
{
q
.
Send
(
i
);
q
1
.
Send
(
i
);
}
size_t
b
;
for
(
size_t
i
=
0
;
i
<
queue_size
;
++
i
)
{
q
.
Receive
(
&
b
);
q
1
.
Receive
(
&
b
);
EXPECT_EQ
(
b
,
i
);
}
EXPECT_EQ
(
q
.
Size
(),
0
);
EXPECT_EQ
(
q
1
.
Size
(),
0
);
FLAGS_reader_queue_speed_test_mode
=
true
;
BlockingQueue
<
size_t
>
q2
(
queue_size
,
true
)
;
for
(
size_t
i
=
0
;
i
<
queue_size
;
++
i
)
{
q
.
Send
(
i
);
q
2
.
Send
(
i
);
}
for
(
size_t
i
=
0
;
i
<
queue_size
;
++
i
)
{
q
.
Receive
(
&
b
);
q
2
.
Receive
(
&
b
);
EXPECT_EQ
(
b
,
0
);
}
EXPECT_EQ
(
q
.
Size
(),
queue_size
);
EXPECT_EQ
(
q
2
.
Size
(),
queue_size
);
}
paddle/fluid/pybind/pybind.cc
浏览文件 @
60030e86
...
...
@@ -341,7 +341,8 @@ All parameter, weight, gradient are variables in Paddle.
return
make_ddim
(
shape
);
});
auto
*
holder
=
var
.
GetMutable
<
LoDTensorBlockingQueueHolder
>
();
holder
->
InitOnce
(
capacity
,
dims
);
holder
->
InitOnce
(
capacity
,
dims
,
FLAGS_reader_queue_speed_test_mode
);
return
holder
->
GetQueue
();
},
py
::
return_value_policy
::
copy
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录