| 30 | virtual ~BCDScheduler() { } |
| 31 | |
| 32 | void loadTrainingData(const DataConfig& train) { |
| 33 | // ask the workers to load the data |
| 34 | auto load_time = tic(); |
| 35 | auto confs = Postmaster::partitionData(train, sys_.yp().num_workers()); |
| 36 | std::vector<Task> loads(confs.size()); |
| 37 | for (int i = 0; i < confs.size(); ++i) { |
| 38 | auto bcd = loads[i].mutable_bcd(); |
| 39 | bcd->set_cmd(BCDCall::LOAD_DATA); |
| 40 | *bcd->mutable_data() = confs[i]; |
| 41 | } |
| 42 | int hit_cache = 0; |
| 43 | port(kWorkerGroup)->submitAndWait(loads, [this, &hit_cache](){ |
| 44 | LoadDataReturn info; CHECK(info.ParseFromString(exec_.lastRecvReply())); |
| 45 | // LL << info.DebugString(); |
| 46 | g_train_info_ = mergeExampleInfo(g_train_info_, info.example_info()); |
| 47 | hit_cache += info.hit_cache(); |
| 48 | }); |
| 49 | if (hit_cache > 0) { |
| 50 | CHECK_EQ(hit_cache, loads.size()) << "clear the local caches"; |
| 51 | LI << "Hit local caches for the training data"; |
| 52 | } |
| 53 | LI << "Loaded " << g_train_info_.num_ex() << " examples in " |
| 54 | << toc(load_time) << " sec"; |
| 55 | |
| 56 | |
| 57 | // preprocess the training data |
| 58 | for (int i = 0; i < g_train_info_.slot_size(); ++i) { |
| 59 | auto info = g_train_info_.slot(i); |
| 60 | CHECK(info.has_id()); |
| 61 | if (info.id() == 0) continue; // it's the label |
| 62 | fea_grp_.push_back(info.id()); |
| 63 | } |
| 64 | auto preprocess_time = tic(); |
| 65 | Task preprocess; |
| 66 | auto prep_bcd = preprocess.mutable_bcd(); |
| 67 | prep_bcd->set_cmd(BCDCall::PREPROCESS_DATA); |
| 68 | for (auto grp : fea_grp_) prep_bcd->add_fea_grp(grp); |
| 69 | prep_bcd->set_hit_cache(hit_cache > 0); |
| 70 | port(kCompGroup)->submitAndWait(preprocess); |
| 71 | LI << "Preprocessing is finished in " << toc(preprocess_time) << " sec"; |
| 72 | if (bcd_conf_.tail_feature_freq()) { |
| 73 | LI << "Features with frequency <= " << bcd_conf_.tail_feature_freq() |
| 74 | << " are filtered"; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void divideFeatureBlocks() { |
| 79 | // partition feature blocks |
nothing calls this directly
no test coverage detected