Faiss

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Protected Member Functions | List of all members
faiss::gpu::GpuIndexIVFPQ Class Reference

IVFPQ index for the GPU. More...

`#include <GpuIndexIVFPQ.h>`

Inheritance diagram for faiss::gpu::GpuIndexIVFPQ:

## Public Member Functions
| GpuIndexIVFPQ (GpuResources *resources, const faiss::IndexIVFPQ *index, GpuIndexIVFPQConfig config=GpuIndexIVFPQConfig())
| GpuIndexIVFPQ (GpuResources *resources, int dims, int nlist, int subQuantizers, int bitsPerCode, faiss::MetricType metric, GpuIndexIVFPQConfig config=GpuIndexIVFPQConfig())
| Construct an empty index.
void | copyFrom (const faiss::IndexIVFPQ *index)
void | copyTo (faiss::IndexIVFPQ *index) const
void | reserveMemory (size_t numVecs)
| Reserve GPU memory in our inverted lists for this number of vectors.
void | setPrecomputedCodes (bool enable)
| Enable or disable pre-computed codes.
bool | getPrecomputedCodes () const
| Are pre-computed codes enabled?
int | getNumSubQuantizers () const
| Return the number of sub-quantizers we are using.
int | getBitsPerCode () const
| Return the number of bits per PQ code.
int | getCentroidsPerSubQuantizer () const
| Return the number of centroids per PQ code (2^bits per code)
size_t | reclaimMemory ()
void | reset () override
void | train (Index::idx_t n, const float *x) override
int | getListLength (int listId) const
std::vector< unsigned char > | getListCodes (int listId) const
std::vector< long > | getListIndices (int listId) const
Public Member Functions inherited from faiss::gpu::GpuIndexIVF
| GpuIndexIVF (GpuResources *resources, int dims, faiss::MetricType metric, int nlist, GpuIndexIVFConfig config=GpuIndexIVFConfig())
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.
GpuIndexFlat * | getQuantizer ()
| Return the quantizer we're using.
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
Public Member Functions inherited from faiss::gpu::GpuIndex
| GpuIndex (GpuResources *resources, int dims, faiss::MetricType metric, GpuIndexConfig config)
int | getDevice () const
GpuResources * | getResources ()
void | add_with_ids (Index::idx_t n, const float *x, const Index::idx_t *ids) 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
Public Member Functions inherited from faiss::Index
| 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

## Protected Member Functions
void | addImpl_ (faiss::Index::idx_t n, const float *x, const faiss::Index::idx_t *ids) override
| Called from GpuIndex for add/add_with_ids.
void | searchImpl_ (faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const override
| Called from GpuIndex for search.
Protected Member Functions inherited from faiss::gpu::GpuIndexIVF
void | trainQuantizer_ (faiss::Index::idx_t n, const float *x)
Protected Member Functions inherited from faiss::gpu::GpuIndex
void | addInternal_ (Index::idx_t n, const float *x, const Index::idx_t *ids)

## Additional Inherited Members
Public Types inherited from faiss::Index
typedef long | idx_t
| all indices are this type
Public Attributes inherited from faiss::gpu::GpuIndexIVF
ClusteringParameters | cp
Public Attributes inherited from faiss::Index
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
Protected Attributes inherited from faiss::gpu::GpuIndexIVF
GpuIndexIVFConfig | ivfConfig_
int | nlist_
| Number of inverted lists that we manage.
int | nprobe_
| Number of inverted list probes per query.
GpuIndexFlat * | quantizer_
| Quantizer for inverted lists.
Protected Attributes inherited from faiss::gpu::GpuIndex
GpuResources * | resources_
| Manages streans, cuBLAS handles and scratch memory for devices.
const int | device_
| The GPU device we are resident on.
const MemorySpace | memorySpace_
| The memory space of our primary storage on the GPU.

## Detailed Description

IVFPQ index for the GPU.

Definition at line 40 of file GpuIndexIVFPQ.h.

## Constructor & Destructor Documentation

faiss::gpu::GpuIndexIVFPQ::GpuIndexIVFPQ | ( | GpuResources * | resources,
|  | const faiss::IndexIVFPQ * | index,
|  | GpuIndexIVFPQConfig | config = `GpuIndexIVFPQConfig()`
| ) |  |

Construct from a pre-existing faiss::IndexIVFPQ instance, copying data over to the given GPU, if the input index is trained.

Definition at line 25 of file GpuIndexIVFPQ.cu.

## Member Function Documentation

void faiss::gpu::GpuIndexIVFPQ::copyFrom | ( | const faiss::IndexIVFPQ * | index | ) |

Reserve space on the GPU for the inverted lists for `num` vectors, assumed equally distributed among Initialize ourselves from the given CPU index; will overwrite all data in ourselves

Definition at line 80 of file GpuIndexIVFPQ.cu.

void faiss::gpu::GpuIndexIVFPQ::copyTo | ( | faiss::IndexIVFPQ * | index | ) | const

Copy ourselves to the given CPU index; will overwrite all data in the index instance

Definition at line 144 of file GpuIndexIVFPQ.cu.

std::vector< unsigned char > faiss::gpu::GpuIndexIVFPQ::getListCodes | ( | int | listId | ) | const

For debugging purposes, return the list codes of a particular list

Definition at line 399 of file GpuIndexIVFPQ.cu.

std::vector< long > faiss::gpu::GpuIndexIVFPQ::getListIndices | ( | int | listId | ) | const

For debugging purposes, return the list indices of a particular list

Definition at line 407 of file GpuIndexIVFPQ.cu.

int faiss::gpu::GpuIndexIVFPQ::getListLength | ( | int | listId | ) | const

For debugging purposes, return the list length of a particular list

Definition at line 393 of file GpuIndexIVFPQ.cu.

size_t faiss::gpu::GpuIndexIVFPQ::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 234 of file GpuIndexIVFPQ.cu.

void faiss::gpu::GpuIndexIVFPQ::reset | ( |  | ) |
| override virtual

Clears out all inverted lists, but retains the coarse and product centroid information

Implements faiss::Index.

Definition at line 244 of file GpuIndexIVFPQ.cu.

void faiss::gpu::GpuIndexIVFPQ::train | ( | Index::idx_t | ,
|  | const float * |
| ) |  |
| override virtual

Perform training on a representative set of vectors

Parameters

  n | nb of training vectors
  x | training vecors, size n * d

Reimplemented from faiss::Index.

Definition at line 300 of file GpuIndexIVFPQ.cu.

The documentation for this class was generated from the following files:

- /data/users/matthijs/github_faiss/faiss/gpu/GpuIndexIVFPQ.h
- /data/users/matthijs/github_faiss/faiss/gpu/GpuIndexIVFPQ.cu