#include <GpuIndexIVFFlat.h>
Public Member Functions | |
GpuIndexIVFFlat (GpuResources *resources, int device, bool useFloat16CoarseQuantizer, bool useFloat16IVFStorage, int dims, int nlist, IndicesOptions indicesOptions, faiss::MetricType metric) | |
GpuIndexIVFFlat (GpuResources *resources, int device, GpuIndexFlat *quantizer, bool useFloat16, int dims, int nlist, IndicesOptions indicesOptions, faiss::MetricType metric) | |
void | reserveMemory (size_t numVecs) |
Reserve GPU memory in our inverted lists for this number of vectors. | |
void | copyFrom (const faiss::IndexIVFFlat *index) |
void | copyTo (faiss::IndexIVFFlat *index) const |
size_t | reclaimMemory () |
void | reset () override |
removes all elements from the database. | |
void | train (Index::idx_t n, const float *x) override |
void | add_with_ids (Index::idx_t n, const float *x, const Index::idx_t *xids) override |
void | search (faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const override |
void | set_typename () override |
![]() | |
GpuIndexIVF (GpuResources *resources, int device, IndicesOptions indicesOptions, bool useFloat16CoarseQuantizer, int dims, faiss::MetricType metric, int nlist) | |
GpuIndexIVF (GpuResources *resources, int device, IndicesOptions indicesOptions, int dims, faiss::MetricType metric, int nlist, GpuIndexFlat *quantizer) | |
IndicesOptions | getIndicesOptions () const |
What indices storage options are we using? | |
bool | getUseFloat16CoarseQuantizer () const |
Is our coarse quantizer storing and performing math in float16? | |
void | copyFrom (const faiss::IndexIVF *index) |
Copy what we need from the CPU equivalent. | |
void | copyTo (faiss::IndexIVF *index) const |
Copy what we have to the CPU equivalent. | |
int | getNumLists () const |
Returns the number of inverted lists we're managing. | |
void | setNumProbes (int nprobe) |
Sets the number of list probes per query. | |
int | getNumProbes () const |
Returns our current number of list probes per query. | |
void | add (Index::idx_t n, const float *x) override |
![]() | |
GpuIndex (GpuResources *resources, int device, int dims, faiss::MetricType metric) | |
int | getDevice () const |
GpuResources * | getResources () |
![]() | |
Index (idx_t d=0, MetricType metric=METRIC_INNER_PRODUCT) | |
virtual void | range_search (idx_t n, const float *x, float radius, RangeSearchResult *result) const |
void | assign (idx_t n, const float *x, idx_t *labels, idx_t k=1) |
virtual long | remove_ids (const IDSelector &sel) |
virtual void | reconstruct (idx_t key, float *recons) const |
virtual void | reconstruct_n (idx_t i0, idx_t ni, float *recons) const |
void | compute_residual (const float *x, float *residual, idx_t key) const |
void | display () const |
virtual std::string | get_typename () const |
Additional Inherited Members | |
![]() | |
typedef long | idx_t |
all indices are this type | |
![]() | |
std::string | index_typename |
int | d |
vector dimension | |
idx_t | ntotal |
total nb of indexed vectors | |
bool | verbose |
verbosity level | |
bool | is_trained |
set if the Index does not require training, or if training is done already | |
MetricType | metric_type |
type of metric this index uses for search | |
![]() | |
void | trainQuantizer_ (faiss::Index::idx_t n, const float *x) |
![]() | |
const IndicesOptions | indicesOptions_ |
How should indices be stored on the GPU? | |
const bool | useFloat16CoarseQuantizer_ |
int | nlist_ |
Number of inverted lists that we manage. | |
int | nprobe_ |
Number of inverted list probes per query. | |
ClusteringParameters | cp_ |
Ability to override default clustering parameters. | |
GpuIndexFlat * | quantizer_ |
Quantizer for inverted lists. | |
bool | ownsQuantizer_ |
Do we own the above quantizer instance? | |
![]() | |
GpuResources * | resources_ |
Manages streans, cuBLAS handles and scratch memory for devices. | |
int | device_ |
The GPU device we are resident on. | |
Wrapper around the GPU implementation that looks like faiss::IndexIVFFlat
Definition at line 25 of file GpuIndexIVFFlat.h.
faiss::gpu::GpuIndexIVFFlat::GpuIndexIVFFlat | ( | GpuResources * | resources, |
int | device, | ||
bool | useFloat16CoarseQuantizer, | ||
bool | useFloat16IVFStorage, | ||
int | dims, | ||
int | nlist, | ||
IndicesOptions | indicesOptions, | ||
faiss::MetricType | metric | ||
) |
Constructs a new instance with an empty flat quantizer; the user provides the number of lists desired.
Definition at line 26 of file GpuIndexIVFFlat.cu.
faiss::gpu::GpuIndexIVFFlat::GpuIndexIVFFlat | ( | GpuResources * | resources, |
int | device, | ||
GpuIndexFlat * | quantizer, | ||
bool | useFloat16, | ||
int | dims, | ||
int | nlist, | ||
IndicesOptions | indicesOptions, | ||
faiss::MetricType | metric | ||
) |
Call to initialize ourselves from a GpuIndexFlat instance. The quantizer must match the dimension parameters specified; if populated, it must also match the number of list elements available. The index must also be present on the same device as ourselves. We do not own this quantizer instance.
Definition at line 58 of file GpuIndexIVFFlat.cu.
|
overridevirtual |
x
and xids
can be resident on the CPU or any GPU; the proper copies are performed
Reimplemented from faiss::Index.
Definition at line 214 of file GpuIndexIVFFlat.cu.
void faiss::gpu::GpuIndexIVFFlat::copyFrom | ( | const faiss::IndexIVFFlat * | index | ) |
Initialize ourselves from the given CPU index; will overwrite all data in ourselves
Definition at line 103 of file GpuIndexIVFFlat.cu.
void faiss::gpu::GpuIndexIVFFlat::copyTo | ( | faiss::IndexIVFFlat * | index | ) | const |
Copy ourselves to the given CPU index; will overwrite all data in the index instance
Definition at line 141 of file GpuIndexIVFFlat.cu.
size_t faiss::gpu::GpuIndexIVFFlat::reclaimMemory | ( | ) |
After adding vectors, one can call this to reclaim device memory to exactly the amount needed. Returns space reclaimed in bytes
Definition at line 163 of file GpuIndexIVFFlat.cu.
|
overridevirtual |
x
, distances
and labels
can be resident on the CPU or any GPU; copies are performed as needed
Implements faiss::Index.
Definition at line 244 of file GpuIndexIVFFlat.cu.
|
overridevirtual |
Perform training on a representative set of vectors
n | nb of training vectors |
x | training vecors, size n * d |
Reimplemented from faiss::Index.
Definition at line 186 of file GpuIndexIVFFlat.cu.