mirror of https://github.com/milvus-io/milvus.git
Fix dataset's memory leak in knowWhere when search (#7527)
Signed-off-by: xige-16 <xi.ge@zilliz.com>pull/7531/head
parent
5b22697ec4
commit
468bef4478
|
@ -17,6 +17,7 @@
|
|||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "knowhere/index/vector_index/helpers/IndexParameter.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace knowhere {
|
||||
|
@ -27,7 +28,20 @@ using ValuePtr = std::shared_ptr<Value>;
|
|||
class Dataset {
|
||||
public:
|
||||
Dataset() = default;
|
||||
|
||||
~Dataset() {
|
||||
for (auto const& d : data_) {
|
||||
if (d.first == meta::IDS) {
|
||||
auto row_data = Get<int64_t*>(milvus::knowhere::meta::IDS);
|
||||
// the space of ids must be allocated through malloc
|
||||
free(row_data);
|
||||
}
|
||||
if (d.first == meta::DISTANCE) {
|
||||
auto row_data = Get<float*>(milvus::knowhere::meta::DISTANCE);
|
||||
// the space of distance must be allocated through malloc
|
||||
free(row_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void
|
||||
Set(const std::string& k, T&& v) {
|
||||
|
|
|
@ -67,7 +67,6 @@ TEST_P(AnnoyTest, annoy_basic) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
/*
|
||||
* output result to check by eyes
|
||||
|
@ -107,11 +106,9 @@ TEST_P(AnnoyTest, annoy_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
/*
|
||||
* delete result checked by eyes
|
||||
|
@ -217,7 +214,6 @@ TEST_P(AnnoyTest, annoy_slice) {
|
|||
ASSERT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_basic) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
auto binaryset = index_->Serialize(conf);
|
||||
auto new_index = std::make_shared<milvus::knowhere::BinaryIDMAP>();
|
||||
|
@ -78,7 +77,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_basic) {
|
|||
auto result2 = new_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result2, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared<faiss::ConcurrentBitset>(nb);
|
||||
for (int64_t i = 0; i < nq; ++i) {
|
||||
|
@ -87,7 +85,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_basic) {
|
|||
|
||||
auto result_bs_1 = index_->Query(query_dataset, conf, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
// auto result4 = index_->SearchById(id_dataset, conf);
|
||||
// AssertAneq(result4, nq, k);
|
||||
|
@ -116,7 +113,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_serialize) {
|
|||
auto re_result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(re_result, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(re_result);
|
||||
EXPECT_EQ(index_->Count(), nb);
|
||||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto binaryset = index_->Serialize(conf);
|
||||
|
@ -136,7 +132,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_serialize) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +151,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_slice) {
|
|||
auto re_result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(re_result, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(re_result);
|
||||
EXPECT_EQ(index_->Count(), nb);
|
||||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto binaryset = index_->Serialize(conf);
|
||||
|
@ -167,7 +161,6 @@ TEST_P(BinaryIDMAPTest, binaryidmap_slice) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ TEST_P(BinaryIVFTest, binaryivf_basic) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared<faiss::ConcurrentBitset>(nb);
|
||||
for (int64_t i = 0; i < nq; ++i) {
|
||||
|
@ -84,7 +83,6 @@ TEST_P(BinaryIVFTest, binaryivf_basic) {
|
|||
|
||||
auto result2 = index_->Query(query_dataset, conf, concurrent_bitset_ptr);
|
||||
AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
#if 0
|
||||
auto result3 = index_->QueryById(id_dataset, conf, nullptr);
|
||||
|
@ -149,7 +147,6 @@ TEST_P(BinaryIVFTest, binaryivf_serialize) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +162,5 @@ TEST_P(BinaryIVFTest, binaryivf_slice) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ TEST_F(SingleIndexTest, IVFSQHybrid) {
|
|||
auto result = gpu_idx->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +86,6 @@ TEST_F(SingleIndexTest, IVFSQHybrid) {
|
|||
auto result = gpu_idx->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
milvus::json quantizer_conf{{milvus::knowhere::meta::DEVICEID, DEVICEID}, {"mode", 2}};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
|
@ -98,7 +96,6 @@ TEST_F(SingleIndexTest, IVFSQHybrid) {
|
|||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +116,6 @@ TEST_F(SingleIndexTest, IVFSQHybrid) {
|
|||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
// PrintResult(result, nq, k);
|
||||
hybrid_idx->UnsetQuantizer();
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ TEST_F(GPURESTEST, copyandsearch) {
|
|||
index_->AddWithoutIds(base_dataset, conf);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
index_->SetIndexSize(nb * dim * sizeof(float));
|
||||
auto cpu_idx = milvus::knowhere::cloner::CopyGpuToCpu(index_, milvus::knowhere::Config());
|
||||
|
@ -90,7 +89,6 @@ TEST_F(GPURESTEST, copyandsearch) {
|
|||
// TimeRecorder tc("search&load");
|
||||
for (int i = 0; i < search_count; ++i) {
|
||||
auto result = search_idx->Query(query_dataset, conf, nullptr);
|
||||
ReleaseQueryResult(result);
|
||||
// if (i > search_count - 6 || i == 0)
|
||||
// tc.RecordSection("search once");
|
||||
}
|
||||
|
@ -110,7 +108,6 @@ TEST_F(GPURESTEST, copyandsearch) {
|
|||
milvus::knowhere::cloner::CopyCpuToGpu(cpu_idx, DEVICEID, milvus::knowhere::Config());
|
||||
tc.RecordSection("Copy to gpu once");
|
||||
auto result2 = search_idx->Query(query_dataset, conf, nullptr);
|
||||
ReleaseQueryResult(result2);
|
||||
tc.RecordSection("Search once");
|
||||
search_func();
|
||||
tc.RecordSection("Search total cost");
|
||||
|
@ -150,7 +147,6 @@ TEST_F(GPURESTEST, trainandsearch) {
|
|||
for (int i = 0; i < search_count; ++i) {
|
||||
auto result = search_idx->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ TEST_P(HNSWTest, HNSW_basic) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
// case: k > nb
|
||||
const int64_t new_rows = 6;
|
||||
|
@ -93,7 +92,6 @@ TEST_P(HNSWTest, HNSW_basic) {
|
|||
ASSERT_EQ(res_ids[i * k + j], -1);
|
||||
}
|
||||
}
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(HNSWTest, HNSW_delete) {
|
||||
|
@ -124,11 +122,9 @@ TEST_P(HNSWTest, HNSW_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
/*
|
||||
* delete result checked by eyes
|
||||
|
@ -183,7 +179,6 @@ TEST_P(HNSWTest, HNSW_serialize) {
|
|||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@ TEST_P(IDMAPTest, idmap_basic) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
if (index_mode_ == milvus::knowhere::IndexMode::MODE_GPU) {
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
|
@ -102,7 +101,6 @@ TEST_P(IDMAPTest, idmap_basic) {
|
|||
auto result2 = new_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result2, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
#if 0
|
||||
auto result3 = new_index->QueryById(id_dataset, conf);
|
||||
|
@ -119,7 +117,6 @@ TEST_P(IDMAPTest, idmap_basic) {
|
|||
|
||||
auto result_bs_1 = index_->Query(query_dataset, conf, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
#if 0
|
||||
auto result_bs_2 = index_->QueryById(id_dataset, conf);
|
||||
|
@ -158,7 +155,6 @@ TEST_P(IDMAPTest, idmap_serialize) {
|
|||
auto re_result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(re_result, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(re_result);
|
||||
EXPECT_EQ(index_->Count(), nb);
|
||||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto binaryset = index_->Serialize(conf);
|
||||
|
@ -178,7 +174,6 @@ TEST_P(IDMAPTest, idmap_serialize) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +198,6 @@ TEST_P(IDMAPTest, idmap_slice) {
|
|||
auto re_result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(re_result, nq, k);
|
||||
// PrintResult(re_result, nq, k);
|
||||
ReleaseQueryResult(re_result);
|
||||
EXPECT_EQ(index_->Count(), nb);
|
||||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto binaryset = index_->Serialize(conf);
|
||||
|
@ -214,7 +208,6 @@ TEST_P(IDMAPTest, idmap_slice) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,7 +465,6 @@ TEST_P(IDMAPTest, idmap_copy) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
{
|
||||
// clone
|
||||
|
@ -487,7 +479,6 @@ TEST_P(IDMAPTest, idmap_copy) {
|
|||
auto clone_index = milvus::knowhere::cloner::CopyCpuToGpu(index_, DEVICEID, conf);
|
||||
auto clone_result = clone_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(clone_result, nq, k);
|
||||
ReleaseQueryResult(clone_result);
|
||||
ASSERT_THROW({ std::static_pointer_cast<milvus::knowhere::GPUIDMAP>(clone_index)->GetRawVectors(); },
|
||||
milvus::knowhere::KnowhereException);
|
||||
|
||||
|
@ -500,7 +491,6 @@ TEST_P(IDMAPTest, idmap_copy) {
|
|||
clone_index->Load(binary);
|
||||
auto new_result = clone_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(new_result, nq, k);
|
||||
ReleaseQueryResult(new_result);
|
||||
|
||||
// auto clone_gpu_idx = clone_index->Clone();
|
||||
// auto clone_gpu_res = clone_gpu_idx->Search(query_dataset, conf);
|
||||
|
@ -510,7 +500,6 @@ TEST_P(IDMAPTest, idmap_copy) {
|
|||
auto host_index = milvus::knowhere::cloner::CopyGpuToCpu(clone_index, conf);
|
||||
auto host_result = host_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(host_result, nq, k);
|
||||
ReleaseQueryResult(host_result);
|
||||
ASSERT_TRUE(std::static_pointer_cast<milvus::knowhere::IDMAP>(host_index)->GetRawVectors() != nullptr);
|
||||
|
||||
// gpu to gpu
|
||||
|
@ -519,7 +508,6 @@ TEST_P(IDMAPTest, idmap_copy) {
|
|||
std::static_pointer_cast<milvus::knowhere::GPUIDMAP>(device_index)->CopyGpuToGpu(DEVICEID, conf);
|
||||
auto device_result = new_device_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(device_result, nq, k);
|
||||
ReleaseQueryResult(device_result);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -107,7 +107,6 @@ TEST_P(IVFTest, ivf_basic_cpu) {
|
|||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
if (index_type_ != milvus::knowhere::IndexEnum::INDEX_FAISS_IVFPQ) {
|
||||
#if 0
|
||||
|
@ -132,7 +131,6 @@ TEST_P(IVFTest, ivf_basic_cpu) {
|
|||
auto result_bs_1 = index_->Query(query_dataset, conf_, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
#if 0
|
||||
auto result_bs_2 = index_->QueryById(id_dataset, conf_);
|
||||
|
@ -166,7 +164,6 @@ TEST_P(IVFTest, ivf_basic_gpu) {
|
|||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared<faiss::ConcurrentBitset>(nb);
|
||||
for (int64_t i = 0; i < nq; ++i) {
|
||||
|
@ -176,7 +173,6 @@ TEST_P(IVFTest, ivf_basic_gpu) {
|
|||
auto result_bs_1 = index_->Query(query_dataset, conf_, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
// PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
milvus::knowhere::FaissGpuResourceMgr::GetInstance().Dump();
|
||||
|
@ -213,7 +209,6 @@ TEST_P(IVFTest, ivf_serialize) {
|
|||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, conf_[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,7 +225,6 @@ TEST_P(IVFTest, ivf_slice) {
|
|||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, conf_[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +263,6 @@ TEST_P(IVFTest, clone_test) {
|
|||
auto clone_index = milvus::knowhere::cloner::CopyGpuToCpu(index_, milvus::knowhere::Config());
|
||||
auto clone_result = clone_index->Query(query_dataset, conf_, nullptr);
|
||||
AssertEqual(result, clone_result);
|
||||
ReleaseQueryResult(clone_result);
|
||||
std::cout << "clone G <=> C [" << index_type_ << "] success" << std::endl;
|
||||
});
|
||||
} else {
|
||||
|
@ -289,14 +282,11 @@ TEST_P(IVFTest, clone_test) {
|
|||
auto clone_index = milvus::knowhere::cloner::CopyCpuToGpu(index_, DEVICEID, milvus::knowhere::Config());
|
||||
auto clone_result = clone_index->Query(query_dataset, conf_, nullptr);
|
||||
AssertEqual(result, clone_result);
|
||||
ReleaseQueryResult(clone_result);
|
||||
std::cout << "clone C <=> G [" << index_type_ << "] success" << std::endl;
|
||||
});
|
||||
EXPECT_ANY_THROW(milvus::knowhere::cloner::CopyCpuToGpu(index_, -1, milvus::knowhere::Config()));
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -320,7 +310,6 @@ TEST_P(IVFTest, gpu_seal_test) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, conf_[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
fiu_init(0);
|
||||
fiu_enable("IVF.Search.throw_std_exception", 1, nullptr, 0);
|
||||
|
|
|
@ -110,7 +110,6 @@ TEST_P(IVFNMCPUTest, ivf_basic_cpu) {
|
|||
auto clone_index = milvus::knowhere::cloner::CopyCpuToGpu(index_, DEVICEID, conf_);
|
||||
auto clone_result = clone_index->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(clone_result, nq, k);
|
||||
ReleaseQueryResult(clone_result);
|
||||
std::cout << "clone C <=> G [" << index_type_ << "] success" << std::endl;
|
||||
});
|
||||
EXPECT_ANY_THROW(milvus::knowhere::cloner::CopyCpuToGpu(index_, -1, milvus::knowhere::Config()));
|
||||
|
@ -124,13 +123,11 @@ TEST_P(IVFNMCPUTest, ivf_basic_cpu) {
|
|||
|
||||
auto result_bs_1 = index_->Query(query_dataset, conf_, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
milvus::knowhere::FaissGpuResourceMgr::GetInstance().Dump();
|
||||
#endif
|
||||
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
||||
TEST_P(IVFNMCPUTest, ivf_slice) {
|
||||
|
@ -163,5 +160,4 @@ TEST_P(IVFNMCPUTest, ivf_slice) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,6 @@ TEST_F(IVFNMGPUTest, ivf_basic_gpu) {
|
|||
SERIALIZE_AND_LOAD(clone_index);
|
||||
auto clone_result = clone_index->Query(query_dataset, conf_, nullptr);
|
||||
AssertEqual(result, clone_result);
|
||||
ReleaseQueryResult(clone_result);
|
||||
std::cout << "clone G <=> C [" << index_type_ << "] success" << std::endl;
|
||||
});
|
||||
}
|
||||
|
@ -131,10 +130,7 @@ TEST_F(IVFNMGPUTest, ivf_basic_gpu) {
|
|||
|
||||
auto result_bs_1 = index_->Query(query_dataset, conf_, concurrent_bitset_ptr);
|
||||
AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result_bs_1);
|
||||
|
||||
milvus::knowhere::FaissGpuResourceMgr::GetInstance().Dump();
|
||||
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,6 @@ TEST_P(IVFHNSWTest, ivfhnsw_basic_cpu) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
||||
TEST_P(IVFHNSWTest, ivfhnsw_slice) {
|
||||
|
@ -93,6 +92,5 @@ TEST_P(IVFHNSWTest, ivfhnsw_slice) {
|
|||
EXPECT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf_, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ TEST_P(NGTONNGTest, ngtonng_basic) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
||||
TEST_P(NGTONNGTest, ngtonng_delete) {
|
||||
|
@ -87,11 +86,9 @@ TEST_P(NGTONNGTest, ngtonng_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(NGTONNGTest, ngtonng_serialize) {
|
||||
|
@ -149,7 +146,6 @@ TEST_P(NGTONNGTest, ngtonng_serialize) {
|
|||
ASSERT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +160,5 @@ TEST_P(NGTONNGTest, ngtonng_slice) {
|
|||
ASSERT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ TEST_P(NGTPANNGTest, ngtpanng_basic) {
|
|||
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
||||
TEST_P(NGTPANNGTest, ngtpanng_delete) {
|
||||
|
@ -87,11 +86,9 @@ TEST_P(NGTPANNGTest, ngtpanng_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(NGTPANNGTest, ngtpanng_serialize) {
|
||||
|
@ -149,7 +146,6 @@ TEST_P(NGTPANNGTest, ngtpanng_serialize) {
|
|||
ASSERT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +160,5 @@ TEST_P(NGTPANNGTest, ngtpanng_slice) {
|
|||
ASSERT_EQ(index_->Dim(), dim);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,6 @@ TEST_F(NSGInterfaceTest, basic_test) {
|
|||
|
||||
auto result_1 = index_->Query(query_dataset, search_conf, nullptr);
|
||||
AssertAnns(result_1, nq, k);
|
||||
ReleaseQueryResult(result_1);
|
||||
|
||||
/* test NSG GPU train */
|
||||
auto new_index = std::make_shared<milvus::knowhere::NSG_NM>(DEVICE_GPU0);
|
||||
|
@ -125,7 +124,6 @@ TEST_F(NSGInterfaceTest, basic_test) {
|
|||
|
||||
auto result_2 = new_index->Query(query_dataset, search_conf, nullptr);
|
||||
AssertAnns(result_2, nq, k);
|
||||
ReleaseQueryResult(result_2);
|
||||
|
||||
ASSERT_EQ(index_->Count(), nb);
|
||||
ASSERT_EQ(index_->Dim(), dim);
|
||||
|
@ -199,9 +197,6 @@ TEST_F(NSGInterfaceTest, delete_test) {
|
|||
for (int i = 0; i < nq; i++) {
|
||||
ASSERT_NE(I_before[i * k], I_after[i * k]);
|
||||
}
|
||||
|
||||
ReleaseQueryResult(result);
|
||||
ReleaseQueryResult(result_after);
|
||||
}
|
||||
|
||||
TEST_F(NSGInterfaceTest, slice_test) {
|
||||
|
@ -232,7 +227,6 @@ TEST_F(NSGInterfaceTest, slice_test) {
|
|||
|
||||
auto result = index_->Query(query_dataset, search_conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
/* test NSG GPU train */
|
||||
auto new_index_1 = std::make_shared<milvus::knowhere::NSG_NM>(DEVICE_GPU0);
|
||||
|
@ -254,7 +248,6 @@ TEST_F(NSGInterfaceTest, slice_test) {
|
|||
|
||||
auto new_result_1 = new_index_1->Query(query_dataset, search_conf, nullptr);
|
||||
AssertAnns(new_result_1, nq, k);
|
||||
ReleaseQueryResult(new_result_1);
|
||||
|
||||
ASSERT_EQ(index_->Count(), nb);
|
||||
ASSERT_EQ(index_->Dim(), dim);
|
||||
|
|
|
@ -58,7 +58,6 @@ TEST_P(RHNSWFlatTest, HNSW_basic) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
// Serialize and Load before Query
|
||||
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
|
||||
|
@ -76,7 +75,6 @@ TEST_P(RHNSWFlatTest, HNSW_basic) {
|
|||
|
||||
auto result2 = tmp_index->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result2, nq, k);
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(RHNSWFlatTest, HNSW_delete) {
|
||||
|
@ -94,11 +92,9 @@ TEST_P(RHNSWFlatTest, HNSW_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
// AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
/*
|
||||
* delete result checked by eyes
|
||||
|
@ -175,7 +171,6 @@ TEST_P(RHNSWFlatTest, HNSW_serialize) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +192,5 @@ TEST_P(RHNSWFlatTest, HNSW_slice) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ TEST_P(RHNSWPQTest, HNSW_basic) {
|
|||
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto tmp_index = std::make_shared<milvus::knowhere::IndexRHNSWPQ>();
|
||||
|
||||
|
@ -67,7 +66,6 @@ TEST_P(RHNSWPQTest, HNSW_basic) {
|
|||
|
||||
auto result2 = tmp_index->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result2, nq, k);
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(RHNSWPQTest, HNSW_delete) {
|
||||
|
@ -85,11 +83,9 @@ TEST_P(RHNSWPQTest, HNSW_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
// AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
/*
|
||||
* delete result checked by eyes
|
||||
|
@ -150,7 +146,6 @@ TEST_P(RHNSWPQTest, HNSW_serialize) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +160,5 @@ TEST_P(RHNSWPQTest, HNSW_slice) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ TEST_P(RHNSWSQ8Test, HNSW_basic) {
|
|||
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto tmp_index = std::make_shared<milvus::knowhere::IndexRHNSWSQ>();
|
||||
|
||||
|
@ -69,7 +68,6 @@ TEST_P(RHNSWSQ8Test, HNSW_basic) {
|
|||
|
||||
auto result2 = tmp_index->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result2, nq, k);
|
||||
ReleaseQueryResult(result2);
|
||||
}
|
||||
|
||||
TEST_P(RHNSWSQ8Test, HNSW_delete) {
|
||||
|
@ -87,11 +85,9 @@ TEST_P(RHNSWSQ8Test, HNSW_delete) {
|
|||
|
||||
auto result1 = index_->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result1, nq, k);
|
||||
ReleaseQueryResult(result1);
|
||||
|
||||
auto result2 = index_->Query(query_dataset, conf, bitset);
|
||||
// AssertAnns(result2, nq, k, CheckMode::CHECK_NOT_EQUAL);
|
||||
ReleaseQueryResult(result2);
|
||||
|
||||
/*
|
||||
* delete result checked by eyes
|
||||
|
@ -152,7 +148,6 @@ TEST_P(RHNSWSQ8Test, HNSW_serialize) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,6 +162,5 @@ TEST_P(RHNSWSQ8Test, HNSW_slice) {
|
|||
EXPECT_EQ(new_idx->Dim(), dim);
|
||||
auto result = new_idx->Query(query_dataset, conf, nullptr);
|
||||
// AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ TEST_P(SPTAGTest, sptag_basic) {
|
|||
// index_->Add(base_dataset, conf);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
{
|
||||
auto ids = result->Get<int64_t*>(milvus::knowhere::meta::IDS);
|
||||
|
@ -103,7 +102,6 @@ TEST_P(SPTAGTest, sptag_serialize) {
|
|||
auto result = new_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
ASSERT_EQ(new_index->Count(), nb);
|
||||
ASSERT_EQ(new_index->Dim(), dim);
|
||||
// ASSERT_THROW({ new_index->Clone(); }, milvus::knowhere::KnowhereException);
|
||||
|
@ -188,6 +186,5 @@ TEST_P(SPTAGTest, sptag_slice) {
|
|||
auto result = new_index->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, k);
|
||||
PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ TEST_P(VecIndexTest, basic) {
|
|||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
PrintResult(result, nq, k);
|
||||
ReleaseQueryResult(result);
|
||||
}
|
||||
|
||||
TEST_P(VecIndexTest, serialize) {
|
||||
|
@ -97,7 +96,6 @@ TEST_P(VecIndexTest, serialize) {
|
|||
EXPECT_EQ(index_->index_mode(), index_mode_);
|
||||
auto result = index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(result);
|
||||
|
||||
auto binaryset = index_->Serialize();
|
||||
auto new_index = milvus::knowhere::VecIndexFactory::GetInstance().CreateVecIndex(index_type_, index_mode_);
|
||||
|
@ -108,7 +106,6 @@ TEST_P(VecIndexTest, serialize) {
|
|||
EXPECT_EQ(index_->index_mode(), new_index->index_mode());
|
||||
auto new_result = new_index_->Query(query_dataset, conf, nullptr);
|
||||
AssertAnns(new_result, nq, conf[milvus::knowhere::meta::TOPK]);
|
||||
ReleaseQueryResult(new_result);
|
||||
}
|
||||
|
||||
// todo
|
||||
|
|
|
@ -58,17 +58,6 @@ AssembleNegBitset(const BitsetSimple& bitset_simple) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// TODO: temporary fix
|
||||
// remove this when internal destructor bug is fix
|
||||
static void
|
||||
ReleaseQueryResult(const knowhere::DatasetPtr& result) {
|
||||
float* res_dist = result->Get<float*>(knowhere::meta::DISTANCE);
|
||||
free(res_dist);
|
||||
|
||||
int64_t* res_ids = result->Get<int64_t*>(knowhere::meta::IDS);
|
||||
free(res_ids);
|
||||
}
|
||||
|
||||
void
|
||||
SearchOnSealed(const Schema& schema,
|
||||
const segcore::SealedIndexingRecord& record,
|
||||
|
@ -111,9 +100,5 @@ SearchOnSealed(const Schema& schema,
|
|||
|
||||
std::copy_n(ids, total_num, result.internal_seg_offsets_.data());
|
||||
std::copy_n(distances, total_num, result.result_distances_.data());
|
||||
|
||||
// TODO: temporary fix
|
||||
// remove this when internal destructor bug is fix
|
||||
ReleaseQueryResult(final);
|
||||
}
|
||||
} // namespace milvus::query
|
||||
|
|
Loading…
Reference in New Issue