Skip to content

Commit

Permalink
Test sa_decode methd on IndexIVFFlat (#4098)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #4098

Increase test coverage: Test sa_decode methd on IndexIVFFlat

Reviewed By: mnorris11

Differential Revision: D67345048

fbshipit-source-id: 533e090a690ffc855091a4f95642446f93b93a3f
  • Loading branch information
satymish authored and facebook-github-bot committed Dec 17, 2024
1 parent db3409a commit 3ff8a24
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_ivf_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,20 @@ TEST(IVF, list_context) {
EXPECT_EQ(nb, context.list_nos.size())
<< "should have correct number of list numbers";
}
{
constexpr size_t num_vecs = 5; // number of vectors
std::vector<float> vecs(num_vecs * d);
for (size_t i = 0; i < num_vecs * d; i++) {
vecs[i] = distrib(rng);
}
const size_t codeSize = index.sa_code_size();
std::vector<uint8_t> encodedData(num_vecs * codeSize);
index.sa_encode(num_vecs, vecs.data(), encodedData.data());
std::vector<float> decodedVecs(num_vecs * d);
index.sa_decode(num_vecs, encodedData.data(), decodedVecs.data());
EXPECT_EQ(vecs, decodedVecs)
<< "decoded vectors should be the same as the original vectors that were encoded";
}
{
constexpr faiss::idx_t k = 100;
constexpr size_t nprobe = 10;
Expand Down

0 comments on commit 3ff8a24

Please sign in to comment.