Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faiss/IndexBinaryIVF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void IndexBinaryIVF::reconstruct_n(idx_t i0, idx_t ni, uint8_t* recons) const {
continue;
}

uint8_t* reconstructed = recons + (id - i0) * d;
uint8_t* reconstructed = recons + (id - i0) * code_size;
reconstruct_from_offset(list_no, offset, reconstructed);
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_index_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ def test_ivf_reconstruction(self):
self.xb[i]
)

def test_ivf_reconstruct_n_compact_output(self):
d = 64
code_size = d // 8
xb = np.arange(3 * code_size, dtype="uint8").reshape(3, code_size)

quantizer = faiss.IndexBinaryFlat(d)
quantizer.add(np.zeros((1, code_size), dtype="uint8"))

index = faiss.IndexBinaryIVF(quantizer, d, 1)
index.is_trained = True
index.add(xb)

np.testing.assert_array_equal(index.reconstruct_n(0, 3), xb)

def test_ivf_nprobe(self):
"""Test in case of nprobe > nlist."""
d = self.xq.shape[1] * 8
Expand Down