MCPcopy Create free account
hub / github.com/antgroup/vsag / Train

Method Train

src/algorithm/ivf.cpp:355–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355void
356IVF::Train(const DatasetPtr& data) {
357 if (this->is_trained_) {
358 return;
359 }
360
361 int64_t total_elements = data->GetNumElements();
362 int64_t dim = data->GetDim();
363 DatasetPtr train_data =
364 vsag::sample_train_data(data, total_elements, dim, train_sample_count_, allocator_);
365 int64_t sample_count = train_data->GetNumElements();
366
367 partition_strategy_->Train(train_data);
368
369 const auto* data_ptr = train_data->GetFloat32Vectors();
370 this->bucket_->Train(data_ptr, sample_count);
371 if (use_reorder_) {
372 this->reorder_codes_->Train(data->GetFloat32Vectors(), data->GetNumElements());
373 }
374 this->is_trained_ = true;
375}
376
377std::vector<int64_t>
378IVF::Add(const DatasetPtr& base) {

Callers 13

BuildMethod · 0.95
vsag_index_trainFunction · 0.45
TestIVFMergeFunction · 0.45
TestHGraphMergeFunction · 0.45
TestTrainAndAddMethod · 0.45
TestRemoveIndexMethod · 0.45
TestIndexStatusMethod · 0.45
mainFunction · 0.45

Calls 4

sample_train_dataFunction · 0.85
GetNumElementsMethod · 0.45
GetDimMethod · 0.45
GetFloat32VectorsMethod · 0.45

Tested by 7

TestIVFMergeFunction · 0.36
TestHGraphMergeFunction · 0.36
TestTrainAndAddMethod · 0.36
TestRemoveIndexMethod · 0.36
TestIndexStatusMethod · 0.36