mirror of https://github.com/milvus-io/milvus.git
fix CPU version bug
parent
fd304cf4b4
commit
6fcd2a13da
|
@ -116,29 +116,29 @@ NSG::Train(const DatasetPtr& dataset, const Config& config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(linxj): dev IndexFactory, support more IndexType
|
// TODO(linxj): dev IndexFactory, support more IndexType
|
||||||
bool use_gpu = false;
|
|
||||||
#ifdef MILVUS_GPU_VERSION
|
|
||||||
use_gpu = true;
|
|
||||||
auto temp_resource = FaissGpuResourceMgr::GetInstance().GetRes(build_cfg->gpu_id);
|
|
||||||
if (temp_resource == nullptr)
|
|
||||||
use_gpu = false;
|
|
||||||
#endif
|
|
||||||
Graph knng;
|
Graph knng;
|
||||||
if (use_gpu) {
|
#ifdef MILVUS_GPU_VERSION
|
||||||
auto preprocess_index = std::make_shared<GPUIVF>(build_cfg->gpu_id);
|
auto temp_resource = FaissGpuResourceMgr::GetInstance().GetRes(build_cfg->gpu_id);
|
||||||
auto model = preprocess_index->Train(dataset, config);
|
if (temp_resource == nullptr) {
|
||||||
preprocess_index->set_index_model(model);
|
|
||||||
preprocess_index->AddWithoutIds(dataset, config);
|
|
||||||
|
|
||||||
preprocess_index->GenGraph(build_cfg->knng, knng, dataset, config);
|
|
||||||
} else {
|
|
||||||
auto preprocess_index = std::make_shared<IVF>();
|
auto preprocess_index = std::make_shared<IVF>();
|
||||||
auto model = preprocess_index->Train(dataset, config);
|
auto model = preprocess_index->Train(dataset, config);
|
||||||
preprocess_index->set_index_model(model);
|
preprocess_index->set_index_model(model);
|
||||||
preprocess_index->AddWithoutIds(dataset, config);
|
preprocess_index->AddWithoutIds(dataset, config);
|
||||||
|
preprocess_index->GenGraph(build_cfg->knng, knng, dataset, config);
|
||||||
|
} else {
|
||||||
|
auto preprocess_index = std::make_shared<GPUIVF>(build_cfg->gpu_id);
|
||||||
|
auto model = preprocess_index->Train(dataset, config);
|
||||||
|
preprocess_index->set_index_model(model);
|
||||||
|
preprocess_index->AddWithoutIds(dataset, config);
|
||||||
preprocess_index->GenGraph(build_cfg->knng, knng, dataset, config);
|
preprocess_index->GenGraph(build_cfg->knng, knng, dataset, config);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
auto preprocess_index = std::make_shared<IVF>();
|
||||||
|
auto model = preprocess_index->Train(dataset, config);
|
||||||
|
preprocess_index->set_index_model(model);
|
||||||
|
preprocess_index->AddWithoutIds(dataset, config);
|
||||||
|
preprocess_index->GenGraph(build_cfg->knng, knng, dataset, config);
|
||||||
|
#endif
|
||||||
|
|
||||||
algo::BuildParams b_params;
|
algo::BuildParams b_params;
|
||||||
b_params.candidate_pool_size = build_cfg->candidate_pool_size;
|
b_params.candidate_pool_size = build_cfg->candidate_pool_size;
|
||||||
|
|
Loading…
Reference in New Issue