Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
687cb79d
P
Paddle
项目概览
机器未来
/
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看板
提交
687cb79d
编写于
2月 26, 2019
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pipe command io interface
上级
1fe54416
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
37 deletion
+9
-37
paddle/fluid/framework/data_feed.cc
paddle/fluid/framework/data_feed.cc
+7
-18
paddle/fluid/framework/executor_thread_worker.cc
paddle/fluid/framework/executor_thread_worker.cc
+1
-1
python/paddle/fluid/data_feed_desc.py
python/paddle/fluid/data_feed_desc.py
+1
-18
未找到文件。
paddle/fluid/framework/data_feed.cc
浏览文件 @
687cb79d
...
...
@@ -177,6 +177,7 @@ void MultiSlotDataFeed::ReadThread() {
while
(
PickOneFile
(
&
filename
))
{
int
err_no
=
0
;
fp_
=
fs_open_read
(
filename
,
&
err_no
,
pipe_command_
);
CHECK
(
fp_
!=
nullptr
);
__fsetlocking
(
&*
fp_
,
FSETLOCKING_BYCALLER
);
thread_local
string
::
LineFileReader
reader
;
std
::
vector
<
MultiSlotType
>
instance
;
...
...
@@ -185,7 +186,7 @@ void MultiSlotDataFeed::ReadThread() {
ins_num
++
;
queue_
->
Send
(
instance
);
}
LOG
(
ERROR
)
<<
"filename: "
<<
filename
<<
" inst num: "
<<
ins_num
;
VLOG
(
3
)
<<
"filename: "
<<
filename
<<
" inst num: "
<<
ins_num
;
}
queue_
->
Close
();
}
...
...
@@ -304,31 +305,16 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
bool
MultiSlotDataFeed
::
ParseOneInstanceFromPipe
(
std
::
vector
<
MultiSlotType
>*
instance
)
{
thread_local
string
::
LineFileReader
reader
;
/*
while (reader.getline(&*(fp_.get()))) {
*/
/*
const char* str = reader.get();
std::string line = std::string(str);
LOG(ERROR) << line;
*/
/*
LOG(ERROR) << "read a line";
}
*/
if
(
!
reader
.
getline
(
&*
(
fp_
.
get
())))
{
return
false
;
}
else
{
// std::string& line = reader_.get();
// const char* str = line.c_str();
int
use_slots_num
=
use_slots_
.
size
();
instance
->
resize
(
use_slots_num
);
const
char
*
str
=
reader
.
get
();
std
::
string
line
=
std
::
string
(
str
);
// LOG(ERROR
) << line;
VLOG
(
3
)
<<
line
;
char
*
endptr
=
const_cast
<
char
*>
(
str
);
int
pos
=
0
;
for
(
size_t
i
=
0
;
i
<
use_slots_index_
.
size
();
++
i
)
{
...
...
@@ -357,7 +343,10 @@ bool MultiSlotDataFeed::ParseOneInstanceFromPipe(
pos
=
endptr
-
str
;
}
else
{
for
(
int
j
=
0
;
j
<=
num
;
++
j
)
{
pos
=
line
.
find_first_of
(
' '
,
pos
+
1
);
// pos = line.find_first_of(' ', pos + 1);
while
(
line
[
pos
+
1
]
!=
' '
)
{
pos
++
;
}
}
}
}
...
...
paddle/fluid/framework/executor_thread_worker.cc
浏览文件 @
687cb79d
...
...
@@ -274,7 +274,7 @@ void ExecutorThreadWorker::TrainFilesWithTimer() {
++
batch_cnt
;
thread_scope_
->
DropKids
();
if
(
thread_id_
==
0
)
{
if
(
batch_cnt
>
0
&&
batch_cnt
%
100
0
==
0
)
{
if
(
batch_cnt
>
0
&&
batch_cnt
%
100
==
0
)
{
for
(
size_t
i
=
0
;
i
<
ops_
.
size
();
++
i
)
{
fprintf
(
stderr
,
"op_name:[%zu][%s], op_mean_time:[%fs]
\n
"
,
i
,
op_name
[
i
].
c_str
(),
op_total_time
[
i
]
/
batch_cnt
);
...
...
python/paddle/fluid/data_feed_desc.py
浏览文件 @
687cb79d
...
...
@@ -68,6 +68,7 @@ class DataFeedDesc(object):
def
__init__
(
self
,
proto_file
):
self
.
proto_desc
=
data_feed_pb2
.
DataFeedDesc
()
self
.
proto_desc
.
pipe_command
=
"cat"
with
open
(
proto_file
,
'r'
)
as
f
:
text_format
.
Parse
(
f
.
read
(),
self
.
proto_desc
)
if
self
.
proto_desc
.
name
==
"MultiSlotDataFeed"
:
...
...
@@ -114,24 +115,6 @@ class DataFeedDesc(object):
self
.
proto_desc
.
multi_slot_desc
.
slots
[
self
.
__name_to_index
[
name
]].
is_dense
=
True
def
set_pipe_command
(
self
,
pipe_command
):
"""
Pipeline command will be set with this function. In IO runtime,
pipeline command will be executed given user provided input raw
files.
Example:
>>> data_feed = fluid.DataFeedDesc('data.proto')
>>> data_feed.set_pipe_command('awk -F '
\t
' '{print $2}'')
Args:
pipe_command: a command string of shell command
Note:
Default is cat, i.e., cat user's input file list to data feed
"""
self
.
proto_desc
.
pipe_command
=
pipe_command
def
set_use_slots
(
self
,
use_slots_name
):
"""
Set if a specific slot will be used for training. A dataset shall
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录