MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / LoadIntoMemoryByLine

Method LoadIntoMemoryByLine

paddle/fluid/framework/data_feed.cc:2316–2413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2314}
2315
2316void SlotRecordInMemoryDataFeed::LoadIntoMemoryByLine() {
2317#ifdef _LINUX
2318 paddle::framework::CustomParser* parser =
2319 global_dlmanager_pool().Load(so_parser_name_, all_slots_info_);
2320 std::string filename;
2321 BufferedLineFileReader line_reader;
2322 line_reader.set_sample_rate(sample_rate_);
2323 BufferedLineFileReader::LineFunc line_func = nullptr;
2324
2325 while (this->PickOneFile(&filename)) {
2326 VLOG(3) << "PickOneFile, filename=" << filename
2327 << ", thread_id=" << thread_id_;
2328 std::vector<SlotRecord> record_vec;
2329 platform::Timer timeline;
2330 timeline.Start();
2331 int offset = 0;
2332 int old_offset = 0;
2333
2334 SlotRecordPool().get(&record_vec, OBJPOOL_BLOCK_SIZE);
2335 // get slotrecord object function
2336 auto record_func = [this, &offset, &record_vec, &old_offset](
2337 std::vector<SlotRecord>& vec, int num) {
2338 vec.resize(num);
2339 if (offset + num > OBJPOOL_BLOCK_SIZE) {
2340 input_channel_->WriteMove(offset, &record_vec[0]);
2341 SlotRecordPool().get(&record_vec[0], offset);
2342 record_vec.resize(OBJPOOL_BLOCK_SIZE);
2343 offset = 0;
2344 old_offset = 0;
2345 }
2346 for (int i = 0; i < num; ++i) {
2347 auto& ins = record_vec[offset + i];
2348 ins->reset();
2349 vec[i] = ins;
2350 }
2351 offset = offset + num;
2352 };
2353
2354 line_func = [this,
2355 &parser,
2356 &record_vec,
2357 &offset,
2358 &filename,
2359 &record_func,
2360 &old_offset](const std::string& line) {
2361 old_offset = offset;
2362 if (!parser->ParseOneInstance(line, record_func)) {
2363 offset = old_offset;
2364 LOG(WARNING) << "read file:[" << filename << "] item error, line:["
2365 << line << "]";
2366 return false;
2367 }
2368 if (offset >= OBJPOOL_BLOCK_SIZE) {
2369 input_channel_->Write(std::move(record_vec));
2370 record_vec.clear();
2371 SlotRecordPool().get(&record_vec, OBJPOOL_BLOCK_SIZE);
2372 offset = 0;
2373 }

Callers

nothing calls this directly

Calls 15

fs_open_readFunction · 0.85
set_sample_rateMethod · 0.80
PickOneFileMethod · 0.80
read_fileMethod · 0.80
is_errorMethod · 0.80
shrink_to_fitMethod · 0.80
PauseMethod · 0.80
ElapsedSecMethod · 0.80
get_sample_lineMethod · 0.80
file_sizeMethod · 0.80
LoadMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected