diff --git a/benchmark/algorithms/faiss_t3.py b/benchmark/algorithms/faiss_t3.py index 622e121b1..d2da945a7 100644 --- a/benchmark/algorithms/faiss_t3.py +++ b/benchmark/algorithms/faiss_t3.py @@ -9,7 +9,6 @@ import resource import threading import json - from multiprocessing.pool import ThreadPool from benchmark.algorithms.base import BaseANN @@ -187,6 +186,7 @@ def produce_batches(sno): print(" adding %d:%d / %d [%.3f s, RSS %d kiB] " % ( i0, i1, ds.nb, time.time() - t0, faiss.get_mem_usage_kb())) + xblock = xblock.astype('f4') index.add_core( len(xblock), faiss.swig_ptr(xblock), @@ -250,13 +250,7 @@ def search(self, x, k): t0 = time.time() for i0, xblock, Dc, Ic in stage2: ni = len(xblock) - self.index_ivf.search_preassigned( - ni, faiss.swig_ptr(xblock), - k, sp(Ic), sp(Dc), - sp(D[i0:]), sp(I[i0:]), - False - ) - + D[i0:i0+ni], I[i0:i0+ni] = self.index_ivf.search_preassigned(xblock, k, Ic, Dc) return D, I def range_search(self, x, radius): diff --git a/neurips21/track3_baseline_faiss/gpu_baseline_faiss.py b/neurips21/track3_baseline_faiss/gpu_baseline_faiss.py index a3fc2d1e8..4f4caa6ec 100644 --- a/neurips21/track3_baseline_faiss/gpu_baseline_faiss.py +++ b/neurips21/track3_baseline_faiss/gpu_baseline_faiss.py @@ -148,7 +148,6 @@ def build_index(args, ds): train_index = faiss.index_cpu_to_all_gpus( faiss.IndexFlatL2(index_ivf.d)) index_ivf.clustering_index = train_index - index.train(xt2) print(" Total train time %.3f s" % (time.time() - t0)) @@ -190,6 +189,9 @@ def produce_batches(sno): print(" adding %d:%d / %d [%.3f s, RSS %d kiB] " % ( i0, i1, ds.nb, time.time() - t0, faiss.get_mem_usage_kb())) + + xblock = xblock.astype('f4') + index.add_core( len(xblock), faiss.swig_ptr(xblock), @@ -236,7 +238,7 @@ def eval_setting_knn(index, xq, gt, k, inter, min_time): ms_per_query = ((t1 - t0) * 1000.0 / nq / nrun) if inter: rank = k - inter_measure = compute_inter(gt[:, :rank], I[:, :rank]) + inter_measure = compute_inter(gt_I[:, :rank], I[:, :rank]) print("%.4f" % inter_measure, end=' ') else: for rank in 1, 10, 100: @@ -316,12 +318,7 @@ def search(self, x, k): t0 = time.time() for i0, xblock, Dc, Ic in stage2: ni = len(xblock) - self.index_ivf.search_preassigned( - ni, faiss.swig_ptr(xblock), - k, sp(Ic), sp(Dc), - sp(D[i0:]), sp(I[i0:]), - False - ) + D[i0:i0+ni], I[i0:i0+ni] = self.index_ivf.search_preassigned(xblock, k, Ic, Dc) return D, I @@ -513,6 +510,7 @@ def aa(*args, **kwargs): nq, d = ds.nq, ds.d nb, d = ds.nq, ds.d + if args.prepare: print("downloading dataset...") ds.prepare() @@ -571,4 +569,4 @@ def aa(*args, **kwargs): run_experiments_searchparams(ds, index, args) if __name__ == "__main__": - main() \ No newline at end of file + main()