Add missing downcast (#1330)

Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1330

add missing downcast for Index (and test for github sync)

See github issue https://github.com/facebookresearch/faiss/issues/1278

Reviewed By: beauby

Differential Revision: D23053182

fbshipit-source-id: 1ce4c248342332ce632ecfd5074affa3ddf55b66
pull/1315/head
Matthijs Douze 2020-08-13 16:36:53 -07:00 committed by Facebook GitHub Bot
parent 569c855ed0
commit 4c3b5ad156
2 changed files with 13 additions and 0 deletions

View File

@ -579,6 +579,7 @@ struct AsyncIndexSearchC {
DOWNCAST ( IndexIVFFlat )
DOWNCAST ( IndexIVF )
DOWNCAST ( IndexFlat )
DOWNCAST ( IndexRefineFlat )
DOWNCAST ( IndexPQ )
DOWNCAST ( IndexScalarQuantizer )
DOWNCAST ( IndexLSH )

View File

@ -615,6 +615,18 @@ class TestSWIGWrap(unittest.TestCase):
[index.id_map.at(int(i)) for i in range(index.ntotal)]
def test_downcast_Refine(self):
index = faiss.IndexRefineFlat(
faiss.IndexScalarQuantizer(10, faiss.ScalarQuantizer.QT_8bit)
)
# serialize and deserialize
index2 = faiss.deserialize_index(
faiss.serialize_index(index)
)
assert isinstance(index2, faiss.IndexRefineFlat)
if __name__ == '__main__':
unittest.main()