Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
faiss::gpu::GpuIndex Class Referenceabstract
Inheritance diagram for faiss::gpu::GpuIndex:
faiss::Index faiss::gpu::GpuIndexFlat faiss::gpu::GpuIndexIVF faiss::gpu::GpuIndexFlatIP faiss::gpu::GpuIndexFlatL2 faiss::gpu::GpuIndexIVFFlat faiss::gpu::GpuIndexIVFPQ

Public Member Functions

 GpuIndex (GpuResources *resources, int dims, faiss::MetricType metric, GpuIndexConfig config)
 
int getDevice () const
 
GpuResourcesgetResources ()
 
void setMinPagingSize (size_t size)
 
size_t getMinPagingSize () const
 Returns the current minimum data size for paged searches.
 
void add (faiss::Index::idx_t, const float *x) override
 
void add_with_ids (Index::idx_t n, const float *x, const Index::idx_t *ids) override
 
void search (Index::idx_t n, const float *x, Index::idx_t k, float *distances, Index::idx_t *labels) const override
 
- Public Member Functions inherited from faiss::Index
 Index (idx_t d=0, MetricType metric=METRIC_L2)
 
virtual void train (idx_t n, const float *x)
 
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 void reset ()=0
 removes all elements from the database.
 
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
 
virtual void search_and_reconstruct (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, float *recons) const
 
void compute_residual (const float *x, float *residual, idx_t key) const
 
void display () const
 

Protected Member Functions

virtual bool addImplRequiresIDs_ () const =0
 
virtual void addImpl_ (int n, const float *x, const Index::idx_t *ids)=0
 
virtual void searchImpl_ (int n, const float *x, int k, float *distances, Index::idx_t *labels) const =0
 

Protected Attributes

GpuResourcesresources_
 Manages streams, 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.
 
size_t minPagedSize_
 Size above which we page copies from the CPU to GPU.
 

Additional Inherited Members

- Public Types inherited from faiss::Index
using idx_t = long
 all indices are this type
 
using component_t = float
 
using distance_t = float
 
- 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
 

Detailed Description

Definition at line 33 of file GpuIndex.h.

Member Function Documentation

void faiss::gpu::GpuIndex::add ( faiss::Index::idx_t  n,
const float *  x 
)
overridevirtual

x can be resident on the CPU or any GPU; copies are performed as needed Handles paged adds if the add set is too large; calls addInternal_

Implements faiss::Index.

Reimplemented in faiss::gpu::GpuIndexFlat.

Definition at line 79 of file GpuIndex.cu.

void faiss::gpu::GpuIndex::add_with_ids ( Index::idx_t  n,
const float *  x,
const Index::idx_t ids 
)
overridevirtual

x and ids can be resident on the CPU or any GPU; copies are performed as needed Handles paged adds if the add set is too large; calls addInternal_

Reimplemented from faiss::Index.

Definition at line 85 of file GpuIndex.cu.

virtual void faiss::gpu::GpuIndex::addImpl_ ( int  n,
const float *  x,
const Index::idx_t ids 
)
protectedpure virtual

Overridden to actually perform the add All data is guaranteed to be resident on our device

Implemented in faiss::gpu::GpuIndexIVFPQ, faiss::gpu::GpuIndexFlat, and faiss::gpu::GpuIndexIVFFlat.

virtual bool faiss::gpu::GpuIndex::addImplRequiresIDs_ ( ) const
protectedpure virtual

Does addImpl_ require IDs? If so, and no IDs are provided, we will generate them sequentially based on the order in which the IDs are added

Implemented in faiss::gpu::GpuIndexFlat, and faiss::gpu::GpuIndexIVF.

void faiss::gpu::GpuIndex::search ( Index::idx_t  n,
const float *  x,
Index::idx_t  k,
float *  distances,
Index::idx_t labels 
) const
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 176 of file GpuIndex.cu.

virtual void faiss::gpu::GpuIndex::searchImpl_ ( int  n,
const float *  x,
int  k,
float *  distances,
Index::idx_t labels 
) const
protectedpure virtual

Overridden to actually perform the search All data is guaranteed to be resident on our device

Implemented in faiss::gpu::GpuIndexIVFPQ, faiss::gpu::GpuIndexFlat, and faiss::gpu::GpuIndexIVFFlat.

void faiss::gpu::GpuIndex::setMinPagingSize ( size_t  size)

Set the minimum data size for searches (in MiB) for which we use CPU -> GPU paging

Definition at line 69 of file GpuIndex.cu.


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