Debian Codegraph @

c_api/IndexIVFFlat_c.h

raw
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 // -*- c -*-
9
10 #ifndef FAISS_INDEX_IVF_FLAT_C_H
11 #define FAISS_INDEX_IVF_FLAT_C_H
12
13 #include "Clustering_c.h"
14 #include "Index_c.h"
15 #include "faiss_c.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /** Inverted file with stored vectors. Here the inverted file
22 * pre-selects the vectors to be searched, but they are not otherwise
23 * encoded, the code array just contains the raw float entries.
24 */
25 FAISS_DECLARE_CLASS_INHERITED(IndexIVFFlat, Index)
26 FAISS_DECLARE_DESTRUCTOR(IndexIVFFlat)
27 FAISS_DECLARE_INDEX_DOWNCAST(IndexIVFFlat)
28
29 /// number of possible key values
30 FAISS_DECLARE_GETTER(IndexIVFFlat, size_t, nlist)
31 /// number of probes at query time
32 FAISS_DECLARE_GETTER_SETTER(IndexIVFFlat, size_t, nprobe)
33 /// quantizer that maps vectors to inverted lists
34 FAISS_DECLARE_GETTER(IndexIVFFlat, FaissIndex*, quantizer)
35 /**
36 * = 0: use the quantizer as index in a kmeans training
37 * = 1: just pass on the training set to the train() of the quantizer
38 * = 2: kmeans training on a flat index + add the centroids to the quantizer
39 */
40 FAISS_DECLARE_GETTER(IndexIVFFlat, char, quantizer_trains_alone)
41
42 /// whether object owns the quantizer
43 FAISS_DECLARE_GETTER_SETTER(IndexIVFFlat, int, own_fields)
44
45 int faiss_IndexIVFFlat_new(FaissIndexIVFFlat** p_index);
46
47 int faiss_IndexIVFFlat_new_with(
48 FaissIndexIVFFlat** p_index,
49 FaissIndex* quantizer,
50 size_t d,
51 size_t nlist);
52
53 int faiss_IndexIVFFlat_new_with_metric(
54 FaissIndexIVFFlat** p_index,
55 FaissIndex* quantizer,
56 size_t d,
57 size_t nlist,
58 FaissMetricType metric);
59
60 int faiss_IndexIVFFlat_add_core(
61 FaissIndexIVFFlat* index,
62 idx_t n,
63 const float* x,
64 const idx_t* xids,
65 const int64_t* precomputed_idx);
66
67 /** Update a subset of vectors.
68 *
69 * The index must have a direct_map
70 *
71 * @param nv nb of vectors to update
72 * @param idx vector indices to update, size nv
73 * @param v vectors of new values, size nv*d
74 */
75 int faiss_IndexIVFFlat_update_vectors(
76 FaissIndexIVFFlat* index,
77 int nv,
78 idx_t* idx,
79 const float* v);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif