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

Method SetWeights

src/io/metadata.cpp:321–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321void Metadata::SetWeights(const label_t* weights, data_size_t len) {
322 std::lock_guard<std::mutex> lock(mutex_);
323 // save to nullptr
324 if (weights == nullptr || len == 0) {
325 weights_.clear();
326 num_weights_ = 0;
327 return;
328 }
329 if (num_data_ != len) {
330 Log::Fatal("Length of weights is not same with #data");
331 }
332 if (!weights_.empty()) { weights_.clear(); }
333 num_weights_ = num_data_;
334 weights_ = std::vector<label_t>(num_weights_);
335 #pragma omp parallel for schedule(static)
336 for (data_size_t i = 0; i < num_weights_; ++i) {
337 weights_[i] = Common::AvoidInf(weights[i]);
338 }
339 LoadQueryWeights();
340 weight_load_from_file_ = false;
341}
342
343void Metadata::SetQuery(const data_size_t* query, data_size_t len) {
344 std::lock_guard<std::mutex> lock(mutex_);

Callers 1

SetFloatFieldMethod · 0.45

Calls 3

AvoidInfFunction · 0.50
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected