Skip to content

Commit

Permalink
Fix faiss swig build with version > 4.2.x
Browse files Browse the repository at this point in the history
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
  • Loading branch information
junjieqi committed Mar 26, 2024
1 parent a4b50e3 commit 1fcb3de
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions faiss/python/swigfaiss.swig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1fcb3de

Please sign in to comment.