IVF Flat
Source header: cuvs/neighbors/ivf_flat.hpp
IVF-Flat index search parameters
neighbors::ivf_flat::search_params
IVF-Flat index search parameters
Fields
neighbors::ivf_flat::list_spec::make_list_extents
Determine the extents of an array enough to hold a given amount of data.
Parameters
Returns
IVF-Flat index
neighbors::ivf_flat::index
IVF-flat index.
neighbors::ivf_flat::index::index
Construct an empty index.
Constructs an empty index. This index will either need to be trained with build or loaded from a saved copy with deserialize
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::index::index
Construct an empty index. It needs to be trained and then populated.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::index::index
Construct an empty index. It needs to be trained and then populated.
Parameters
Returns
void
neighbors::ivf_flat::index::veclen
Vectorized load/store size in elements, determines the size of interleaved data chunks.
Returns
uint32_t
neighbors::ivf_flat::index::metric
Distance metric used for clustering.
Returns
neighbors::ivf_flat::index::adaptive_centers
Whether centers() change upon extending the index (ivf_flat::extend).
Returns
bool
neighbors::ivf_flat::index::list_sizes
Sizes of the lists (clusters) [n_lists]
NB: This may differ from the actual list size if the shared lists have been extended by another index
Returns
raft::device_vector_view<uint32_t, uint32_t>
neighbors::ivf_flat::index::centers
k-means cluster centers corresponding to the lists [n_lists, dim]
Returns
raft::device_matrix_view<float, uint32_t, raft::row_major>
neighbors::ivf_flat::index::center_norms
(Optional) Precomputed norms of the centers w.r.t. the chosen distance metric [n_lists].
NB: this may be empty if the index is empty or if the metric does not require the center norms calculation.
Returns
std::optional<raft::device_vector_view<float, uint32_t>>
neighbors::ivf_flat::index::accum_sorted_sizes
Accumulated list sizes, sorted in descending order [n_lists + 1].
The last value contains the total length of the index. The value at index zero is always zero.
That is, the content of this span is as if the list_sizes was sorted and then accumulated.
This span is used during search to estimate the maximum size of the workspace.
Returns
raft::host_vector_view<IdxT, uint32_t>
neighbors::ivf_flat::index::size
Total length of the index.
Returns
IdxT
neighbors::ivf_flat::index::dim
Dimensionality of the data.
Returns
uint32_t
neighbors::ivf_flat::index::n_lists
Number of clusters/inverted lists.
Returns
uint32_t
neighbors::ivf_flat::index::inds_ptrs
Pointers to the inverted lists (clusters) indices [n_lists].
Returns
raft::device_vector_view<IdxT*, uint32_t>
neighbors::ivf_flat::index::conservative_memory_allocation
Whether to use conservative memory allocation when extending the list (cluster) data
(see index_params.conservative_memory_allocation).
Returns
bool
neighbors::ivf_flat::index::lists
Lists’ data and indices.
Returns
std::vector<std::shared_ptr<list_data<T, IdxT>>>&
IVF-Flat index build
neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<float, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<half, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<int8_t, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<float, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<half, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<int8_t, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>
Additional overload: neighbors::ivf_flat::build
Build the index from the dataset for efficient search.
NB: Currently, the following distance metrics are supported:
- L2Expanded
- L2Unexpanded
- InnerProduct
- CosineExpanded
Note, if index_params.add_data_on_build is set to true, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
IVF-Flat index extend
neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<float, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<half, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<int8_t, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<float, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<half, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<int8_t, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::extend
Build a new index containing the data of the original plus new extra vectors.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Implementation note: The new data is clustered according to existing kmeans clusters, then the cluster centers are adjusted to match the newly labeled data.
Usage example:
Parameters
Returns
cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>
Additional overload: neighbors::ivf_flat::extend
Extend the index in-place with the new data.
Note, the user can set a stream pool in the input raft::resource with at least one stream to enable kernel and copy overlapping.
Usage example:
Parameters
Returns
void
IVF-Flat index serialize
neighbors::ivf_flat::serialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
neighbors::ivf_flat::deserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Write the index to an output stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from input stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Write the index to an output stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from input stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Write the index to an output stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from input stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Save the index to file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from file.
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::serialize
Write the index to an output stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::deserialize
Load index from input stream
Experimental, both the API and the serialization format are subject to change.
Parameters
Returns
void
Helper functions for IVF Flat
neighbors::ivf_flat::helpers::codepacker::pack
Write flat codes into an existing list by the given offset.
NB: no memory allocation happens here; the list must fit the data (offset + n_vec).
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack
Write flat codes into an existing list by the given offset.
NB: no memory allocation happens here; the list must fit the data (offset + n_vec).
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack
Write flat codes into an existing list by the given offset.
NB: no memory allocation happens here; the list must fit the data (offset + n_vec).
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack
Write flat codes into an existing list by the given offset.
NB: no memory allocation happens here; the list must fit the data (offset + n_vec).
Usage example:
Parameters
Returns
void
neighbors::ivf_flat::helpers::codepacker::unpack
Unpack n_take consecutive records of a single list (cluster) in the compressed index
starting at given offset.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack
Unpack n_take consecutive records of a single list (cluster) in the compressed index
starting at given offset.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack
Unpack n_take consecutive records of a single list (cluster) in the compressed index
starting at given offset.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack
Unpack n_take consecutive records of a single list (cluster) in the compressed index
starting at given offset.
Usage example:
Parameters
Returns
void
neighbors::ivf_flat::helpers::codepacker::pack_1
Write one flat code into a block by the given offset. The offset indicates the id of the record
in the list. This function interleaves the code and is intended to later copy the interleaved codes over to the IVF list on device. NB: no memory allocation happens here; the block must fit the record (offset + 1).
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack_1
Write one flat code into a block by the given offset. The offset indicates the id of the record
in the list. This function interleaves the code and is intended to later copy the interleaved codes over to the IVF list on device. NB: no memory allocation happens here; the block must fit the record (offset + 1).
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack_1
Write one flat code into a block by the given offset. The offset indicates the id of the record
in the list. This function interleaves the code and is intended to later copy the interleaved codes over to the IVF list on device. NB: no memory allocation happens here; the block must fit the record (offset + 1).
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::pack_1
Write one flat code into a block by the given offset. The offset indicates the id of the record
in the list. This function interleaves the code and is intended to later copy the interleaved codes over to the IVF list on device. NB: no memory allocation happens here; the block must fit the record (offset + 1).
Parameters
Returns
void
neighbors::ivf_flat::helpers::codepacker::unpack_1
Unpack 1 record of a single list (cluster) in the index to fetch the flat code. The offset
indicates the id of the record. This function fetches one flat code from an interleaved code.
interleaved format.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack_1
Unpack 1 record of a single list (cluster) in the index to fetch the flat code. The offset
indicates the id of the record. This function fetches one flat code from an interleaved code.
interleaved format.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack_1
Unpack 1 record of a single list (cluster) in the index to fetch the flat code. The offset
indicates the id of the record. This function fetches one flat code from an interleaved code.
interleaved format.
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::codepacker::unpack_1
Unpack 1 record of a single list (cluster) in the index to fetch the flat code. The offset
indicates the id of the record. This function fetches one flat code from an interleaved code.
interleaved format.
Parameters
Returns
void
neighbors::ivf_flat::helpers::reset_index
Public helper API to reset the data and indices ptrs, and the list sizes. Useful for
externally modifying the index without going through the build stage. The data and indices of the IVF lists will be lost.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::reset_index
Public helper API to reset the data and indices ptrs, and the list sizes. Useful for
externally modifying the index without going through the build stage. The data and indices of the IVF lists will be lost.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::reset_index
Public helper API to reset the data and indices ptrs, and the list sizes. Useful for
externally modifying the index without going through the build stage. The data and indices of the IVF lists will be lost.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::reset_index
Public helper API to reset the data and indices ptrs, and the list sizes. Useful for
externally modifying the index without going through the build stage. The data and indices of the IVF lists will be lost.
Usage example:
Parameters
Returns
void
neighbors::ivf_flat::helpers::recompute_internal_state
Helper exposing the re-computation of list sizes and related arrays if IVF lists have been
modified externally.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::recompute_internal_state
Helper exposing the re-computation of list sizes and related arrays if IVF lists have been
modified externally.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::recompute_internal_state
Helper exposing the re-computation of list sizes and related arrays if IVF lists have been
modified externally.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::ivf_flat::helpers::recompute_internal_state
Helper exposing the re-computation of list sizes and related arrays if IVF lists have been
modified externally.
Usage example:
Parameters
Returns
void
Types
neighbors::ivf_flat::experimental::udf::point
Wrapper for vector elements that provides both packed and unpacked access.
For float: trivial wrapper around scalar values For int8/uint8 with Veclen > 1: wraps packed bytes in a 32-bit word
Fields
neighbors::ivf_flat::experimental::udf::metric_interface
Base interface for custom distance metrics.