Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
dd2dfeb6
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dd2dfeb6
编写于
10月 19, 2018
作者:
Q
Qiao Longfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add debug information
上级
803e2ed9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
116 addition
and
16 deletion
+116
-16
paddle/fluid/operators/reader/ctr_reader.cc
paddle/fluid/operators/reader/ctr_reader.cc
+23
-8
paddle/fluid/operators/reader/ctr_reader_test.cc
paddle/fluid/operators/reader/ctr_reader_test.cc
+93
-8
未找到文件。
paddle/fluid/operators/reader/ctr_reader.cc
浏览文件 @
dd2dfeb6
...
...
@@ -141,7 +141,12 @@ void ReadThread(const std::vector<std::string>& file_list,
const
std
::
vector
<
std
::
string
>&
slots
,
int
batch_size
,
int
thread_id
,
std
::
vector
<
ReaderThreadStatus
>*
thread_status
,
std
::
shared_ptr
<
LoDTensorBlockingQueue
>
queue
)
{
VLOG
(
3
)
<<
"reader thread start! thread_id = "
<<
thread_id
;
VLOG
(
3
)
<<
"["
<<
thread_id
<<
"]"
<<
" reader thread start! thread_id = "
<<
thread_id
;
for
(
auto
&
file
:
file_list
)
{
VLOG
(
3
)
<<
"["
<<
thread_id
<<
"]"
<<
" file "
<<
file
;
}
(
*
thread_status
)[
thread_id
]
=
Running
;
VLOG
(
3
)
<<
"set status to running"
;
...
...
@@ -159,6 +164,10 @@ void ReadThread(const std::vector<std::string>& file_list,
VLOG
(
3
)
<<
"reader inited"
;
clock_t
t0
=
clock
();
int
i
=
0
;
while
(
reader
.
HasNext
())
{
batch_data
.
clear
();
batch_label
.
clear
();
...
...
@@ -176,9 +185,7 @@ void ReadThread(const std::vector<std::string>& file_list,
break
;
}
}
VLOG
(
3
)
<<
"read one batch, batch_size = "
<<
batch_data
.
size
();
print_map
(
&
batch_data
[
0
]);
// print_map(&batch_data[0]);
std
::
vector
<
framework
::
LoDTensor
>
lod_datas
;
...
...
@@ -204,8 +211,6 @@ void ReadThread(const std::vector<std::string>& file_list,
lod_datas
.
push_back
(
lod_tensor
);
}
VLOG
(
3
)
<<
"convert data to tensor"
;
// insert label tensor
framework
::
LoDTensor
label_tensor
;
int64_t
*
label_tensor_data
=
label_tensor
.
mutable_data
<
int64_t
>
(
...
...
@@ -214,8 +219,18 @@ void ReadThread(const std::vector<std::string>& file_list,
memcpy
(
label_tensor_data
,
batch_label
.
data
(),
batch_label
.
size
());
lod_datas
.
push_back
(
label_tensor
);
VLOG
(
3
)
<<
"push one data"
;
queue
->
Push
(
lod_datas
);
// queue->Push(lod_datas);
VLOG
(
4
)
<<
"push one data, queue_size="
<<
queue
->
Size
();
if
(
i
!=
0
&&
i
%
100
==
0
)
{
clock_t
t1
=
clock
();
float
line_per_s
=
100
*
batch_size
*
static_cast
<
int64
>
(
CLOCKS_PER_SEC
)
/
static_cast
<
int
>
(
t1
-
t0
);
VLOG
(
3
)
<<
"["
<<
thread_id
<<
"]"
<<
" line_per_second = "
<<
line_per_s
;
t0
=
t1
;
}
i
++
;
}
(
*
thread_status
)[
thread_id
]
=
Stopped
;
...
...
paddle/fluid/operators/reader/ctr_reader_test.cc
浏览文件 @
dd2dfeb6
...
...
@@ -12,34 +12,119 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/reader/ctr_reader.h"
#include <time.h>
#include "gtest/gtest.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/operators/reader/blocking_queue.h"
#include "paddle/fluid/operators/reader/ctr_reader.h"
using
paddle
::
operators
::
reader
::
LoDTensorBlockingQueue
;
using
paddle
::
operators
::
reader
::
LoDTensorBlockingQueueHolder
;
using
paddle
::
operators
::
reader
::
CTRReader
;
using
paddle
::
framework
::
LoDTensor
;
TEST
(
CTR_READER
,
read_data
)
{
LoDTensorBlockingQueueHolder
queue_holder
;
int
capacity
=
64
;
queue_holder
.
InitOnce
(
capacity
,
{},
fals
e
);
queue_holder
.
InitOnce
(
capacity
,
{},
tru
e
);
std
::
shared_ptr
<
LoDTensorBlockingQueue
>
queue
=
queue_holder
.
GetQueue
();
int
batch_size
=
10
;
int
thread_num
=
1
;
std
::
vector
<
std
::
string
>
slots
=
{
"6003"
,
"6004"
};
int
thread_num
=
2
;
std
::
vector
<
std
::
string
>
slots
=
{
"6002"
,
"6003"
,
"6004"
,
"6005"
,
"6006"
,
"6007"
,
"6008"
,
"6009"
,
"6010"
,
"6011"
,
"6012"
,
"6013"
,
"6014"
,
"6015"
,
"6016"
,
"6017"
,
"6018"
,
"6019"
,
"6020"
,
"6021"
,
"6023"
,
"6024"
,
"6025"
,
"6026"
,
"6027"
,
"6028"
,
"6029"
,
"6030"
,
"6031"
,
"6032"
,
"6033"
,
"6034"
,
"6035"
,
"6036"
,
"6037"
,
"6038"
,
"6039"
,
"6040"
,
"6041"
,
"6042"
,
"6043"
,
"6044"
,
"6045"
,
"6046"
,
"6047"
,
"6048"
,
"6050"
,
"6051"
,
"6052"
,
"6054"
,
"6055"
,
"6056"
,
"6057"
,
"6058"
,
"6059"
,
"6060"
,
"6061"
,
"6062"
,
"6063"
,
"6064"
,
"6065"
,
"6066"
,
"6067"
,
"6068"
,
"6069"
,
"6070"
,
"6071"
,
"6072"
,
"6073"
,
"6074"
,
"6075"
,
"6076"
,
"6077"
,
"6078"
,
"6079"
,
"6080"
,
"6081"
,
"6082"
,
"6083"
,
"6084"
,
"6085"
,
"6086"
,
"6087"
,
"6088"
,
"6089"
,
"6090"
,
"6091"
,
"6092"
,
"6093"
,
"6094"
,
"6095"
,
"6096"
,
"6097"
,
"6098"
,
"6099"
,
"6100"
,
"6101"
,
"6102"
,
"6103"
,
"6104"
,
"6105"
,
"6106"
,
"6107"
,
"6108"
,
"6109"
,
"6110"
,
"6111"
,
"6112"
,
"6113"
,
"6114"
,
"6115"
,
"6116"
,
"6117"
,
"6118"
,
"6119"
,
"6120"
,
"6121"
,
"6122"
,
"6123"
,
"6124"
,
"6125"
,
"6126"
,
"6127"
,
"6128"
,
"6129"
,
"6130"
,
"6131"
,
"6132"
,
"6133"
,
"6134"
,
"6135"
,
"6136"
,
"6137"
,
"6138"
,
"6139"
,
"6140"
,
"6141"
,
"6142"
,
"6143"
,
"6144"
,
"6145"
,
"6146"
,
"6147"
,
"6148"
,
"6149"
,
"6150"
,
"6151"
,
"6152"
,
"6153"
,
"6155"
,
"6156"
,
"6157"
,
"6158"
,
"6160"
,
"6161"
,
"6162"
,
"6163"
,
"6164"
,
"6165"
,
"6166"
,
"6167"
,
"6168"
,
"6169"
,
"6170"
,
"6171"
,
"6172"
,
"6173"
,
"6174"
,
"6175"
,
"6176"
,
"6177"
,
"6178"
,
"6181"
,
"6182"
,
"6183"
,
"6184"
,
"6185"
,
"6186"
,
"6188"
,
"6189"
,
"6190"
,
"6191"
,
"6192"
,
"6194"
,
"6195"
,
"6196"
,
"6197"
,
"6198"
,
"6199"
,
"6200"
,
"6201"
,
"6202"
,
"6203"
,
"6204"
,
"6205"
,
"6206"
,
"6207"
,
"6208"
,
"6209"
,
"6210"
,
"6211"
,
"6212"
,
"6213"
,
"6214"
,
"6215"
,
"6216"
,
"6217"
,
"6218"
,
"6220"
,
"6222"
,
"6223"
,
"6224"
,
"6225"
,
"6226"
,
"6227"
,
"6228"
,
"6229"
,
"6230"
,
"6231"
,
"6232"
,
"6233"
,
"6234"
,
"6235"
,
"6236"
,
"6237"
,
"6238"
,
"6239"
,
"6240"
,
"6241"
,
"6242"
,
"6243"
,
"6244"
,
"6245"
,
"6247"
,
"6248"
,
"6250"
,
"6251"
,
"6253"
,
"6254"
,
"6255"
,
"6256"
,
"6257"
,
"6258"
,
"6259"
,
"6260"
,
"6261"
,
"6262"
,
"6263"
,
"6264"
,
"6265"
,
"6350"
,
"6351"
,
"6352"
,
"6353"
,
"6354"
,
"6355"
,
"6356"
,
"6738"
,
"6739"
,
"6740"
,
"6741"
,
"6751"
,
"6753"
,
"6754"
,
"6755"
,
"6756"
,
"6757"
,
"6759"
,
"6760"
,
"6763"
,
"6764"
,
"6765"
,
"6766"
,
"6767"
,
"6768"
,
"6769"
,
"6770"
,
"6806"
,
"6807"
,
"6808"
,
"6809"
,
"6810"
,
"6811"
,
"6812"
,
"6813"
,
"6814"
,
"6815"
,
"6816"
,
"6817"
,
"6818"
,
"6819"
,
"6820"
,
"6821"
,
"6822"
,
"6823"
,
"6824"
,
"6825"
,
"6826"
,
"6827"
,
"6828"
,
"6829"
,
"6830"
,
"6831"
,
"6832"
,
"6833"
,
"6834"
,
"6835"
,
"6836"
,
"6837"
,
"6838"
,
"6839"
,
"6840"
,
"6841"
,
"6842"
,
"6843"
,
"6844"
,
"6845"
,
"6846"
,
"6847"
,
"6848"
,
"6849"
,
"6850"
,
"6851"
,
"6852"
,
"6853"
,
"6854"
,
"6855"
,
"6856"
,
"6857"
,
"6858"
,
"6859"
,
"6860"
,
"6861"
,
"6862"
,
"6863"
,
"6864"
,
"6865"
,
"6866"
,
"6867"
,
"6868"
,
"6869"
,
"6870"
,
"6871"
,
"6872"
,
"6873"
,
"6874"
,
"6875"
,
"6876"
,
"6877"
,
"6878"
,
"6879"
,
"6880"
,
"6881"
,
"6882"
,
"6883"
,
"6884"
,
"6885"
,
"6886"
,
"6887"
,
"6888"
,
"6889"
,
"6890"
,
"6891"
,
"6892"
,
"6893"
,
"6894"
,
"6895"
,
"6896"
,
"6897"
,
"6898"
,
"6899"
,
"6900"
,
"6901"
,
"6902"
,
"6903"
,
"6904"
,
"6905"
,
"6906"
,
"6907"
,
"6908"
,
"6909"
,
"6910"
,
"6911"
,
"6912"
,
"6913"
,
"6914"
,
"6915"
,
"6916"
,
"6917"
,
"6918"
,
"6919"
,
"6920"
,
"6921"
,
"6922"
,
"6923"
,
"6924"
,
"6925"
,
"6926"
,
"6927"
,
"6928"
,
"6929"
,
"6930"
,
"6931"
,
"6932"
,
"6933"
,
"6934"
,
"6935"
,
"6936"
,
"6937"
,
"6938"
,
"6939"
,
"6940"
,
"6941"
,
"6942"
,
"6943"
,
"6944"
,
"6945"
,
"6946"
,
"6947"
,
"6948"
,
"6949"
,
"6950"
,
"6951"
,
"6952"
,
"6953"
,
"6954"
,
"6955"
,
"6956"
,
"6957"
,
"6958"
,
"6959"
,
"6960"
,
"6961"
,
"6962"
,
"6963"
,
"7001"
,
"7002"
,
"7003"
,
"7004"
,
"7005"
,
"7006"
,
"7007"
,
"7008"
,
"7009"
,
"7010"
,
"7011"
,
"7012"
,
"7013"
,
"7014"
,
"7015"
,
"7016"
,
"7017"
,
"7018"
,
"7019"
,
"7020"
,
"7021"
,
"7022"
,
"7023"
,
"7024"
,
"7025"
,
"7026"
,
"7027"
,
"7028"
,
"7029"
,
"7030"
,
"7031"
,
"7032"
,
"7033"
,
"7034"
,
"7035"
,
"7036"
,
"7037"
,
"7038"
,
"7039"
,
"7040"
,
"7041"
,
"7042"
,
"7043"
,
"7044"
,
"7045"
,
"7046"
,
"7047"
,
"7048"
,
"7049"
,
"7050"
,
"7051"
,
"7052"
,
"7053"
,
"7054"
,
"7055"
,
"7056"
,
"7057"
,
"7058"
,
"7060"
,
"7062"
,
"7063"
,
"7064"
,
"7065"
,
"7066"
,
"7067"
,
"7068"
,
"7069"
,
"7070"
,
"7071"
,
"7072"
,
"7073"
,
"7074"
,
"7075"
,
"7076"
,
"7077"
,
"7078"
,
"7079"
,
"7080"
,
"7081"
,
"7082"
,
"7083"
,
"7084"
,
"7085"
,
"7086"
,
"7087"
,
"7088"
,
"7089"
,
"7090"
,
"7091"
,
"7092"
,
"7093"
,
"7094"
,
"7095"
,
"7096"
,
"7097"
,
"7098"
,
"7099"
,
"7100"
,
"7101"
,
"7102"
,
"7103"
,
"7104"
,
"7105"
,
"7106"
,
"7107"
,
"7108"
,
"7109"
,
"7110"
,
"7120"
,
"7122"
,
"7123"
,
"7124"
,
"7125"
,
"7126"
,
"7127"
,
"7128"
,
"7129"
,
"7131"
,
"7133"
,
"7134"
,
"7135"
,
"7136"
,
"7137"
,
"7138"
,
"7139"
,
"7140"
,
"7141"
,
"7142"
,
"7143"
,
"7144"
,
"7145"
,
"7146"
,
"7147"
,
"7148"
,
"7149"
,
"7150"
,
"7151"
,
"7152"
,
"7153"
,
"7154"
,
"7155"
,
"7156"
,
"7157"
,
"7158"
,
"7159"
,
"7160"
,
"7161"
,
"7162"
,
"7163"
,
"7164"
,
"7165"
,
"7166"
,
"7167"
,
"7168"
,
"7169"
,
"7170"
,
"7171"
,
"7172"
,
"7173"
,
"7174"
,
"7175"
,
"7176"
,
"7177"
,
"7178"
,
"7179"
,
"7180"
,
"7181"
,
"7182"
,
"7183"
,
"7184"
,
"7185"
,
"7186"
,
"7187"
,
"7500"
,
"7501"
,
"7502"
,
"7503"
,
"7504"
,
"7505"
,
"7506"
,
"7507"
,
"7508"
,
"7509"
,
"7510"
,
"7511"
,
"7512"
,
"7513"
,
"7514"
,
"7515"
,
"7516"
,
"7517"
,
"7750"
};
std
::
vector
<
std
::
string
>
file_list
=
{
"/Users/qiaolongfei/project/gzip_test/part-00000-A.gz"
,
"/Users/qiaolongfei/project/gzip_test/part-00000-A.gz"
};
"/Users/qiaolongfei/project/gzip_test/part-00001-A.gz"
,
"/Users/qiaolongfei/project/gzip_test/part-00002-A.gz"
};
CTRReader
reader
(
queue
,
batch_size
,
thread_num
,
slots
,
file_list
);
reader
.
Start
();
//
// std::vector<LoDTensor> out;
// reader.ReadNext(&out);
std
::
cout
<<
"start to reader data"
<<
std
::
endl
;
std
::
vector
<
LoDTensor
>
out
;
int
read_batch
=
1000
;
clock_t
t0
=
clock
();
for
(
int
i
=
0
;
i
<
read_batch
;
++
i
)
{
reader
.
ReadNext
(
&
out
);
}
clock_t
t1
=
clock
();
float
line_per_s
=
read_batch
*
batch_size
*
static_cast
<
int64
>
(
CLOCKS_PER_SEC
)
/
static_cast
<
int
>
(
t1
-
t0
);
VLOG
(
3
)
<<
"line_per_second = "
<<
line_per_s
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录