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 | Static Public Member Functions | List of all members
faiss::gpu::IVFPQ Class Reference

Implementing class for IVFPQ on the GPU. More...

Inheritance diagram for faiss::gpu::IVFPQ:

## Public Member Functions
| IVFPQ (GpuResources *resources, FlatIndex *quantizer, int numSubQuantizers, int bitsPerSubQuantizer, float *pqCentroidData, IndicesOptions indicesOptions, bool useFloat16LookupTables)
void | setPrecomputedCodes (bool enable)
| Enable or disable pre-computed codes.
void | addCodeVectorsFromCpu (int listId, const void *codes, const long *indices, size_t numVecs)
int | classifyAndAddVectors (Tensor< float, 2, true > &vecs, Tensor< long, 1, true > &indices)
void | query (Tensor< float, 2, true > &queries, int nprobe, int k, Tensor< float, 2, true > &outDistances, Tensor< long, 2, true > &outIndices)
std::vector< unsigned char > | getListCodes (int listId) const
| Return the list codes of a particular list back to the CPU.
Tensor< float, 3, true > | getPQCentroids ()
Public Member Functions inherited from faiss::gpu::IVFBase
| IVFBase (GpuResources *resources, FlatIndex *quantizer, int bytesPerVector, IndicesOptions indicesOptions)
void | reserveMemory (size_t numVecs)
| Reserve GPU memory in our inverted lists for this number of vectors.
void | reset ()
int | getDim () const
| Return the number of dimensions we are indexing.
size_t | reclaimMemory ()
size_t | getNumLists () const
| Returns the number of inverted lists.
int | getListLength (int listId) const
std::vector< long > | getListIndices (int listId) const
| Return the list indices of a particular list back to the CPU.

## Static Public Member Functions
static bool | isSupportedPQCodeLength (int size)
| Returns true if we support PQ in this size.
static bool | isSupportedNoPrecomputedSubDimSize (int dims)

## Additional Inherited Members
Protected Member Functions inherited from faiss::gpu::IVFBase
size_t | reclaimMemory_ (bool exact)
void | updateDeviceListInfo_ (cudaStream_t stream)
| Update all device-side list pointer and size information.
void | updateDeviceListInfo_ (const std::vector< int > &listIds, cudaStream_t stream)
void | addIndicesFromCpu_ (int listId, const long *indices, size_t numVecs)
| Shared function to copy indices from CPU to GPU.
Protected Attributes inherited from faiss::gpu::IVFBase
GpuResources * | resources_
| Collection of GPU resources that we use.
FlatIndex * | quantizer_
| Quantizer object.
const int | dim_
| Expected dimensionality of the vectors.
const int | numLists_
| Number of inverted lists we maintain.
const int | bytesPerVector_
| Number of bytes per vector in the list.
const IndicesOptions | indicesOptions_
| How are user indices stored on the GPU?
thrust::device_vector< void * > | deviceListDataPointers_
thrust::device_vector< void * > | deviceListIndexPointers_
thrust::device_vector< int > | deviceListLengths_
int | maxListLength_
| Maximum list length seen.
std::vector< std::unique_ptr < DeviceVector< unsigned char > > > | deviceListData_
std::vector< std::unique_ptr < DeviceVector< unsigned char > > > | deviceListIndices_
std::vector< std::vector< long > > | listOffsetToUserIndex_

## Detailed Description

Implementing class for IVFPQ on the GPU.

Definition at line 20 of file IVFPQ.cuh.

## Constructor & Destructor Documentation

faiss::gpu::IVFPQ::IVFPQ | ( | GpuResources * | resources,
|  | FlatIndex * | quantizer,
|  | int | numSubQuantizers,
|  | int | bitsPerSubQuantizer,
|  | float * | pqCentroidData,
|  | IndicesOptions | indicesOptions,
|  | bool | useFloat16LookupTables
| ) |  |

Parameters

  quantizer | We do not own this reference

Definition at line 36 of file IVFPQ.cu.

## Member Function Documentation

void faiss::gpu::IVFPQ::addCodeVectorsFromCpu | ( | int | listId,
|  | const void * | codes,
|  | const long * | indices,
|  | size_t | numVecs
| ) |  |

Adds a set of codes and indices to a list; the data can be resident on either the host or the device

Definition at line 347 of file IVFPQ.cu.

int faiss::gpu::IVFPQ::classifyAndAddVectors | ( | Tensor< float, 2, true > & | vecs,
|  | Tensor< long, 1, true > & | indices
| ) |  |

Calcuates the residual and quantizes the vectors, adding them to this index The input data must be on our current device. Returns the number of vectors successfully added. Vectors may not be able to be added because they contain NaNs.

Definition at line 119 of file IVFPQ.cu.

Tensor< float, 3, true > faiss::gpu::IVFPQ::getPQCentroids | ( |  | ) |

Returns our set of sub-quantizers of the form (sub q)(code id)(sub dim)

Definition at line 592 of file IVFPQ.cu.

bool faiss::gpu::IVFPQ::isSupportedNoPrecomputedSubDimSize | ( | int | dims | ) |
| static

For no precomputed codes, is this a supported sub-dimension size? FIXME: get MM implementation working again

Definition at line 96 of file IVFPQ.cu.

void faiss::gpu::IVFPQ::query | ( | Tensor< float, 2, true > & | queries,
|  | int | nprobe,
|  | int | k,
|  | Tensor< float, 2, true > & | outDistances,
|  | Tensor< long, 2, true > & | outIndices
| ) |  |

Find the approximate k nearest neigbors for `queries` against our database

Definition at line 517 of file IVFPQ.cu.

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

- IVFPQ.cuh
- IVFPQ.cu