From 50f15b3576cb09ceac6c2d3d19d093b24efcf632 Mon Sep 17 00:00:00 2001 From: Navneet Verma Date: Mon, 3 Jul 2023 18:49:01 -0700 Subject: [PATCH] Fixing unit test for Faiss due to faiss upgrade. (#951) Signed-off-by: Navneet Verma --- DEVELOPER_GUIDE.md | 4 ++-- jni/tests/faiss_wrapper_test.cpp | 16 ++++++++-------- jni/tests/test_util.cpp | 6 +++--- jni/tests/test_util.h | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index d8ef9e413..4fe31487a 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -56,11 +56,11 @@ In addition to this, the plugin has been tested with JDK 17, and this JDK versio #### CMake -The plugin requires that cmake >= 3.23.1 is installed in order to build the JNI libraries. +The plugin requires that cmake >= 3.23.3 is installed in order to build the JNI libraries. One easy way to install on mac or linux is to use pip: ```bash -pip install cmake==3.23.1 +pip install cmake==3.23.3 ``` #### Faiss Dependencies diff --git a/jni/tests/faiss_wrapper_test.cpp b/jni/tests/faiss_wrapper_test.cpp index 440061b0e..abe4ecb20 100644 --- a/jni/tests/faiss_wrapper_test.cpp +++ b/jni/tests/faiss_wrapper_test.cpp @@ -23,8 +23,8 @@ using ::testing::Return; TEST(FaissCreateIndexTest, BasicAssertions) { // Define the data - faiss::Index::idx_t numIds = 200; - std::vector ids; + faiss::idx_t numIds = 200; + std::vector ids; std::vector> vectors; int dim = 2; for (int64_t i = 0; i < numIds; ++i) { @@ -70,8 +70,8 @@ TEST(FaissCreateIndexTest, BasicAssertions) { TEST(FaissCreateIndexFromTemplateTest, BasicAssertions) { // Define the data - faiss::Index::idx_t numIds = 100; - std::vector ids; + faiss::idx_t numIds = 100; + std::vector ids; std::vector> vectors; int dim = 2; for (int64_t i = 0; i < numIds; ++i) { @@ -122,8 +122,8 @@ TEST(FaissCreateIndexFromTemplateTest, BasicAssertions) { TEST(FaissLoadIndexTest, BasicAssertions) { // Define the data - faiss::Index::idx_t numIds = 100; - std::vector ids; + faiss::idx_t numIds = 100; + std::vector ids; std::vector vectors; int dim = 2; for (int64_t i = 0; i < numIds; i++) { @@ -174,8 +174,8 @@ TEST(FaissLoadIndexTest, BasicAssertions) { TEST(FaissQueryIndexTest, BasicAssertions) { // Define the index data - faiss::Index::idx_t numIds = 100; - std::vector ids; + faiss::idx_t numIds = 100; + std::vector ids; std::vector vectors; int dim = 16; for (int64_t i = 0; i < numIds; i++) { diff --git a/jni/tests/test_util.cpp b/jni/tests/test_util.cpp index 096f2f415..a75886c51 100644 --- a/jni/tests/test_util.cpp +++ b/jni/tests/test_util.cpp @@ -234,7 +234,7 @@ faiss::Index *test_util::FaissLoadFromSerializedIndex( } faiss::IndexIDMap test_util::FaissAddData(faiss::Index *index, - std::vector ids, + std::vector ids, std::vector dataset) { faiss::IndexIDMap idMap = faiss::IndexIDMap(index); idMap.add_with_ids(ids.size(), dataset.data(), ids.data()); @@ -251,11 +251,11 @@ faiss::Index *test_util::FaissLoadIndex(const std::string &indexPath) { } void test_util::FaissQueryIndex(faiss::Index *index, float *query, int k, - float *distances, faiss::Index::idx_t *ids) { + float *distances, faiss::idx_t *ids) { index->search(1, query, k, distances, ids); } -void test_util::FaissTrainIndex(faiss::Index *index, faiss::Index::idx_t n, +void test_util::FaissTrainIndex(faiss::Index *index, faiss::idx_t n, const float *x) { if (auto *indexIvf = dynamic_cast(index)) { if (indexIvf->quantizer_trains_alone == 2) { diff --git a/jni/tests/test_util.h b/jni/tests/test_util.h index cd47be476..6eac70fcf 100644 --- a/jni/tests/test_util.h +++ b/jni/tests/test_util.h @@ -108,7 +108,7 @@ namespace test_util { faiss::Index* FaissLoadFromSerializedIndex(std::vector* indexSerial); faiss::IndexIDMap FaissAddData(faiss::Index* index, - std::vector ids, + std::vector ids, std::vector dataset); void FaissWriteIndex(faiss::Index* index, const std::string& indexPath); @@ -116,9 +116,9 @@ namespace test_util { faiss::Index* FaissLoadIndex(const std::string& indexPath); void FaissQueryIndex(faiss::Index* index, float* query, int k, float* distances, - faiss::Index::idx_t* ids); + faiss::idx_t* ids); - void FaissTrainIndex(faiss::Index* index, faiss::Index::idx_t n, + void FaissTrainIndex(faiss::Index* index, faiss::idx_t n, const float* x); // -------------------------------------------------------------------------------