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::GpuIndexBinaryFlat Class Reference

`#include <GpuIndexBinaryFlat.h>`

Inheritance diagram for faiss::gpu::GpuIndexBinaryFlat:

## Public Member Functions
| GpuIndexBinaryFlat (GpuResources *resources, const faiss::IndexBinaryFlat *index, GpuIndexBinaryFlatConfig config=GpuIndexBinaryFlatConfig())
| GpuIndexBinaryFlat (GpuResources *resources, int dims, GpuIndexBinaryFlatConfig config=GpuIndexBinaryFlatConfig())
| Construct an empty instance that can be added to.
void | copyFrom (const faiss::IndexBinaryFlat *index)
void | copyTo (faiss::IndexBinaryFlat *index) const
void | add (faiss::IndexBinary::idx_t n, const uint8_t *x) override
void | reset () override
| Removes all elements from the database.
void | search (faiss::IndexBinary::idx_t n, const uint8_t *x, faiss::IndexBinary::idx_t k, int32_t *distances, faiss::IndexBinary::idx_t *labels) const override
void | reconstruct (faiss::IndexBinary::idx_t key, uint8_t *recons) const override
Public Member Functions inherited from faiss::IndexBinary
| IndexBinary (idx_t d=0, MetricType metric=METRIC_L2)
virtual void | train (idx_t n, const uint8_t *x)
virtual void | add_with_ids (idx_t n, const uint8_t *x, const long *xids)
virtual void | range_search (idx_t n, const uint8_t *x, int radius, RangeSearchResult *result) const
void | assign (idx_t n, const uint8_t *x, idx_t *labels, idx_t k=1)
virtual long | remove_ids (const IDSelector &sel)
virtual void | reconstruct_n (idx_t i0, idx_t ni, uint8_t *recons) const
virtual void | search_and_reconstruct (idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels, uint8_t *recons) const
void | display () const

## Protected Member Functions
void | searchFromCpuPaged_ (int n, const uint8_t *x, int k, int32_t *outDistancesData, int *outIndicesData) const
void | searchNonPaged_ (int n, const uint8_t *x, int k, int32_t *outDistancesData, int *outIndicesData) const

## Protected Attributes
GpuResources * | resources_
| Manages streans, cuBLAS handles and scratch memory for devices.
GpuIndexBinaryFlatConfig | config_
| Configuration options.
BinaryFlatIndex * | data_

## Additional Inherited Members
Public Types inherited from faiss::IndexBinary
typedef long | idx_t
| all indices are this type
Public Attributes inherited from faiss::IndexBinary
int | d
| vector dimension
int | code_size
| number of bytes per vector ( = d / 8 )
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

A GPU version of IndexBinaryFlat for brute-force comparison of bit vectors via Hamming distance

Definition at line 24 of file GpuIndexBinaryFlat.h.

## Constructor & Destructor Documentation

faiss::gpu::GpuIndexBinaryFlat::GpuIndexBinaryFlat | ( | GpuResources * | resources,
|  | const faiss::IndexBinaryFlat * | index,
|  | GpuIndexBinaryFlatConfig | config = `GpuIndexBinaryFlatConfig()`
| ) |  |

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

Definition at line 25 of file GpuIndexBinaryFlat.cu.

## Member Function Documentation

void faiss::gpu::GpuIndexBinaryFlat::add | ( | faiss::IndexBinary::idx_t | n,
|  | const uint8_t * | x
| ) |  |
| override virtual

Add n vectors of dimension d to the index.

Vectors are implicitly assigned labels ntotal .. ntotal + n - 1

Parameters

  x | input matrix, size n * d / 8

Implements faiss::IndexBinary.

Definition at line 117 of file GpuIndexBinaryFlat.cu.

void faiss::gpu::GpuIndexBinaryFlat::copyFrom | ( | const faiss::IndexBinaryFlat * | index | ) |

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

Definition at line 71 of file GpuIndexBinaryFlat.cu.

void faiss::gpu::GpuIndexBinaryFlat::copyTo | ( | faiss::IndexBinaryFlat * | index | ) | const

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

Definition at line 99 of file GpuIndexBinaryFlat.cu.

void faiss::gpu::GpuIndexBinaryFlat::reconstruct | ( | faiss::IndexBinary::idx_t | key,
|  | uint8_t * | recons
| ) |  | const
| override virtual

Reconstruct a stored vector.

This function may not be defined for some indexes.

Parameters

  key | id of the vector to reconstruct
  recons | reconstucted vector (size d / 8)

Reimplemented from faiss::IndexBinary.

Definition at line 282 of file GpuIndexBinaryFlat.cu.

void faiss::gpu::GpuIndexBinaryFlat::search | ( | faiss::IndexBinary::idx_t | n,
|  | const uint8_t * | x,
|  | faiss::IndexBinary::idx_t | k,
|  | int32_t * | distances,
|  | faiss::IndexBinary::idx_t * | labels
| ) |  | const
| override virtual

Query n vectors of dimension d to the index.

return at most k vectors. If there are not enough results for a query, the result array is padded with -1s.

Parameters

  x | input vectors to search, size n * d / 8
  labels | output labels of the NNs, size n*k
  distances | output pairwise distances, size n*k

Implements faiss::IndexBinary.

Definition at line 148 of file GpuIndexBinaryFlat.cu.

void faiss::gpu::GpuIndexBinaryFlat::searchFromCpuPaged_ | ( | int | n,
|  | const uint8_t * | x,
|  | int | k,
|  | int32_t * | 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 253 of file GpuIndexBinaryFlat.cu.

## Member Data Documentation

BinaryFlatIndex* faiss::gpu::GpuIndexBinaryFlat::data_
| protected

Holds our GPU data containing the list of vectors; is managed via raw pointer so as to allow non-CUDA compilers to see this header

Definition at line 87 of file GpuIndexBinaryFlat.h.

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

- /tmp/faiss/gpu/GpuIndexBinaryFlat.h
- /tmp/faiss/gpu/GpuIndexBinaryFlat.cu