Struct faiss::index::gpu::GpuIndexImpl
source · pub struct GpuIndexImpl<'gpu, I> { /* private fields */ }
Expand description
Native GPU implementation of a Faiss index. GPU indexes in Faiss are first
built on the CPU, and subsequently transferred to one or more GPU’s via the
into_gpu
or to_gpu
methods. Calling into_cpu
(or to_cpu
)
enables the user to bring the index back to CPU memory.
When using to_gpu
or to_cpu
, the indexes will contain the same
indexed vectors, but are independent at the point of creation. The use of
into_gpu
or into_cpu
isn’t necessarily faster, but will automatically
free the originating index.
The 'gpu
lifetime ensures that the GPU resources are in scope for as
long as the index lives.
Implementations§
source§impl<'gpu, I> GpuIndexImpl<'gpu, I>where
I: NativeIndex,
I: FromInnerPtr,
impl<'gpu, I> GpuIndexImpl<'gpu, I>where
I: NativeIndex,
I: FromInnerPtr,
Trait Implementations§
source§impl<'gpu, I: Debug> Debug for GpuIndexImpl<'gpu, I>
impl<'gpu, I: Debug> Debug for GpuIndexImpl<'gpu, I>
source§impl<'g, I> Drop for GpuIndexImpl<'g, I>
impl<'g, I> Drop for GpuIndexImpl<'g, I>
source§impl<'gpu, I> Index for GpuIndexImpl<'gpu, I>where
I: Index,
impl<'gpu, I> Index for GpuIndexImpl<'gpu, I>where
I: Index,
source§fn is_trained(&self) -> bool
fn is_trained(&self) -> bool
Whether the Index does not require training, or if training is done already
source§fn metric_type(&self) -> MetricType
fn metric_type(&self) -> MetricType
The metric type assumed by the index
source§fn add(&mut self, x: &[f32]) -> Result<()>
fn add(&mut self, x: &[f32]) -> Result<()>
Add new data vectors to the index.
This assumes a C-contiguous memory slice of vectors, where the total
number of vectors is
x.len() / d
. Read moresource§fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>
fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>
Add new data vectors to the index with IDs.
This assumes a C-contiguous memory slice of vectors, where the total
number of vectors is
x.len() / d
.
Not all index types may support this operation. Read moresource§fn assign(&mut self, query: &[f32], k: usize) -> Result<AssignSearchResult>
fn assign(&mut self, query: &[f32], k: usize) -> Result<AssignSearchResult>
Similar to
search
, but only provides the labels.source§fn search(&mut self, query: &[f32], k: usize) -> Result<SearchResult>
fn search(&mut self, query: &[f32], k: usize) -> Result<SearchResult>
Perform a search for the
k
closest vectors to the given query vectors.source§fn range_search(
&mut self,
query: &[f32],
radius: f32
) -> Result<RangeSearchResult>
fn range_search(
&mut self,
query: &[f32],
radius: f32
) -> Result<RangeSearchResult>
Perform a ranged search for the vectors closest to the given query vectors
by the given radius. Read more
source§fn remove_ids(&mut self, sel: &IdSelector) -> Result<i64>
fn remove_ids(&mut self, sel: &IdSelector) -> Result<i64>
Remove data vectors represented by IDs.
source§impl<'g, I> NativeIndex for GpuIndexImpl<'g, I>where
I: NativeIndex,
impl<'g, I> NativeIndex for GpuIndexImpl<'g, I>where
I: NativeIndex,
source§fn inner_ptr(&self) -> *mut FaissIndex
fn inner_ptr(&self) -> *mut FaissIndex
Retrieve a pointer to the native index object.