@@ -28,11 +28,43 @@ typedef enum FaissQuantizerType {
2828 QT_bf16 ,
2929 QT_8bit_direct_signed , ///< fast indexing of signed int8s ranging from [-128
3030 ///< to 127]
31+ QT_0bit , ///< 0 bits per component, centroid-only distance (IVF only; a
32+ ///< flat index with QT_0bit stores nothing)
33+ QT_1bit_tqmse , ///< TurboQuant MSE-optimized, 1 bit per component
34+ QT_2bit_tqmse , ///< TurboQuant MSE-optimized, 2 bits per component
35+ QT_3bit_tqmse , ///< TurboQuant MSE-optimized, 3 bits per component
36+ QT_4bit_tqmse , ///< TurboQuant MSE-optimized, 4 bits per component
37+ QT_8bit_tqmse , ///< TurboQuant MSE-optimized, 8 bits per component
38+ QT_2bit_tq , ///< Full TurboQuant (1-bit MSE + 1-bit QJL + factors)
39+ QT_3bit_tq , ///< Full TurboQuant (2-bit MSE + 1-bit QJL + factors)
40+ QT_4bit_tq , ///< Full TurboQuant (3-bit MSE + 1-bit QJL + factors)
41+ QT_5bit_tq , ///< Full TurboQuant (4-bit MSE + 1-bit QJL + factors)
42+ QT_1bit_eden , ///< EDEN Lloyd-Max scalar code, 1 bit per component
43+ QT_2bit_eden , ///< EDEN Lloyd-Max scalar code, 2 bits per component
44+ QT_3bit_eden , ///< EDEN Lloyd-Max scalar code, 3 bits per component
45+ QT_4bit_eden , ///< EDEN Lloyd-Max scalar code, 4 bits per component
46+ QT_5bit_eden , ///< EDEN Lloyd-Max scalar code, 5 bits per component
47+ QT_6bit_eden , ///< EDEN Lloyd-Max scalar code, 6 bits per component
48+ QT_7bit_eden , ///< EDEN Lloyd-Max scalar code, 7 bits per component
49+ QT_8bit_eden , ///< EDEN Lloyd-Max scalar code, 8 bits per component
50+ QT_count
3151} FaissQuantizerType ;
3252
53+ typedef enum FaissRangeStat {
54+ RS_minmax , ///< [min - rs*(max-min), max + rs*(max-min)]
55+ RS_meanstd , ///< [mean - std * rs, mean + std * rs]
56+ RS_quantiles , ///< [Q(rs), Q(1-rs)]
57+ RS_optim , ///< alternate optimization of reconstruction error
58+ } FaissRangeStat ;
59+
3360// forward declaration
3461typedef enum FaissMetricType FaissMetricType ;
3562
63+ /** Opaque type for the ScalarQuantizer codec owned by an index.
64+ * Valid only while the owning index is alive and must not be freed.
65+ */
66+ FAISS_DECLARE_CLASS (ScalarQuantizer )
67+
3668/** Opaque type for IndexScalarQuantizer */
3769FAISS_DECLARE_CLASS_INHERITED (IndexScalarQuantizer , Index )
3870
@@ -90,6 +122,39 @@ int faiss_IndexIVFScalarQuantizer_add_core(
90122 const idx_t * xids ,
91123 const idx_t * precomputed_idx );
92124
125+ /** Access the scalar quantizer codec of an IndexScalarQuantizer.
126+ * Borrowed reference, owned by the index; do not free.
127+ */
128+ FaissScalarQuantizer * faiss_IndexScalarQuantizer_sq (
129+ FaissIndexScalarQuantizer * index );
130+
131+ /** Access the scalar quantizer codec of an IndexIVFScalarQuantizer.
132+ * Borrowed reference, owned by the index; do not free.
133+ */
134+ FaissScalarQuantizer * faiss_IndexIVFScalarQuantizer_sq (
135+ FaissIndexIVFScalarQuantizer * index );
136+
137+ /// quantizer type of this codec
138+ FAISS_DECLARE_GETTER (ScalarQuantizer , FaissQuantizerType , qtype )
139+ /// bits per scalar code
140+ FAISS_DECLARE_GETTER (ScalarQuantizer , size_t , bits )
141+ /// size of the input vectors
142+ FAISS_DECLARE_GETTER (ScalarQuantizer , size_t , d )
143+ /// bytes per encoded vector
144+ FAISS_DECLARE_GETTER (ScalarQuantizer , size_t , code_size )
145+ /// range estimation strategy (uniform encoder)
146+ FAISS_DECLARE_GETTER_SETTER (ScalarQuantizer , FaissRangeStat , rangestat )
147+ /// argument to the range estimation strategy (rs)
148+ FAISS_DECLARE_GETTER_SETTER (ScalarQuantizer , float , rangestat_arg )
149+
150+ /// Number of trained values
151+ size_t faiss_ScalarQuantizer_trained_size (const FaissScalarQuantizer * sq );
152+
153+ /** Copy the trained values into out, which must hold at least
154+ * faiss_ScalarQuantizer_trained_size() floats.
155+ */
156+ void faiss_ScalarQuantizer_trained (const FaissScalarQuantizer * sq , float * out );
157+
93158#ifdef __cplusplus
94159}
95160#endif
0 commit comments