Skip to content

Commit

Permalink
selector parameter for FastScan (#3362)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3362

Add test to Alex' PR

Reviewed By: junjieqi

Differential Revision: D56003946

fbshipit-source-id: 5a8a881d450bc97ae0777d73ce0ce8607ec6b686
  • Loading branch information
mdouze authored and facebook-github-bot committed Apr 11, 2024
1 parent 17fbeb8 commit 40e8643
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_search_params.py
Expand Up @@ -22,15 +22,14 @@ class TestSelector(unittest.TestCase):
combinations as possible.
"""

def do_test_id_selector(self, index_key, id_selector_type="batch", mt=faiss.METRIC_L2):
def do_test_id_selector(self, index_key, id_selector_type="batch", mt=faiss.METRIC_L2, k=10):
""" Verify that the id selector returns the subset of results that are
members according to the IDSelector.
Supports id_selector_type="batch", "bitmap", "range", "range_sorted", "and", "or", "xor"
"""
ds = datasets.SyntheticDataset(32, 1000, 100, 20)
index = faiss.index_factory(ds.d, index_key, mt)
index.train(ds.get_train())
k = 10

# reference result
if "range" in id_selector_type:
Expand Down Expand Up @@ -145,6 +144,16 @@ def test_IVFFlat_range_sorted(self):
def test_IVFPQ(self):
self.do_test_id_selector("IVF32,PQ4x4np")

def test_IVFPQfs(self):
self.do_test_id_selector("IVF32,PQ4x4fs")

def test_IVFPQfs_k1(self):
self.do_test_id_selector("IVF32,PQ4x4fs", k=1)

def test_IVFPQfs_k40(self):
# test reservoir codepath
self.do_test_id_selector("IVF32,PQ4x4fs", k=40)

def test_IVFSQ(self):
self.do_test_id_selector("IVF32,SQ8")

Expand Down

0 comments on commit 40e8643

Please sign in to comment.