Skip to content

Commit 00ce0e2

Browse files
navneet1vfacebook-github-bot
authored andcommitted
Add the support for IndexIDMap with Cagra index (#4188)
Summary: ## Description Add the support for adding vectors with ids when IndexIDMap is used with Cagra Index. Resolves issue: #4107 Pull Request resolved: #4188 Reviewed By: mnorris11 Differential Revision: D69812544 Pulled By: gtwang01 fbshipit-source-id: 3c12c930e5d10ce214b12e68dacd63a644011b79
1 parent 1fe8b8b commit 00ce0e2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

faiss/gpu/GpuIndexCagra.cu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ void GpuIndexCagra::train(idx_t n, const float* x) {
103103
this->ntotal = n;
104104
}
105105

106+
void GpuIndexCagra::add(idx_t n, const float* x) {
107+
train(n, x);
108+
}
109+
106110
bool GpuIndexCagra::addImplRequiresIDs_() const {
107111
return false;
108112
};

faiss/gpu/GpuIndexCagra.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ struct GpuIndexCagra : public GpuIndex {
245245
faiss::MetricType metric = faiss::METRIC_L2,
246246
GpuIndexCagraConfig config = GpuIndexCagraConfig());
247247

248+
/// Trains CAGRA based on the given vector data and add them along with ids.
249+
/// NB: The use of the add function here is to build the CAGRA graph on
250+
/// the base dataset. Use this function when you want to add vectors with
251+
/// ids. Ref: https://github.com/facebookresearch/faiss/issues/4107
252+
void add(idx_t n, const float* x) override;
253+
248254
/// Trains CAGRA based on the given vector data.
249255
/// NB: The use of the train function here is to build the CAGRA graph on
250256
/// the base dataset and is currently the only function to add the full set

0 commit comments

Comments
 (0)