13 #ifndef FAISS_PRODUCT_QUANTIZER_H
14 #define FAISS_PRODUCT_QUANTIZER_H
20 #include "Clustering.h"
65 void train (
int n,
const float *x);
67 ProductQuantizer(
size_t d,
80 void compute_code (
const float * x, uint8_t * code)
const ;
88 void decode (
const uint8_t *code,
float *x)
const;
89 void decode (
const uint8_t *code,
float *x,
size_t n)
const;
111 float * dis_table)
const;
113 void compute_inner_prod_table (
const float * x,
114 float * dis_table)
const;
124 float * dis_tables)
const;
126 void compute_inner_prod_tables (
size_t nx,
128 float * dis_tables)
const;
139 void search (
const float * x,
141 const uint8_t * codes,
143 float_maxheap_array_t *res,
144 bool init_finalize_heap =
true)
const;
149 const uint8_t * codes,
151 float_minheap_array_t *res,
152 bool init_finalize_heap =
true)
const;
159 void compute_sdc_table ();
161 void search_sdc (
const uint8_t * qcodes,
163 const uint8_t * bcodes,
166 bool init_finalize_heap =
true)
const;
void set_params(const float *centroids, int m)
Define the centroids for subquantizer m.
intialize centroids with nbits-D hypercube
size_t nbits
number of bits per quantization index
void decode(const uint8_t *code, float *x) const
decode a vector from a given code (or n vectors if third argument)
size_t byte_per_idx
nb bytes per code component (1 or 2)
intialize centroids with nbits-D hypercube
void set_derived_values()
compute derived values when d, M and nbits have been set
std::vector< float > sdc_table
Symmetric Distance Table.
share dictionary accross PQ segments
size_t dsub
dimensionality of each subvector
void compute_distance_tables(size_t nx, const float *x, float *dis_tables) const
void compute_code_from_distance_table(const float *tab, uint8_t *code) const
void compute_codes(const float *x, uint8_t *codes, size_t n) const
same as compute_code for several vectors
void compute_distance_table(const float *x, float *dis_table) const
void search(const float *x, size_t nx, const uint8_t *codes, const size_t ncodes, float_maxheap_array_t *res, bool init_finalize_heap=true) const
size_t code_size
byte per indexed vector
size_t ksub
number of centroids for each subquantizer
void search_ip(const float *x, size_t nx, const uint8_t *codes, const size_t ncodes, float_minheap_array_t *res, bool init_finalize_heap=true) const
void compute_code(const float *x, uint8_t *code) const
Quantize one vector with the product quantizer.
the centroids are already initialized
ClusteringParameters cp
parameters used during clustering
size_t M
number of subquantizers
float * get_centroids(size_t m, size_t i)
return the centroids associated with subvector m
size_t d
size of the input vectors
bool verbose
verbose during training?
std::vector< float > centroids
Centroid table, size M * ksub * dsub.
train_type_t
initialization