MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / CheckOrPartition

Method CheckOrPartition

src/io/metadata.cpp:141–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141void Metadata::CheckOrPartition(data_size_t num_all_data, const std::vector<data_size_t>& used_data_indices) {
142 if (used_data_indices.empty()) {
143 if (!queries_.empty()) {
144 // need convert query_id to boundaries
145 std::vector<data_size_t> tmp_buffer;
146 data_size_t last_qid = -1;
147 data_size_t cur_cnt = 0;
148 for (data_size_t i = 0; i < num_data_; ++i) {
149 if (last_qid != queries_[i]) {
150 if (cur_cnt > 0) {
151 tmp_buffer.push_back(cur_cnt);
152 }
153 cur_cnt = 0;
154 last_qid = queries_[i];
155 }
156 ++cur_cnt;
157 }
158 tmp_buffer.push_back(cur_cnt);
159 query_boundaries_ = std::vector<data_size_t>(tmp_buffer.size() + 1);
160 num_queries_ = static_cast<data_size_t>(tmp_buffer.size());
161 query_boundaries_[0] = 0;
162 for (size_t i = 0; i < tmp_buffer.size(); ++i) {
163 query_boundaries_[i + 1] = query_boundaries_[i] + tmp_buffer[i];
164 }
165 LoadQueryWeights();
166 queries_.clear();
167 }
168 // check weights
169 if (!weights_.empty() && num_weights_ != num_data_) {
170 weights_.clear();
171 num_weights_ = 0;
172 Log::Fatal("Weights size doesn't match data size");
173 }
174
175 // check query boundries
176 if (!query_boundaries_.empty() && query_boundaries_[num_queries_] != num_data_) {
177 query_boundaries_.clear();
178 num_queries_ = 0;
179 Log::Fatal("Query size doesn't match data size");
180 }
181
182 // contain initial score file
183 if (!init_score_.empty() && (num_init_score_ % num_data_) != 0) {
184 init_score_.clear();
185 num_init_score_ = 0;
186 Log::Fatal("Initial score size doesn't match data size");
187 }
188 } else {
189 if (!queries_.empty()) {
190 Log::Fatal("Cannot used query_id for parallel training");
191 }
192 data_size_t num_used_data = static_cast<data_size_t>(used_data_indices.size());
193 // check weights
194 if (weight_load_from_file_) {
195 if (weights_.size() > 0 && num_weights_ != num_all_data) {
196 weights_.clear();
197 num_weights_ = 0;
198 Log::Fatal("Weights size doesn't match data size");

Callers 2

LoadFromFileMethod · 0.45

Calls 4

push_backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected