All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
faiss::gpu::IVFBase Class Reference

Base inverted list functionality for IVFFlat and IVFPQ. More...

Inheritance diagram for faiss::gpu::IVFBase:

## Public Member Functions

| IVFBase (GpuResources *resources, FlatIndex *quantizer, int bytesPerVector, IndicesOptions indicesOptions, MemorySpace space)
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.

## Protected Member Functions

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

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?
const MemorySpace | space_
| What memory space our inverted list storage is in.
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

Base inverted list functionality for IVFFlat and IVFPQ.

Definition at line 27 of file IVFBase.cuh.

## Constructor & Destructor Documentation

faiss::gpu::IVFBase::IVFBase | ( | GpuResources * | resources,
|  | FlatIndex * | quantizer,
|  | int | bytesPerVector,
|  | IndicesOptions | indicesOptions,
|  | MemorySpace | space
| ) |  |

Parameters

  quantizer | We do not own this reference

Definition at line 25 of file IVFBase.cu.

## Member Function Documentation

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

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

Definition at line 200 of file IVFBase.cu.

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

size_t faiss::gpu::IVFBase::reclaimMemory_ | ( | bool | exact | ) |

protected

Reclaim memory consumed on the device for our inverted lists `exact` means we trim exactly to the memory needed

Definition at line 111 of file IVFBase.cu.

void faiss::gpu::IVFBase::reset | ( |  | ) |

Clear out all inverted lists, but retain the coarse quantizer and the product quantizer info

Definition at line 75 of file IVFBase.cu.

void faiss::gpu::IVFBase::updateDeviceListInfo_ | ( | const std::vector< int > & | listIds,
|  | cudaStream_t | stream
| ) |  |

protected

For a set of list IDs, update device-side list pointer and size information

Definition at line 148 of file IVFBase.cu.

## Member Data Documentation

std::vector<std::unique_ptr<DeviceVector<unsigned char> > > faiss::gpu::IVFBase::deviceListData_

protected

Device memory for each separate list, as managed by the host. Device memory as stored in DeviceVector is stored as unique_ptr since deviceListSummary_ pointers must remain valid despite resizing of deviceLists_

Definition at line 121 of file IVFBase.cuh.

thrust::device_vector<void*> faiss::gpu::IVFBase::deviceListDataPointers_

protected

Device representation of all inverted list data id -> data

Definition at line 104 of file IVFBase.cuh.

thrust::device_vector<void*> faiss::gpu::IVFBase::deviceListIndexPointers_

protected

Device representation of all inverted list index pointers id -> data

Definition at line 108 of file IVFBase.cuh.

thrust::device_vector<int> faiss::gpu::IVFBase::deviceListLengths_

protected

Device representation of all inverted list lengths id -> length

Definition at line 112 of file IVFBase.cuh.

std::vector<std::vector<long> > faiss::gpu::IVFBase::listOffsetToUserIndex_

protected

If we are storing indices on the CPU (indicesOptions_ is INDICES_CPU), then this maintains a CPU-side map of what (inverted list id, offset) maps to which user index

Definition at line 127 of file IVFBase.cuh.

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

- /data/users/matthijs/github_faiss/faiss/gpu/impl/IVFBase.cuh
- /data/users/matthijs/github_faiss/faiss/gpu/impl/IVFBase.cu