Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
GpuIndexIVFPQ.cu
1
2 /**
3 * Copyright (c) 2015-present, Facebook, Inc.
4 * All rights reserved.
5 *
6 * This source code is licensed under the CC-by-NC license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10 // Copyright 2004-present Facebook. All Rights Reserved.
11
12 #include "GpuIndexIVFPQ.h"
13 #include "../ProductQuantizer.h"
14 #include "GpuIndexFlat.h"
15 #include "GpuResources.h"
16 #include "impl/IVFPQ.cuh"
17 #include "utils/CopyUtils.cuh"
18 #include "utils/DeviceUtils.h"
19 #include "../IndexFlat.h"
20 #include "../IndexIVFPQ.h"
21
22 #include <limits>
23
24 namespace faiss { namespace gpu {
25
26 GpuIndexIVFPQ::GpuIndexIVFPQ(GpuResources* resources,
27 int device,
28 IndicesOptions indicesOptions,
29 bool useFloat16LookupTables,
30 const faiss::IndexIVFPQ* index) :
31 GpuIndexIVF(resources,
32 device,
33 indicesOptions,
34 false, // FIXME: float 16 coarse quantizer
35 index->d,
36 index->metric_type,
37 index->nlist),
38 useFloat16LookupTables_(useFloat16LookupTables),
39 subQuantizers_(0),
40 bitsPerCode_(0),
41 usePrecomputed_(false),
42 reserveMemoryVecs_(0),
43 index_(nullptr) {
44 #ifndef FAISS_USE_FLOAT16
45 FAISS_ASSERT(!useFloat16LookupTables_);
46 #endif
47
48 copyFrom(index);
49 }
50
51 GpuIndexIVFPQ::GpuIndexIVFPQ(GpuResources* resources,
52 int device,
53 int dims,
54 int nlist,
55 int subQuantizers,
56 int bitsPerCode,
57 bool usePrecomputed,
58 IndicesOptions indicesOptions,
59 bool useFloat16LookupTables,
60 faiss::MetricType metric) :
61 GpuIndexIVF(resources,
62 device,
63 indicesOptions,
64 false, // FIXME: float 16 coarse quantizer
65 dims,
66 metric,
67 nlist),
68 useFloat16LookupTables_(useFloat16LookupTables),
69 subQuantizers_(subQuantizers),
70 bitsPerCode_(bitsPerCode),
71 usePrecomputed_(usePrecomputed),
72 reserveMemoryVecs_(0),
73 index_(nullptr) {
74 #ifndef FAISS_USE_FLOAT16
75 FAISS_ASSERT(!useFloat16LookupTables_);
76 #endif
77
78 assertSettings_();
79
80 // FIXME make IP work fully
81 FAISS_ASSERT(this->metric_type == faiss::METRIC_L2);
82
83 // We haven't trained ourselves, so don't construct the PQ index yet
84 this->is_trained = false;
85 }
86
87 GpuIndexIVFPQ::~GpuIndexIVFPQ() {
88 delete index_;
89 }
90
91 void
92 GpuIndexIVFPQ::copyFrom(const faiss::IndexIVFPQ* index) {
93 DeviceScope scope(device_);
94
95 // FIXME: support this
96 FAISS_ASSERT(index->metric_type == faiss::METRIC_L2);
97 GpuIndexIVF::copyFrom(index);
98
99 // Clear out our old data
100 delete index_;
101 index_ = nullptr;
102
103 subQuantizers_ = index->pq.M;
104 bitsPerCode_ = index->pq.nbits;
105
106 // We only support this
107 FAISS_ASSERT(index->pq.byte_per_idx == 1);
108 FAISS_ASSERT(index->by_residual);
109 FAISS_ASSERT(index->polysemous_ht == 0);
110 usePrecomputed_ = index->use_precomputed_table;
111
112 assertSettings_();
113
114 // The other index might not be trained
115 if (!index->is_trained) {
116 return;
117 }
118
119 // Otherwise, we can populate ourselves from the other index
120 this->is_trained = true;
121
122 // Copy our lists as well
123 // The product quantizer must have data in it
124 FAISS_ASSERT(index->pq.centroids.size() > 0);
125 index_ = new IVFPQ(resources_,
126 quantizer_->getGpuData(),
127 subQuantizers_,
128 bitsPerCode_,
129 (float*) index->pq.centroids.data(),
130 indicesOptions_,
131 useFloat16LookupTables_);
132 // Doesn't make sense to reserve memory here
133 index_->setPrecomputedCodes(usePrecomputed_);
134
135 // Copy database vectors, if any
136 for (size_t i = 0; i < index->codes.size(); ++i) {
137 auto& codes = index->codes[i];
138 auto& indices = index->ids[i];
139
140 FAISS_ASSERT(indices.size() * subQuantizers_ == codes.size());
141 index_->addCodeVectorsFromCpu(i,
142 codes.data(),
143 indices.data(),
144 indices.size());
145 }
146 }
147
148 void
149 GpuIndexIVFPQ::copyTo(faiss::IndexIVFPQ* index) const {
150 DeviceScope scope(device_);
151
152 // We must have the indices in order to copy to ourselves
153 FAISS_ASSERT(indicesOptions_ != INDICES_IVF);
154
155 GpuIndexIVF::copyTo(index);
156
157 //
158 // IndexIVFPQ information
159 //
160 index->by_residual = true;
161 index->use_precomputed_table = 0;
162 index->code_size = subQuantizers_;
163 index->pq = faiss::ProductQuantizer(this->d, subQuantizers_, bitsPerCode_);
164
165 index->do_polysemous_training = false;
166 index->polysemous_training = nullptr;
167
168 index->scan_table_threshold = 0;
169 index->max_codes = 0;
170 index->polysemous_ht = 0;
171 index->codes.clear();
172 index->codes.resize(nlist_);
173 index->precomputed_table.clear();
174
175 if (index_) {
176 // Copy the inverted lists
177 for (int i = 0; i < nlist_; ++i) {
178 index->ids[i] = getListIndices(i);
179 index->codes[i] = getListCodes(i);
180 }
181
182 // Copy PQ centroids
183 auto devPQCentroids = index_->getPQCentroids();
184 index->pq.centroids.resize(devPQCentroids.numElements());
185
186 fromDevice<float, 3>(devPQCentroids,
187 index->pq.centroids.data(),
188 resources_->getDefaultStream(device_));
189
190 if (usePrecomputed_) {
191 index->precompute_table();
192 }
193 }
194 }
195
196 void
197 GpuIndexIVFPQ::reserveMemory(size_t numVecs) {
198 reserveMemoryVecs_ = numVecs;
199 if (index_) {
200 DeviceScope scope(device_);
201 index_->reserveMemory(numVecs);
202 }
203 }
204
205 void
206 GpuIndexIVFPQ::setPrecomputedCodes(bool enable) {
207 usePrecomputed_ = enable;
208 if (index_) {
209 DeviceScope scope(device_);
210 index_->setPrecomputedCodes(enable);
211 }
212
213 assertSettings_();
214 }
215
216 bool
217 GpuIndexIVFPQ::getPrecomputedCodes() const {
218 return usePrecomputed_;
219 }
220
221 bool
222 GpuIndexIVFPQ::getFloat16LookupTables() const {
223 return useFloat16LookupTables_;
224 }
225
226 int
227 GpuIndexIVFPQ::getNumSubQuantizers() const {
228 return subQuantizers_;
229 }
230
231 int
232 GpuIndexIVFPQ::getBitsPerCode() const {
233 return bitsPerCode_;
234 }
235
236 int
237 GpuIndexIVFPQ::getCentroidsPerSubQuantizer() const {
238 return utils::pow2(bitsPerCode_);
239 }
240
241 size_t
242 GpuIndexIVFPQ::reclaimMemory() {
243 if (index_) {
244 DeviceScope scope(device_);
245 return index_->reclaimMemory();
246 }
247
248 return 0;
249 }
250
251 void
252 GpuIndexIVFPQ::reset() {
253 if (index_) {
254 DeviceScope scope(device_);
255
256 index_->reset();
257 this->ntotal = 0;
258 } else {
259 FAISS_ASSERT(this->ntotal == 0);
260 }
261 }
262
263 void
264 GpuIndexIVFPQ::trainResidualQuantizer_(Index::idx_t n, const float* x) {
265 // Code largely copied from faiss::IndexIVFPQ
266 // FIXME: GPUize more of this
267 n = std::min(n, (Index::idx_t) (1 << bitsPerCode_) * 64);
268
269 if (this->verbose) {
270 printf("computing residuals\n");
271 }
272
273 std::vector<Index::idx_t> assign(n);
274 quantizer_->assign (n, x, assign.data());
275
276 std::vector<float> residuals(n * d);
277
278 for (idx_t i = 0; i < n; i++) {
279 quantizer_->compute_residual(x + i * d, &residuals[i * d], assign[i]);
280 }
281
282 if (this->verbose) {
283 printf("training %d x %d product quantizer on %ld vectors in %dD\n",
284 subQuantizers_, getCentroidsPerSubQuantizer(), n, this->d);
285 }
286
287 // Just use the CPU product quantizer to determine sub-centroids
288 faiss::ProductQuantizer pq(this->d, subQuantizers_, bitsPerCode_);
289 pq.verbose = this->verbose;
290 pq.train(n, residuals.data());
291
292 index_ = new IVFPQ(resources_,
293 quantizer_->getGpuData(),
294 subQuantizers_,
295 bitsPerCode_,
296 pq.centroids.data(),
297 indicesOptions_,
298 useFloat16LookupTables_);
299 if (reserveMemoryVecs_) {
300 index_->reserveMemory(reserveMemoryVecs_);
301 }
302
303 index_->setPrecomputedCodes(usePrecomputed_);
304 }
305
306 void
307 GpuIndexIVFPQ::train(Index::idx_t n, const float* x) {
308 DeviceScope scope(device_);
309
310 if (this->is_trained) {
311 FAISS_ASSERT(quantizer_->is_trained);
312 FAISS_ASSERT(quantizer_->ntotal == nlist_);
313 FAISS_ASSERT(index_);
314 return;
315 }
316
317 FAISS_ASSERT(!index_);
318
319 trainQuantizer_(n, x);
320 trainResidualQuantizer_(n, x);
321
322 this->is_trained = true;
323 }
324
325 void
326 GpuIndexIVFPQ::addImpl_(Index::idx_t n,
327 const float* x,
328 const Index::idx_t* xids) {
329 // Device is already set in GpuIndex::addInternal_
330
331 FAISS_ASSERT(index_);
332 FAISS_ASSERT(n > 0);
333
334 auto stream = resources_->getDefaultStreamCurrentDevice();
335
336 auto deviceVecs =
337 toDevice<float, 2>(resources_,
338 device_,
339 const_cast<float*>(x),
340 stream,
341 {(int) n, index_->getDim()});
342
343 auto deviceIndices =
344 toDevice<Index::idx_t, 1>(resources_,
345 device_,
346 const_cast<Index::idx_t*>(xids),
347 stream,
348 {(int) n});
349
350 // Not all vectors may be able to be added (some may contain NaNs
351 // etc)
352 ntotal += index_->classifyAndAddVectors(deviceVecs, deviceIndices);
353 }
354
355 void
356 GpuIndexIVFPQ::searchImpl_(faiss::Index::idx_t n,
357 const float* x,
358 faiss::Index::idx_t k,
359 float* distances,
360 faiss::Index::idx_t* labels) const {
361 // Device is already set in GpuIndex::search
362
363 FAISS_ASSERT(index_);
364 FAISS_ASSERT(n > 0);
365
366 // Make sure arguments are on the device we desire; use temporary
367 // memory allocations to move it if necessary
368 auto devX =
369 toDevice<float, 2>(resources_,
370 device_,
371 const_cast<float*>(x),
372 resources_->getDefaultStream(device_),
373 {(int) n, index_->getDim()});
374 auto devDistances =
375 toDevice<float, 2>(resources_,
376 device_,
377 distances,
378 resources_->getDefaultStream(device_),
379 {(int) n, (int) k});
380 auto devLabels =
381 toDevice<faiss::Index::idx_t, 2>(resources_,
382 device_,
383 labels,
384 resources_->getDefaultStream(device_),
385 {(int) n, (int) k});
386
387 index_->query(devX,
388 nprobe_,
389 (int) k,
390 devDistances,
391 devLabels);
392
393 // Copy back if necessary
394 fromDevice<float, 2>(
395 devDistances, distances, resources_->getDefaultStream(device_));
396 fromDevice<faiss::Index::idx_t, 2>(
397 devLabels, labels, resources_->getDefaultStream(device_));
398 }
399
400 void
401 GpuIndexIVFPQ::set_typename() {
402 // FIXME: implement
403 FAISS_ASSERT(false);
404 }
405
406 int
407 GpuIndexIVFPQ::getListLength(int listId) const {
408 FAISS_ASSERT(index_);
409 return index_->getListLength(listId);
410 }
411
412 std::vector<unsigned char>
413 GpuIndexIVFPQ::getListCodes(int listId) const {
414 FAISS_ASSERT(index_);
415 DeviceScope scope(device_);
416
417 return index_->getListCodes(listId);
418 }
419
420 std::vector<long>
421 GpuIndexIVFPQ::getListIndices(int listId) const {
422 FAISS_ASSERT(index_);
423 DeviceScope scope(device_);
424
425 return index_->getListIndices(listId);
426 }
427
428 void
429 GpuIndexIVFPQ::assertSettings_() const {
430 // Our implementation has these restrictions:
431
432 // Must have some number of lists
433 FAISS_ASSERT(nlist_ > 0);
434
435 // up to a single byte per code
436 FAISS_ASSERT(bitsPerCode_ <= 8);
437
438 // Sub-quantizers must evenly divide dimensions available
439 FAISS_ASSERT(this->d % subQuantizers_ == 0);
440
441 // The number of bytes per encoded vector must be one we support
442 FAISS_ASSERT(IVFPQ::isSupportedPQCodeLength(subQuantizers_));
443
444 // We must have enough shared memory on the current device to store
445 // our lookup distances
446 int lookupTableSize = sizeof(float);
447 #ifdef FAISS_USE_FLOAT16
448 if (useFloat16LookupTables_) {
449 lookupTableSize = sizeof(half);
450 }
451 #endif
452
453 // 64 bytes per code is only supported with usage of float16, at 2^8
454 // codes per subquantizer
455 FAISS_ASSERT(lookupTableSize * subQuantizers_ * utils::pow2(bitsPerCode_)
456 <= getMaxSharedMemPerBlock(device_));
457
458 // If precomputed codes are disabled, we have an extra limitation in
459 // terms of the number of dimensions per subquantizer
460 FAISS_ASSERT(usePrecomputed_ ||
461 IVFPQ::isSupportedNoPrecomputedSubDimSize(
462 this->d / subQuantizers_));
463
464 // TODO: fully implement METRIC_INNER_PRODUCT
465 FAISS_ASSERT(this->metric_type == faiss::METRIC_L2);
466 }
467
468 } } // namespace
faiss::gpu::GpuIndexIVFPQ::getListIndices
std::vector< long > getListIndices(int listId) const
Definition: GpuIndexIVFPQ.cu:421
faiss::IndexIVFPQ::precompute_table
void precompute_table()
build precomputed table
Definition: IndexIVFPQ.cpp:400
faiss::ProductQuantizer::nbits
size_t nbits
number of bits per quantization index
Definition: ProductQuantizer.h:30
faiss::IndexIVFPQ::polysemous_training
PolysemousTraining * polysemous_training
if NULL, use default
Definition: IndexIVFPQ.h:37
faiss::ProductQuantizer::byte_per_idx
size_t byte_per_idx
nb bytes per code component (1 or 2)
Definition: ProductQuantizer.h:34
faiss::gpu::IVFBase::getDim
int getDim() const
Return the number of dimensions we are indexing.
Definition: IVFBase.cu:99
faiss::gpu::IVFBase::getListLength
int getListLength(int listId) const
Definition: IVFBase.cu:199
faiss::gpu::GpuIndexFlat::getGpuData
FlatIndex * getGpuData()
For internal access.
Definition: GpuIndexFlat.h:109
faiss::Index::assign
void assign(idx_t n, const float *x, idx_t *labels, idx_t k=1)
Definition: Index.cpp:24
faiss::gpu::IVFBase::reserveMemory
void reserveMemory(size_t numVecs)
Reserve GPU memory in our inverted lists for this number of vectors.
Definition: IVFBase.cu:44
faiss::gpu::GpuIndexIVFPQ::getListLength
int getListLength(int listId) const
Definition: GpuIndexIVFPQ.cu:407
faiss::IndexIVFPQ::do_polysemous_training
bool do_polysemous_training
reorder PQ centroids after training?
Definition: IndexIVFPQ.h:36
faiss::IndexIVFPQ::scan_table_threshold
size_t scan_table_threshold
use table computation or on-the-fly?
Definition: IndexIVFPQ.h:40
faiss::IndexIVFPQ::precomputed_table
std::vector< float > precomputed_table
Definition: IndexIVFPQ.h:48
faiss::IndexIVFPQ::polysemous_ht
int polysemous_ht
Hamming thresh for polysemous filtering.
Definition: IndexIVFPQ.h:42
faiss::gpu::GpuIndexIVFPQ::addImpl_
virtual void addImpl_(faiss::Index::idx_t n, const float *x, const faiss::Index::idx_t *ids)
Called from GpuIndex for add/add_with_ids.
Definition: GpuIndexIVFPQ.cu:326
faiss::gpu::GpuResources
Definition: GpuResources.h:24
faiss::gpu::GpuIndexIVFPQ::getBitsPerCode
int getBitsPerCode() const
Return the number of bits per PQ code.
Definition: GpuIndexIVFPQ.cu:232
faiss::gpu::GpuIndex::device_
int device_
The GPU device we are resident on.
Definition: GpuIndex.h:80
faiss::IndexIVF::ids
std::vector< std::vector< long > > ids
Inverted lists for indexes.
Definition: IndexIVF.h:56
faiss::gpu::GpuIndexIVF
Definition: GpuIndexIVF.h:25
faiss::Index::d
int d
vector dimension
Definition: Index.h:66
faiss::IndexIVFPQ::max_codes
size_t max_codes
max nb of codes to visit to do a query
Definition: IndexIVFPQ.h:41
faiss::gpu::IVFPQ::isSupportedPQCodeLength
static bool isSupportedPQCodeLength(int size)
Returns true if we support PQ in this size.
Definition: IVFPQ.cu:71
faiss::gpu::GpuIndexIVFPQ::reclaimMemory
size_t reclaimMemory()
Definition: GpuIndexIVFPQ.cu:242
faiss::gpu::GpuIndexIVFPQ::searchImpl_
virtual void searchImpl_(faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const
Called from GpuIndex for search.
Definition: GpuIndexIVFPQ.cu:356
faiss::IndexIVFPQ
Definition: IndexIVFPQ.h:30
faiss::gpu::GpuIndexIVF::nprobe_
int nprobe_
Number of inverted list probes per query.
Definition: GpuIndexIVF.h:92
faiss::gpu::GpuIndexIVFPQ::reserveMemory
void reserveMemory(size_t numVecs)
Reserve GPU memory in our inverted lists for this number of vectors.
Definition: GpuIndexIVFPQ.cu:197
faiss::gpu::GpuIndexIVF::indicesOptions_
const IndicesOptions indicesOptions_
How should indices be stored on the GPU?
Definition: GpuIndexIVF.h:82
faiss::gpu::IVFPQ::classifyAndAddVectors
int classifyAndAddVectors(Tensor< float, 2, true > &vecs, Tensor< long, 1, true > &indices)
Definition: IVFPQ.cu:119
faiss::gpu::IVFPQ::query
void query(Tensor< float, 2, true > &queries, int nprobe, int k, Tensor< float, 2, true > &outDistances, Tensor< long, 2, true > &outIndices)
Definition: IVFPQ.cu:518
faiss::gpu::GpuIndexIVFPQ::reset
virtual void reset()
Definition: GpuIndexIVFPQ.cu:252
faiss::gpu::GpuIndexIVFPQ::copyFrom
void copyFrom(const faiss::IndexIVFPQ *index)
Definition: GpuIndexIVFPQ.cu:92
faiss::gpu::IVFPQ::getPQCentroids
Tensor< float, 3, true > getPQCentroids()
Definition: IVFPQ.cu:593
faiss::gpu::GpuIndex::resources_
GpuResources * resources_
Manages streans, cuBLAS handles and scratch memory for devices.
Definition: GpuIndex.h:77
faiss::gpu::GpuIndexIVF::copyTo
void copyTo(faiss::IndexIVF *index) const
Copy what we have to the CPU equivalent.
Definition: GpuIndexIVF.cu:187
faiss::Index::idx_t
long idx_t
all indices are this type
Definition: Index.h:64
faiss::gpu::GpuIndexIVF::nlist_
int nlist_
Number of inverted lists that we manage.
Definition: GpuIndexIVF.h:89
faiss::Index::ntotal
idx_t ntotal
total nb of indexed vectors
Definition: Index.h:67
faiss::Index::verbose
bool verbose
verbosity level
Definition: Index.h:68
faiss::gpu::IVFPQ::setPrecomputedCodes
void setPrecomputedCodes(bool enable)
Enable or disable pre-computed codes.
Definition: IVFPQ.cu:101
faiss::gpu::IVFPQ::getListCodes
std::vector< unsigned char > getListCodes(int listId) const
Return the list codes of a particular list back to the CPU.
Definition: IVFPQ.cu:585
faiss::gpu::GpuIndexIVFPQ::copyTo
void copyTo(faiss::IndexIVFPQ *index) const
Definition: GpuIndexIVFPQ.cu:149
faiss::gpu::IVFBase::reset
void reset()
Definition: IVFBase.cu:74
faiss::gpu::GpuIndexIVFPQ::getFloat16LookupTables
bool getFloat16LookupTables() const
Are float16 residual distance lookup tables enabled?
Definition: GpuIndexIVFPQ.cu:222
faiss::gpu::DeviceScope
Definition: DeviceUtils.h:55
faiss::IndexIVFPQ::by_residual
bool by_residual
Encode residual or plain vector?
Definition: IndexIVFPQ.h:31
faiss::gpu::GpuIndexIVF::quantizer_
GpuIndexFlat * quantizer_
Quantizer for inverted lists.
Definition: GpuIndexIVF.h:98
faiss::Index::metric_type
MetricType metric_type
type of metric this index uses for search
Definition: Index.h:74
faiss::IndexIVFPQ::pq
ProductQuantizer pq
produces the codes
Definition: IndexIVFPQ.h:34
faiss::ProductQuantizer::M
size_t M
number of subquantizers
Definition: ProductQuantizer.h:29
faiss::gpu::GpuIndexIVFPQ::getNumSubQuantizers
int getNumSubQuantizers() const
Return the number of sub-quantizers we are using.
Definition: GpuIndexIVFPQ.cu:227
faiss::gpu::IVFBase::getListIndices
std::vector< long > getListIndices(int listId) const
Return the list indices of a particular list back to the CPU.
Definition: IVFBase.cu:206
faiss::gpu::GpuIndexIVFPQ::getCentroidsPerSubQuantizer
int getCentroidsPerSubQuantizer() const
Return the number of centroids per PQ code (2^bits per code)
Definition: GpuIndexIVFPQ.cu:237
faiss::IndexIVFPQ::code_size
size_t code_size
code size per vector in bytes
Definition: IndexIVFPQ.h:33
faiss::gpu::GpuIndexIVFPQ::setPrecomputedCodes
void setPrecomputedCodes(bool enable)
Enable or disable pre-computed codes.
Definition: GpuIndexIVFPQ.cu:206
faiss::ProductQuantizer
Definition: ProductQuantizer.h:26
faiss::gpu::GpuIndexIVF::copyFrom
void copyFrom(const faiss::IndexIVF *index)
Copy what we need from the CPU equivalent.
Definition: GpuIndexIVF.cu:120
faiss::Index::is_trained
bool is_trained
set if the Index does not require training, or if training is done already
Definition: Index.h:71
faiss::Index::compute_residual
void compute_residual(const float *x, float *residual, idx_t key) const
Definition: Index.cpp:58
faiss::gpu::GpuIndexIVFPQ::getPrecomputedCodes
bool getPrecomputedCodes() const
Are pre-computed codes enabled?
Definition: GpuIndexIVFPQ.cu:217
faiss::gpu::GpuIndexIVFPQ::GpuIndexIVFPQ
GpuIndexIVFPQ(GpuResources *resources, int device, IndicesOptions indicesOptions, bool useFloat16LookupTables, const faiss::IndexIVFPQ *index)
Definition: GpuIndexIVFPQ.cu:26
faiss::gpu::IVFBase::reclaimMemory
size_t reclaimMemory()
Definition: IVFBase.cu:104
faiss::gpu::IVFPQ
Implementing class for IVFPQ on the GPU.
Definition: IVFPQ.cuh:20
faiss::MetricType
MetricType
Some algorithms support both an inner product vetsion and a L2 search version.
Definition: Index.h:44
faiss::gpu::GpuIndexIVFPQ::train
virtual void train(Index::idx_t n, const float *x)
Definition: GpuIndexIVFPQ.cu:307
faiss::IndexIVFPQ::use_precomputed_table
int use_precomputed_table
if by_residual, build precompute tables
Definition: IndexIVFPQ.h:32
faiss::gpu::GpuIndexIVFPQ::getListCodes
std::vector< unsigned char > getListCodes(int listId) const
Definition: GpuIndexIVFPQ.cu:413
faiss::ProductQuantizer::centroids
std::vector< float > centroids
Centroid table, size M * ksub * dsub.
Definition: ProductQuantizer.h:53
faiss::gpu::IVFPQ::isSupportedNoPrecomputedSubDimSize
static bool isSupportedNoPrecomputedSubDimSize(int dims)
Definition: IVFPQ.cu:96