From 6f2942fd2aeab6b3fa39b5f663c5efc8ba14ada3 Mon Sep 17 00:00:00 2001 From: DJ <44884520+Tickdack@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:07:30 +0800 Subject: [PATCH 1/5] Update IndexRefine.h add remove for refine --- faiss/IndexRefine.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/faiss/IndexRefine.h b/faiss/IndexRefine.h index 9ad4e4be29..ce6b34f284 100644 --- a/faiss/IndexRefine.h +++ b/faiss/IndexRefine.h @@ -44,6 +44,8 @@ struct IndexRefine : Index { void add(idx_t n, const float* x) override; + size_t remove_ids(const IDSelector& sel) override; + void reset() override; void search( From 9350e67992ac8db23029709bab3a9cb83cee062f Mon Sep 17 00:00:00 2001 From: DJ <44884520+Tickdack@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:09:22 +0800 Subject: [PATCH 2/5] Update IndexRefine.cpp --- faiss/IndexRefine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/faiss/IndexRefine.cpp b/faiss/IndexRefine.cpp index 01dd97a08b..6df1cf924e 100644 --- a/faiss/IndexRefine.cpp +++ b/faiss/IndexRefine.cpp @@ -54,6 +54,14 @@ void IndexRefine::add(idx_t n, const float* x) { ntotal = refine_index->ntotal; } +size_t IndexRefine::remove_ids(const IDSelector& sel) { + FAISS_THROW_IF_NOT(is_trained); + base_index->remove_ids(sel); + refine_index->remove_ids(sel); + ntotal = refine_index->ntotal; + return -1; +} + void IndexRefine::reset() { base_index->reset(); refine_index->reset(); From 6273833651369cbfe0f9f7dc0d7f934e6998edaa Mon Sep 17 00:00:00 2001 From: DJ <44884520+Tickdack@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:58:01 +0800 Subject: [PATCH 3/5] Update IndexRefine.cpp --- faiss/IndexRefine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faiss/IndexRefine.cpp b/faiss/IndexRefine.cpp index 6df1cf924e..81b2d66cd0 100644 --- a/faiss/IndexRefine.cpp +++ b/faiss/IndexRefine.cpp @@ -59,7 +59,7 @@ size_t IndexRefine::remove_ids(const IDSelector& sel) { base_index->remove_ids(sel); refine_index->remove_ids(sel); ntotal = refine_index->ntotal; - return -1; + return ntotal; } void IndexRefine::reset() { From 0ad39b8d546e7af79d6f8d625d9056a29ad221e2 Mon Sep 17 00:00:00 2001 From: DJ <44884520+Tickdack@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:40:07 +0800 Subject: [PATCH 4/5] Update faiss/IndexRefine.cpp Co-authored-by: gtwang01 <110636181+gtwang01@users.noreply.github.com> --- faiss/IndexRefine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/faiss/IndexRefine.cpp b/faiss/IndexRefine.cpp index 81b2d66cd0..c16abde4f7 100644 --- a/faiss/IndexRefine.cpp +++ b/faiss/IndexRefine.cpp @@ -59,7 +59,11 @@ size_t IndexRefine::remove_ids(const IDSelector& sel) { base_index->remove_ids(sel); refine_index->remove_ids(sel); ntotal = refine_index->ntotal; - return ntotal; + ntotal_before = refine_index->ntotal + base_index->remove_ids(sel); + refine_index->remove_ids(sel); + ntotal_after = refine_index->ntotal; + return ntotal_after - ntotal_before; } void IndexRefine::reset() { From 6905966486510cf1a7837ded94963ed8dd664f18 Mon Sep 17 00:00:00 2001 From: DJ <44884520+Tickdack@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:41:56 +0800 Subject: [PATCH 5/5] Update IndexRefine.cpp --- faiss/IndexRefine.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/faiss/IndexRefine.cpp b/faiss/IndexRefine.cpp index c16abde4f7..c30e0d7dec 100644 --- a/faiss/IndexRefine.cpp +++ b/faiss/IndexRefine.cpp @@ -57,13 +57,8 @@ void IndexRefine::add(idx_t n, const float* x) { size_t IndexRefine::remove_ids(const IDSelector& sel) { FAISS_THROW_IF_NOT(is_trained); base_index->remove_ids(sel); - refine_index->remove_ids(sel); - ntotal = refine_index->ntotal; - ntotal_before = refine_index->ntotal - base_index->remove_ids(sel); - refine_index->remove_ids(sel); - ntotal_after = refine_index->ntotal; - return ntotal_after - ntotal_before; + size_t nremove = refine_index->remove_ids(sel); + return nremove; } void IndexRefine::reset() {