10 #ifndef FAISS_INDEX_SCALAR_QUANTIZER_H
11 #define FAISS_INDEX_SCALAR_QUANTIZER_H
30 struct SQDistanceComputer;
73 void train (
size_t n,
const float *x);
82 void decode (
const uint8_t *code,
float *x,
size_t n)
const;
115 void add(
idx_t n,
const float* x)
override;
122 idx_t* labels)
const override;
124 void reset()
override;
154 const idx_t *list_nos,
155 uint8_t * codes)
const override;
164 float* recons)
const override;
void encode_vectors(idx_t n, const float *x, const idx_t *list_nos, uint8_t *codes) const override
size_t code_size
bytes per vector
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
void train_residual(idx_t n, const float *x) override
alternate optimization of reconstruction error
same, shared range for all dimensions
void reconstruct_from_offset(long list_no, long offset, float *recons) const override
void add(idx_t n, const float *x) override
void reset() override
removes all elements from the database.
void add_with_ids(idx_t n, const float *x, const long *xids) override
default implementation that calls encode_vectors
long idx_t
all indices are this type
std::vector< uint8_t > codes
Codes. Size ntotal * pq.code_size.
ScalarQuantizer sq
Used to encode the vectors.
[mean - std * rs, mean + std * rs]
void decode(const uint8_t *code, float *x, size_t n) const
decode a vector from a given code (or n vectors if third argument)
InvertedListScanner * get_InvertedListScanner(bool store_pairs) const override
get a scanner for this index (store_pairs means ignore labels)
void compute_codes(const float *x, uint8_t *codes, size_t n) const
same as compute_code for several vectors
void reconstruct_n(idx_t i0, idx_t ni, float *recons) const override
void reconstruct(idx_t key, float *recons) const override
[min - rs*(max-min), max + rs*(max-min)]
std::vector< float > trained
trained values (including the range)
Index * quantizer
quantizer that maps vectors to inverted lists
void train(idx_t n, const float *x) override
size_t d
dimension of input vectors
size_t nlist
number of possible key values
MetricType
Some algorithms support both an inner product version and a L2 search version.