Skip to content

Merge pull request #7 from maronuu/section/multi-threading #36

Merge pull request #7 from maronuu/section/multi-threading

Merge pull request #7 from maronuu/section/multi-threading #36

name: Build from source
on: [push]
jobs:
Build-from-source:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: |
bash build.sh
- name: Test
run: |
### We need to run export again if we move to the different step ###
export PATH="$HOME/miniconda/bin:$PATH"
export PYTHONPATH=$HOME/faiss/build/faiss/python/build/lib:$PYTHONPATH
cd $HOME/faiss
echo "##### Check ldd of .so #####"
ldd build/faiss/libfaiss_avx2.so
echo "##### Run c++ test #####"
make -C build -j demo_ivfpq_indexing
./build/demos/demo_ivfpq_indexing
echo "##### Run python test #####"
cd
python -c "import faiss, numpy; err = faiss.Kmeans(10, 20).train(numpy.random.rand(1000, 10).astype('float32')); print(err)"
echo "##### Check AVX2 is working or not #####"
LD_DEBUG=libs python -c "import faiss" 2>&1 | grep libfaiss_avx2.so
echo "import faiss
import numpy as np
import time
np.random.seed(234)
D = 128
N = 10000
X = np.random.random((N, D)).astype(np.float32)
M = 64
nbits = 4
pq = faiss.IndexPQ(D, M, nbits)
pq.train(X)
pq.add(X)
pq_fast = faiss.IndexPQFastScan(D, M, nbits)
pq_fast.train(X)
pq_fast.add(X)
t0 = time.time()
d1, ids1 = pq.search(x=X[:3], k=5)
t1 = time.time()
print(f'pq: {(t1 - t0) * 1000} msec')
t0 = time.time()
d2, ids2 = pq_fast.search(x=X[:3], k=5)
t1 = time.time()
print(f'pq_fast: {(t1 - t0) * 1000} msec')
assert np.allclose(ids1, ids2)
" > check.py
python check.py