Skip to content

Commit 1fcb3de

Browse files
committed
Fix faiss swig build with version > 4.2.x
Summary: Currently, faiss can't build with swig version > 4.2.x. As the #3239 mentioned. Swig removed the support for 32bit swig/swig@9fb3a49. 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
1 parent a4b50e3 commit 1fcb3de

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

faiss/python/swigfaiss.swig

-8
Original file line numberDiff line numberDiff line change
@@ -1022,18 +1022,10 @@ PyObject *swig_ptr (PyObject *a)
10221022
return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0);
10231023
}
10241024
if(PyArray_TYPE(ao) == NPY_UINT64) {
1025-
#ifdef SWIGWORDSIZE64
10261025
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0);
1027-
#else
1028-
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0);
1029-
#endif
10301026
}
10311027
if(PyArray_TYPE(ao) == NPY_INT64) {
1032-
#ifdef SWIGWORDSIZE64
10331028
return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0);
1034-
#else
1035-
return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0);
1036-
#endif
10371029
}
10381030
PyErr_SetString(PyExc_ValueError, "did not recognize array type");
10391031
return NULL;

0 commit comments

Comments
 (0)