From a4b50e301f42856b2c6d696da59cbfe5a62124d1 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Tue, 26 Mar 2024 00:09:23 -0700 Subject: [PATCH 01/18] change cmake --- tests/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0cb8219096..66ec9f74a5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,6 +59,34 @@ if(FAISS_OPT_LEVEL STREQUAL "avx512") target_link_libraries(faiss_test PRIVATE faiss_avx512) endif() +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # release-1.12.1 + OVERRIDE_FIND_PACKAGE) +set(BUILD_GMOCK CACHE BOOL OFF) +set(INSTALL_GTEST CACHE BOOL OFF) +FetchContent_MakeAvailable(googletest) + +if(NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/gtest-config.cmake + AND NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/GTestConfig.cmake) + file( + WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/gtest-config.cmake + [=[ +include(CMakeFindDependencyMacro) +find_dependency(googletest) +if(NOT TARGET GTest::GTest) + add_library(GTest::GTest INTERFACE IMPORTED) + target_link_libraries(GTest::GTest INTERFACE GTest::gtest) +endif() +if(NOT TARGET GTest::Main) + add_library(GTest::Main INTERFACE IMPORTED) + target_link_libraries(GTest::Main INTERFACE GTest::gtest_main) +endif() +]=]) +endif() + find_package(OpenMP REQUIRED) find_package(GTest CONFIG REQUIRED) From 1fcb3de0fe8010815bc93740e393d82162c05acc Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Mon, 25 Mar 2024 00:22:05 -0700 Subject: [PATCH 02/18] Fix faiss swig build with version > 4.2.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Currently, faiss can't build with swig version > 4.2.x. As the https://github.com/facebookresearch/faiss/issues/3239 mentioned. Swig removed the support for 32bit https://github.com/swig/swig/commit/9fb3a4939e4ec528f050057d8ccd743a066222ac. So SWIGTYPE_p_unsigned_long_long isn't supported any more. In this diff, we are going to remove the unsupported type from Faiss swig. Test Plan: STEP 1: create a new conda env ``` conda create --name faiss_swig conda activate faiss_swig ``` STEP 2: install dependecies from conda-forge ``` conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 -c conda-forge ``` STEP 3: CMAKE ``` cmake -B build \ [system] -DBUILD_TESTING=ON \ -DBUILD_SHARED_LIBS=ON \ -DFAISS_ENABLE_GPU=OFF \ -DFAISS_ENABLE_RAFT=OFF \ -DFAISS_OPT_LEVEL=avx512 \ -DFAISS_ENABLE_C_API=ON \ -DPYTHON_EXECUTABLE=$(which python) \ -DCMAKE_BUILD_TYPE=Release \ -DBLA_VENDOR=Intel10_64_dyn \ -DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \ . ``` STEP 4: build ``` make -C build -j faiss && make -C build -j swigfaiss ``` /var/folders/n5/8sm28y7j7hl8w4xdtl7r_33w0000gn/T/TemporaryItems/NSIRD_screencaptureui_AjUh4J/Screenshot 2024-03-25 at 12.21.25 AM.png --- faiss/python/swigfaiss.swig | 8 -------- 1 file changed, 8 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index fb7f50dd2e..ee95165c6f 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,18 +1022,10 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#ifdef SWIGWORDSIZE64 return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); -#else - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); -#endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#ifdef SWIGWORDSIZE64 return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0); -#else - return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0); -#endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); return NULL; From f235edbc480e9caa7183336f5b74ed525a58e65b Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Mon, 25 Mar 2024 00:29:20 -0700 Subject: [PATCH 03/18] Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .circleci/config.yml | 4 ++-- conda/faiss-gpu-raft/meta.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 289f812526..d5519186b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -224,7 +224,7 @@ jobs: - run: name: Install env using main channel command: | - conda install -y -q python=3.11 cmake make swig=4.0.2 mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64 + conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64 -c conda-forge - when: condition: equal: [ "ON", << parameters.raft >> ] @@ -232,7 +232,7 @@ jobs: - run: name: Install env using conda-forge channel command: | - conda install -y -q python=3.11 cmake make swig=4.0.2 mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge + conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge - when: condition: and: diff --git a/conda/faiss-gpu-raft/meta.yaml b/conda/faiss-gpu-raft/meta.yaml index 12dfc889b1..c43e7656c3 100644 --- a/conda/faiss-gpu-raft/meta.yaml +++ b/conda/faiss-gpu-raft/meta.yaml @@ -84,7 +84,7 @@ outputs: build: - {{ compiler('cxx') }} - sysroot_linux-64 =2.17 # [linux64] - - swig =4.0.2 + - swig - cmake >=3.23.1 - make # [not win] host: From a3498c047e1569082e188145b1e279224de29c06 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Mon, 25 Mar 2024 18:01:17 -0700 Subject: [PATCH 04/18] add debug output Tags: --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d5519186b3..42e6e2faeb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -266,7 +266,7 @@ jobs: name: C++ tests command: | export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/" - make -C build test + make -C build test --output-on-failure - run: name: Install Python extension command: | From 673f48ad26a8b965ccfb683303e3a21ef9688d27 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Tue, 26 Mar 2024 00:40:24 -0700 Subject: [PATCH 05/18] remove broken change --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 42e6e2faeb..d5519186b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -266,7 +266,7 @@ jobs: name: C++ tests command: | export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/" - make -C build test --output-on-failure + make -C build test - run: name: Install Python extension command: | From 8de8d7e971d3867168de67742182915d3ee0b727 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Wed, 27 Mar 2024 15:01:39 -0700 Subject: [PATCH 06/18] add gcc version --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d5519186b3..549e4a2793 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -224,7 +224,7 @@ jobs: - run: name: Install env using main channel command: | - conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64 -c conda-forge + conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64=11.2 sysroot_linux-64 - when: condition: equal: [ "ON", << parameters.raft >> ] @@ -232,7 +232,7 @@ jobs: - run: name: Install env using conda-forge channel command: | - conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge + conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64=11.2 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge - when: condition: and: From 6598d49fa2ddf75c91ed94c4eb007fa23331b7aa Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Wed, 27 Mar 2024 22:53:54 -0700 Subject: [PATCH 07/18] try to fix test --- tests/test_graph_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_graph_based.py b/tests/test_graph_based.py index dd4212d717..edbcacb829 100644 --- a/tests/test_graph_based.py +++ b/tests/test_graph_based.py @@ -26,7 +26,7 @@ def __init__(self, *args, **kwargs): (_, self.xb, self.xq) = get_dataset_2(d, nt, nb, nq) index = faiss.IndexFlatL2(d) index.add(self.xb) - Dref, Iref = index.search(self.xq, 1) + Dref, Iref = index.search(self.xq, int(1)) self.Iref = Iref def test_hnsw(self): From 961713ae74cfbb593a78a35042e17078c297669b Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Wed, 27 Mar 2024 23:40:04 -0700 Subject: [PATCH 08/18] remove debug info --- tests/test_graph_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_graph_based.py b/tests/test_graph_based.py index edbcacb829..dd4212d717 100644 --- a/tests/test_graph_based.py +++ b/tests/test_graph_based.py @@ -26,7 +26,7 @@ def __init__(self, *args, **kwargs): (_, self.xb, self.xq) = get_dataset_2(d, nt, nb, nq) index = faiss.IndexFlatL2(d) index.add(self.xb) - Dref, Iref = index.search(self.xq, int(1)) + Dref, Iref = index.search(self.xq, 1) self.Iref = Iref def test_hnsw(self): From 8a17e06f12235fcc23fab6d2b0899024f3b763b6 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 12:11:00 -0700 Subject: [PATCH 09/18] add long long marco --- faiss/python/swigfaiss.swig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index ee95165c6f..c7488e1aed 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,10 +1022,18 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { +#ifdef __SIZEOF_LONG_LONG__ return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#endif } if(PyArray_TYPE(ao) == NPY_INT64) { - return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0); +#ifdef __SIZEOF_LONG_LONG__ + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); return NULL; From c1c8ee31ee5a72653c2e6c0ddd9abe3c8dce01a0 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 12:18:48 -0700 Subject: [PATCH 10/18] try sizeof_long --- faiss/python/swigfaiss.swig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index c7488e1aed..43dd1fc5b7 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,17 +1022,17 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#ifdef __SIZEOF_LONG_LONG__ - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); -#else +#ifdef __SIZEOF_LONG__ return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#ifdef __SIZEOF_LONG_LONG__ - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); -#else +#ifdef __SIZEOF_LONG__ return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); From 9ce9a67be65c77e5c9ad2df55541f1238b736156 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 13:15:31 -0700 Subject: [PATCH 11/18] _LONG_WIDTH__ --- faiss/python/swigfaiss.swig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 43dd1fc5b7..225ec822fb 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,14 +1022,14 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#ifdef __SIZEOF_LONG__ +#ifdef _LONG_WIDTH__ return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#ifdef __SIZEOF_LONG__ +#ifdef _LONG_WIDTH__ return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); From 50144f5b4a13ac92cbd03c71ba308060453322cd Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 14:09:29 -0700 Subject: [PATCH 12/18] try another macro --- faiss/python/swigfaiss.swig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 225ec822fb..4a7183a6aa 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,14 +1022,14 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#ifdef _LONG_WIDTH__ +#if __WORDSIZE == 32 return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#ifdef _LONG_WIDTH__ +#if __WORDSIZE == 32 return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); From 4432541f15f3c77017ffb58a5ab9ff739ce82bff Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 14:16:54 -0700 Subject: [PATCH 13/18] use size_of_long --- faiss/python/swigfaiss.swig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 4a7183a6aa..e69f6d48b9 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,14 +1022,14 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#if __WORDSIZE == 32 +#if __SIZEOF_LONG__ == 4 return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#if __WORDSIZE == 32 +#if __SIZEOF_LONG__ == 4 return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); From 449964ef9c7dba9d73fe3eae7d7e6ce810839e13 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 14:29:00 -0700 Subject: [PATCH 14/18] use size_of_long --- faiss/python/swigfaiss.swig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index e69f6d48b9..f1ca840418 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,17 +1022,17 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#if __SIZEOF_LONG__ == 4 - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); -#else +#if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#if __SIZEOF_LONG__ == 4 - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); -#else +#if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); From 19b73efe4bf86e58cff650b7e9243c27d2246de3 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 15:48:34 -0700 Subject: [PATCH 15/18] use __wordsize --- faiss/python/swigfaiss.swig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index f1ca840418..9372823b38 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,17 +1022,17 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); -#else +#if (__WORDSIZE == 32) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); -#else +#if (__WORDSIZE == 32) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); From cb243fc2d95286b19e1beb44bed2eeb8d24c41b8 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 17:19:25 -0700 Subject: [PATCH 16/18] fix typo --- faiss/python/swigfaiss.swig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 9372823b38..a1a3624c14 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1030,9 +1030,9 @@ PyObject *swig_ptr (PyObject *a) } if(PyArray_TYPE(ao) == NPY_INT64) { #if (__WORDSIZE == 32) - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); + return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0); #else - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); + return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0); #endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type"); From 4a95427f42d1bad66d57fa4f6acc71ea3427fc23 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 17:24:14 -0700 Subject: [PATCH 17/18] use __SIZEOF_LONG__ --- faiss/python/swigfaiss.swig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index a1a3624c14..73fdf2a7ca 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,14 +1022,14 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#if (__WORDSIZE == 32) +#if (__SIZEOF_LONG__ == 4) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#if (__WORDSIZE == 32) +#if (__SIZEOF_LONG__ == 4) return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0); #else return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0); From 6b1664769a5ee9d050dcb4112687f528f1c017c3 Mon Sep 17 00:00:00 2001 From: Junjie Qi Date: Thu, 28 Mar 2024 17:40:17 -0700 Subject: [PATCH 18/18] use __SIZEOF_LONG__ --- faiss/python/swigfaiss.swig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 73fdf2a7ca..0ea93609e3 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -1022,17 +1022,17 @@ PyObject *swig_ptr (PyObject *a) return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0); } if(PyArray_TYPE(ao) == NPY_UINT64) { -#if (__SIZEOF_LONG__ == 4) - return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); -#else +#if (__SIZEOF_LONG__ == 8) return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0); #endif } if(PyArray_TYPE(ao) == NPY_INT64) { -#if (__SIZEOF_LONG__ == 4) - return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0); -#else +#if (__SIZEOF_LONG__ == 8) return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0); +#else + return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0); #endif } PyErr_SetString(PyExc_ValueError, "did not recognize array type");