From 6fcd2a13da5374ab48d43cf579be8519c40b0c40 Mon Sep 17 00:00:00 2001 From: fishpenguin Date: Fri, 29 Nov 2019 15:57:42 +0800 Subject: [PATCH] fix CPU version bug --- .../knowhere/index/vector_index/IndexNSG.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexNSG.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexNSG.cpp index 71660551c1..8cd98a74d7 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexNSG.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexNSG.cpp @@ -116,29 +116,29 @@ NSG::Train(const DatasetPtr& dataset, const Config& config) { } // 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; - if (use_gpu) { - auto preprocess_index = std::make_shared(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); - } else { +#ifdef MILVUS_GPU_VERSION + auto temp_resource = FaissGpuResourceMgr::GetInstance().GetRes(build_cfg->gpu_id); + if (temp_resource == nullptr) { auto preprocess_index = std::make_shared(); 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); + } else { + auto preprocess_index = std::make_shared(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); } +#else + auto preprocess_index = std::make_shared(); + 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; b_params.candidate_pool_size = build_cfg->candidate_pool_size;