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 | Protected Attributes | List of all members
faiss::gpu::GpuIndexFlat Class Reference

`#include <GpuIndexFlat.h>`

Inheritance diagram for faiss::gpu::GpuIndexFlat:

## Public Member Functions
| GpuIndexFlat (GpuResources *resources, const faiss::IndexFlat *index, GpuIndexFlatConfig config=GpuIndexFlatConfig())
| GpuIndexFlat (GpuResources *resources, int dims, faiss::MetricType metric, GpuIndexFlatConfig config=GpuIndexFlatConfig())
| Construct an empty instance that can be added to.
void | setMinPagingSize (size_t size)
size_t | getMinPagingSize () const
| Returns the current minimum data size for paged searches.
bool | getUseFloat16 () const
| Do we store vectors and perform math in float16?
void | copyFrom (const faiss::IndexFlat *index)
void | copyTo (faiss::IndexFlat *index) const
size_t | getNumVecs () const
| Returns the number of vectors we contain.
virtual void | reset ()
| Clears all vectors from this index.
virtual void | train (Index::idx_t n, const float *x)
| This index is not trained, so this does nothing.
virtual void | search (faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const
virtual void | reconstruct (faiss::Index::idx_t key, float *out) const
virtual void | reconstruct_n (faiss::Index::idx_t i0, faiss::Index::idx_t num, float *out) const
| Batch reconstruction method.
virtual void | set_typename ()
FlatIndex * | getGpuData ()
| For internal access.
Public Member Functions inherited from faiss::gpu::GpuIndex
| GpuIndex (GpuResources *resources, int device, int dims, faiss::MetricType metric)
int | getDevice () const
GpuResources * | getResources ()
virtual void | add (faiss::Index::idx_t, const float *x)
virtual void | add_with_ids (Index::idx_t n, const float *x, const Index::idx_t *ids)
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)
void | compute_residual (const float *x, float *residual, idx_t key) const
void | display () const
virtual std::string | get_typename () const

## Protected Member Functions
virtual void | addImpl_ (faiss::Index::idx_t n, const float *x, const faiss::Index::idx_t *ids)
| Called from GpuIndex for add.
virtual void | searchImpl_ (faiss::Index::idx_t n, const float *x, faiss::Index::idx_t k, float *distances, faiss::Index::idx_t *labels) const
| Should not be called (we have our own implementation)
void | searchFromCpuPaged_ (int n, const float *x, int k, float *outDistancesData, int *outIndicesData) const
void | searchNonPaged_ (int n, const float *x, int k, float *outDistancesData, int *outIndicesData) const
Protected Member Functions inherited from faiss::gpu::GpuIndex
void | addInternal_ (Index::idx_t n, const float *x, const Index::idx_t *ids)

## Protected Attributes
size_t | minPagedSize_
| Size above which we page copies from the CPU to GPU.
const GpuIndexFlatConfig | config_
FlatIndex * | data_
| Holds our GPU data containing the list of vectors.
Protected Attributes inherited from faiss::gpu::GpuIndex
GpuResources * | resources_
| Manages streans, cuBLAS handles and scratch memory for devices.
int | device_
| The GPU device we are resident on.

## Additional Inherited Members
Public Types inherited from faiss::Index
typedef long | idx_t
| all indices are this type
Public Attributes inherited from faiss::Index
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

## Detailed Description

Wrapper around the GPU implementation that looks like faiss::IndexFlat; copies over centroid data from a given faiss::IndexFlat

Definition at line 43 of file GpuIndexFlat.h.

## Constructor & Destructor Documentation

faiss::gpu::GpuIndexFlat::GpuIndexFlat | ( | GpuResources * | resources,
|  | const faiss::IndexFlat * | index,
|  | GpuIndexFlatConfig | config = `GpuIndexFlatConfig()`
| ) |  |

Construct from a pre-existing faiss::IndexFlat instance, copying data over to the given GPU

Definition at line 33 of file GpuIndexFlat.cu.

## Member Function Documentation

void faiss::gpu::GpuIndexFlat::copyFrom | ( | const faiss::IndexFlat * | index | ) |

Initialize ourselves from the given CPU index; will overwrite all data in ourselves

Definition at line 84 of file GpuIndexFlat.cu.

void faiss::gpu::GpuIndexFlat::copyTo | ( | faiss::IndexFlat * | index | ) | const

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

Definition at line 111 of file GpuIndexFlat.cu.

void faiss::gpu::GpuIndexFlat::reconstruct | ( | faiss::Index::idx_t | key,
|  | float * | out
| ) |  | const
| virtual

Reconstruction methods; prefer the batch reconstruct as it will be more efficient

Reimplemented from faiss::Index.

Definition at line 458 of file GpuIndexFlat.cu.

void faiss::gpu::GpuIndexFlat::search | ( | faiss::Index::idx_t | n,
|  | const float * | x,
|  | faiss::Index::idx_t | k,
|  | float * | distances,
|  | faiss::Index::idx_t * | labels
| ) |  | const
| virtual

`x`, `distances` and `labels` can be resident on the CPU or any GPU; copies are performed as needed We have our own implementation here which handles CPU async copies; searchImpl_ is not called FIXME: move paged impl into GpuIndex

Reimplemented from faiss::gpu::GpuIndex.

Definition at line 176 of file GpuIndexFlat.cu.

void faiss::gpu::GpuIndexFlat::searchFromCpuPaged_ | ( | int | n,
|  | const float * | x,
|  | int | k,
|  | float * | outDistancesData,
|  | int * | outIndicesData
| ) |  | const
| protected

Called from search when the input data is on the CPU; potentially allows for pinned memory usage

Definition at line 286 of file GpuIndexFlat.cu.

void faiss::gpu::GpuIndexFlat::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 GpuIndexFlat.cu.

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

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