Skip to content

Commit

Permalink
Fix possible asan in unit tests (#734)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Guzhva <[email protected]>
  • Loading branch information
alexanderguzhva authored Jul 29, 2024
1 parent 6710318 commit 177374d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/ut/test_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TEST_CASE("Test Kmeans With Float Vector", "[float metrics]") {
const std::string NUM_CLUSTERS = "num_clusters";
auto topk = 1;

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[NUM_CLUSTERS] = num_clusters;
return json;
Expand Down
4 changes: 2 additions & 2 deletions tests/ut/test_diskann.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ TEST_CASE("Test DiskANN GetVectorByIds", "[diskann]") {
fs::remove(kDir);
REQUIRE_NOTHROW(fs::create_directories(kL2IndexDir));

auto base_gen = [&] {
auto base_gen = [=] {
knowhere::Json json;
json[knowhere::meta::RETRIEVE_FRIENDLY] = true;
json["dim"] = dim;
Expand All @@ -351,7 +351,7 @@ TEST_CASE("Test DiskANN GetVectorByIds", "[diskann]") {
return json;
};

auto build_gen = [&]() {
auto build_gen = [=]() {
knowhere::Json json = base_gen();
json["index_prefix"] = kL2IndexPrefix;
json["data_path"] = kRawDataPath;
Expand Down
6 changes: 3 additions & 3 deletions tests/ut/test_feder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TEST_CASE("Test Feder", "[feder]") {

auto version = GenTestVersionList();

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = knowhere::metric::L2;
Expand All @@ -153,14 +153,14 @@ TEST_CASE("Test Feder", "[feder]") {
return json;
};

auto ivfflat_gen = [&base_gen]() {
auto ivfflat_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NLIST] = 16;
json[knowhere::indexparam::NPROBE] = 4;
return json;
};

auto hnsw_gen = [&base_gen]() {
auto hnsw_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::HNSW_M] = 8;
json[knowhere::indexparam::EFCONSTRUCTION] = 200;
Expand Down
8 changes: 4 additions & 4 deletions tests/ut/test_gpu_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST_CASE("Test All GPU Index", "[search]") {

auto version = GenTestVersionList();

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = knowhere::metric::L2;
Expand All @@ -42,21 +42,21 @@ TEST_CASE("Test All GPU Index", "[search]") {

auto bruteforce_gen = base_gen;

auto ivfflat_gen = [&base_gen]() {
auto ivfflat_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NLIST] = 16;
json[knowhere::indexparam::NPROBE] = 16;
return json;
};

auto ivfpq_gen = [&ivfflat_gen]() {
auto ivfpq_gen = [ivfflat_gen]() {
knowhere::Json json = ivfflat_gen();
json[knowhere::indexparam::M] = 0;
json[knowhere::indexparam::NBITS] = 8;
return json;
};

auto cagra_gen = [&base_gen]() {
auto cagra_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::INTERMEDIATE_GRAPH_DEGREE] = 128;
json[knowhere::indexparam::GRAPH_DEGREE] = 64;
Expand Down
16 changes: 8 additions & 8 deletions tests/ut/test_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,30 @@ TEST_CASE("Test Iterator Mem Index With Float Vector", "[float metrics]") {
auto metric = GENERATE(as<std::string>{}, knowhere::metric::L2, knowhere::metric::COSINE, knowhere::metric::IP);
auto version = GenTestVersionList();

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = metric;
json[knowhere::meta::TOPK] = topk;
return json;
};

auto hnsw_gen = [&base_gen]() {
auto hnsw_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::HNSW_M] = 128;
json[knowhere::indexparam::EFCONSTRUCTION] = 200;
json[knowhere::indexparam::EF] = 64;
return json;
};

auto ivfflat_gen = [&base_gen]() {
auto ivfflat_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NPROBE] = 16;
json[knowhere::indexparam::NLIST] = 24;
return json;
};

auto ivfflatcc_gen = [&base_gen]() {
auto ivfflatcc_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NPROBE] = 16;
json[knowhere::indexparam::NLIST] = 24;
Expand Down Expand Up @@ -252,15 +252,15 @@ TEST_CASE("Test Iterator IVFFlatCC With Newly Insert Vectors", "[float metrics]
auto metric = GENERATE(as<std::string>{}, knowhere::metric::L2, knowhere::metric::COSINE, knowhere::metric::IP);
auto version = GenTestVersionList();

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = metric;
json[knowhere::meta::TOPK] = topk;
return json;
};

auto ivfflatcc_gen = [&base_gen]() {
auto ivfflatcc_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NPROBE] = 16;
json[knowhere::indexparam::NLIST] = 24;
Expand Down Expand Up @@ -332,15 +332,15 @@ TEST_CASE("Test Iterator Mem Index With Binary Metrics", "[binary metrics]") {
auto metric = GENERATE(as<std::string>{}, knowhere::metric::HAMMING, knowhere::metric::JACCARD);
auto version = GenTestVersionList();

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = metric;
json[knowhere::meta::TOPK] = topk;
return json;
};

auto hnsw_gen = [&base_gen]() {
auto hnsw_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::HNSW_M] = 128;
json[knowhere::indexparam::EFCONSTRUCTION] = 200;
Expand Down
8 changes: 4 additions & 4 deletions tests/ut/test_ivfflat_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_CASE("Test Build Search Concurrency", "[Concurrency]") {
int64_t build_task_num = 1;
int64_t search_task_num = 10;

auto base_gen = [&]() {
auto base_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = metric;
Expand All @@ -45,22 +45,22 @@ TEST_CASE("Test Build Search Concurrency", "[Concurrency]") {
return json;
};

auto ivf_gen = [&base_gen]() {
auto ivf_gen = [base_gen]() {
knowhere::Json json = base_gen();
json[knowhere::indexparam::NLIST] = 128;
json[knowhere::indexparam::NPROBE] = 16;
json[knowhere::indexparam::ENSURE_TOPK_FULL] = false;
return json;
};

auto ivf_cc_gen = [&ivf_gen]() {
auto ivf_cc_gen = [ivf_gen]() {
knowhere::Json json = ivf_gen();
json[knowhere::meta::NUM_BUILD_THREAD] = 1;
json[knowhere::indexparam::SSIZE] = 48;
return json;
};

auto ivf_sq_8_cc_gen = [&ivf_cc_gen]() {
auto ivf_sq_8_cc_gen = [ivf_cc_gen]() {
knowhere::Json json = ivf_cc_gen();
json[knowhere::indexparam::CODE_SIZE] = 8;
return json;
Expand Down
4 changes: 2 additions & 2 deletions tests/ut/test_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ TEST_CASE("Test Mem Index With Float Vector", "[float metrics]") {
.value();
uint32_t nb = 1000;
uint32_t dim = 128;
auto ivf_pq_gen = [&]() {
auto ivf_pq_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = knowhere::metric::L2;
Expand All @@ -398,7 +398,7 @@ TEST_CASE("Test Mem Index With Float Vector", "[float metrics]") {
.value();
uint32_t nb = 1000;
uint32_t dim = 128;
auto ivf_pq_gen = [&]() {
auto ivf_pq_gen = [=]() {
knowhere::Json json;
json[knowhere::meta::DIM] = dim;
json[knowhere::meta::METRIC_TYPE] = knowhere::metric::L2;
Expand Down

0 comments on commit 177374d

Please sign in to comment.