Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
PaddleRec
提交
fae7e884
P
PaddleRec
项目概览
BaiXuePrincess
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fae7e884
编写于
8月 05, 2019
作者:
R
rensilin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish datareader ut
Change-Id: I1b0544bb2b844a47d7434963c21b05c134e1da80
上级
d5f4d04b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
9 deletion
+17
-9
paddle/fluid/train/custom_trainer/feed/dataset/data_reader.cc
...le/fluid/train/custom_trainer/feed/dataset/data_reader.cc
+10
-3
paddle/fluid/train/custom_trainer/feed/unit_test/test_datareader.cc
...id/train/custom_trainer/feed/unit_test/test_datareader.cc
+7
-6
未找到文件。
paddle/fluid/train/custom_trainer/feed/dataset/data_reader.cc
浏览文件 @
fae7e884
...
...
@@ -26,12 +26,15 @@ public:
++
pos
;
}
if
(
pos
>=
len
)
{
VLOG
(
2
)
<<
"fail to parse line"
<<
std
::
string
(
str
,
len
)
<<
", strlen: "
<<
len
;
VLOG
(
2
)
<<
"fail to parse line
:
"
<<
std
::
string
(
str
,
len
)
<<
", strlen: "
<<
len
;
return
-
1
;
}
VLOG
(
5
)
<<
"getline: "
<<
str
<<
" , pos: "
<<
pos
<<
", len: "
<<
len
;
data
.
id
.
assign
(
str
,
pos
);
data
.
data
.
assign
(
str
+
pos
+
1
,
len
-
pos
-
1
);
if
(
!
data
.
data
.
empty
()
&&
data
.
data
.
back
()
==
'\n'
)
{
data
.
data
.
pop_back
();
}
return
0
;
}
...
...
@@ -41,12 +44,15 @@ public:
++
pos
;
}
if
(
str
[
pos
]
==
'\0'
)
{
VLOG
(
2
)
<<
"fail to parse line"
<<
str
<<
", get '
\\
0' at pos: "
<<
pos
;
VLOG
(
2
)
<<
"fail to parse line
:
"
<<
str
<<
", get '
\\
0' at pos: "
<<
pos
;
return
-
1
;
}
VLOG
(
5
)
<<
"getline: "
<<
str
<<
" , pos: "
<<
pos
;
data
.
id
.
assign
(
str
,
pos
);
data
.
data
.
assign
(
str
+
pos
+
1
);
if
(
!
data
.
data
.
empty
()
&&
data
.
data
.
back
()
==
'\n'
)
{
data
.
data
.
pop_back
();
}
return
0
;
}
...
...
@@ -105,7 +111,7 @@ public:
if
(
::
paddle
::
framework
::
fs_path_split
(
filename
).
second
==
_done_file_name
)
{
continue
;
}
int
err_no
;
int
err_no
=
0
;
std
::
shared_ptr
<
FILE
>
fin
=
::
paddle
::
framework
::
fs_open_read
(
filename
,
&
err_no
,
_pipeline_cmd
);
if
(
err_no
!=
0
)
{
VLOG
(
2
)
<<
"fail to open file: "
<<
filename
<<
", with cmd: "
<<
_pipeline_cmd
;
...
...
@@ -127,6 +133,7 @@ public:
VLOG
(
2
)
<<
"fail when write to channel"
;
return
-
1
;
}
data_channel
->
Close
();
return
0
;
}
...
...
paddle/fluid/train/custom_trainer/feed/unit_test/test_datareader.cc
浏览文件 @
fae7e884
...
...
@@ -36,17 +36,18 @@ class DataReaderTest : public testing::Test
public:
static
void
SetUpTestCase
()
{
::
paddle
::
framework
::
localfs_mkdir
(
test_data_dir
);
framework
::
shell_set_verbose
(
true
);
framework
::
localfs_mkdir
(
test_data_dir
);
{
std
::
ofstream
fout
(
::
paddle
::
framework
::
fs_path_join
(
test_data_dir
,
"a.txt"
));
std
::
ofstream
fout
(
framework
::
fs_path_join
(
test_data_dir
,
"a.txt"
));
fout
<<
"abc 123456"
<<
std
::
endl
;
fout
<<
"def 234567"
<<
std
::
endl
;
fout
.
close
();
}
{
std
::
ofstream
fout
(
::
paddle
::
framework
::
fs_path_join
(
test_data_dir
,
"b.txt"
));
std
::
ofstream
fout
(
framework
::
fs_path_join
(
test_data_dir
,
"b.txt"
));
fout
<<
"ghi 345678"
<<
std
::
endl
;
fout
<<
"jkl 456789"
<<
std
::
endl
;
fout
.
close
();
...
...
@@ -55,7 +56,7 @@ public:
static
void
TearDownTestCase
()
{
::
paddle
::
framework
::
localfs_remove
(
test_data_dir
);
framework
::
localfs_remove
(
test_data_dir
);
}
virtual
void
SetUp
()
...
...
@@ -118,12 +119,12 @@ TEST_F(DataReaderTest, LineDataReader) {
ASSERT_EQ
(
0
,
data_reader
->
initialize
(
config
,
context_ptr
));
ASSERT_FALSE
(
data_reader
->
is_data_ready
(
test_data_dir
));
std
::
ofstream
fout
(
::
paddle
::
framework
::
fs_path_join
(
test_data_dir
,
"done_file"
));
std
::
ofstream
fout
(
framework
::
fs_path_join
(
test_data_dir
,
"done_file"
));
fout
<<
"done"
;
fout
.
close
();
ASSERT_TRUE
(
data_reader
->
is_data_ready
(
test_data_dir
));
auto
channel
=
::
paddle
::
framework
::
MakeChannel
<
DataItem
>
(
);
auto
channel
=
framework
::
MakeChannel
<
DataItem
>
(
128
);
ASSERT_NE
(
nullptr
,
channel
);
ASSERT_EQ
(
0
,
data_reader
->
read_all
(
test_data_dir
,
channel
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录