Debian Codegraph @

c_api/IndexScalarQuantizer_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_SCALAR_QUANTIZER_C_H
11 #define FAISS_INDEX_SCALAR_QUANTIZER_C_H
12
13 #include "Index_c.h"
14 #include "faiss_c.h"
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 typedef enum FaissQuantizerType {
21 QT_8bit, ///< 8 bits per component
22 QT_4bit, ///< 4 bits per component
23 QT_8bit_uniform, ///< same, shared range for all dimensions
24 QT_4bit_uniform,
25 QT_fp16,
26 QT_8bit_direct, ///< fast indexing of uint8s
27 QT_6bit, ///< 6 bits per component
28 QT_bf16,
29 QT_8bit_direct_signed, ///< fast indexing of signed int8s ranging from [-128
30 ///< to 127]
31 } FaissQuantizerType;
32
33 // forward declaration
34 typedef enum FaissMetricType FaissMetricType;
35
36 /** Opaque type for IndexScalarQuantizer */
37 FAISS_DECLARE_CLASS_INHERITED(IndexScalarQuantizer, Index)
38
39 int faiss_IndexScalarQuantizer_new(FaissIndexScalarQuantizer** p_index);
40
41 int faiss_IndexScalarQuantizer_new_with(
42 FaissIndexScalarQuantizer** p_index,
43 idx_t d,
44 FaissQuantizerType qt,
45 FaissMetricType metric);
46
47 FAISS_DECLARE_INDEX_DOWNCAST(IndexScalarQuantizer)
48
49 FAISS_DECLARE_DESTRUCTOR(IndexScalarQuantizer)
50
51 /** Opaque type for IndexIVFScalarQuantizer */
52 FAISS_DECLARE_CLASS_INHERITED(IndexIVFScalarQuantizer, Index)
53
54 FAISS_DECLARE_INDEX_DOWNCAST(IndexIVFScalarQuantizer)
55
56 FAISS_DECLARE_DESTRUCTOR(IndexIVFScalarQuantizer)
57
58 int faiss_IndexIVFScalarQuantizer_new(FaissIndexIVFScalarQuantizer** p_index);
59
60 int faiss_IndexIVFScalarQuantizer_new_with(
61 FaissIndexIVFScalarQuantizer** p_index,
62 FaissIndex* quantizer,
63 idx_t d,
64 size_t nlist,
65 FaissQuantizerType qt);
66
67 int faiss_IndexIVFScalarQuantizer_new_with_metric(
68 FaissIndexIVFScalarQuantizer** p_index,
69 FaissIndex* quantizer,
70 size_t d,
71 size_t nlist,
72 FaissQuantizerType qt,
73 FaissMetricType metric,
74 int encode_residual);
75
76 /// number of possible key values
77 FAISS_DECLARE_GETTER(IndexIVFScalarQuantizer, size_t, nlist)
78 /// number of probes at query time
79 FAISS_DECLARE_GETTER_SETTER(IndexIVFScalarQuantizer, size_t, nprobe)
80 /// quantizer that maps vectors to inverted lists
81 FAISS_DECLARE_GETTER(IndexIVFScalarQuantizer, FaissIndex*, quantizer)
82
83 /// whether object owns the quantizer
84 FAISS_DECLARE_GETTER_SETTER(IndexIVFScalarQuantizer, int, own_fields)
85
86 int faiss_IndexIVFScalarQuantizer_add_core(
87 FaissIndexIVFScalarQuantizer* index,
88 idx_t n,
89 const float* x,
90 const idx_t* xids,
91 const idx_t* precomputed_idx);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif