-
Notifications
You must be signed in to change notification settings - Fork 46
70 lines (53 loc) · 1.77 KB
/
build_from_source.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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