IVF Flat

View as Markdown

Source header: cuvs/neighbors/ivf_flat.hpp

IVF-Flat index search parameters

neighbors::ivf_flat::search_params

IVF-Flat index search parameters

1struct search_params : cuvs::neighbors::search_params {
2 uint32_t n_probes;
3 std::optional<std::string> metric_udf;
4};

Fields

NameTypeDescription
n_probesuint32_tThe number of clusters to search.
metric_udfstd::optional<std::string>Custom metric UDF code.

neighbors::ivf_flat::list_spec::make_list_extents

Determine the extents of an array enough to hold a given amount of data.

1constexpr auto make_list_extents(SizeT n_rows) const -> list_extents;

Parameters

NameDirectionTypeDescription
n_rowsSizeT

Returns

list_extents

IVF-Flat index

neighbors::ivf_flat::index

IVF-flat index.

1template <typename T, typename IdxT>
2struct index;

neighbors::ivf_flat::index::index

Construct an empty index.

1index(raft::resources const& res);

Constructs an empty index. This index will either need to be trained with build or loaded from a saved copy with deserialize

Parameters

NameDirectionTypeDescription
resraft::resources const&

Returns

void

Additional overload: neighbors::ivf_flat::index::index

Construct an empty index. It needs to be trained and then populated.

1index(raft::resources const& res, const index_params& params, uint32_t dim);

Parameters

NameDirectionTypeDescription
resraft::resources const&
paramsconst index_params&
dimuint32_t

Returns

void

Additional overload: neighbors::ivf_flat::index::index

Construct an empty index. It needs to be trained and then populated.

1index(raft::resources const& res,
2cuvs::distance::DistanceType metric,
3uint32_t n_lists,
4bool adaptive_centers,
5bool conservative_memory_allocation,
6uint32_t dim);

Parameters

NameDirectionTypeDescription
resraft::resources const&
metriccuvs::distance::DistanceType
n_listsuint32_t
adaptive_centersbool
conservative_memory_allocationbool
dimuint32_t

Returns

void

neighbors::ivf_flat::index::veclen

Vectorized load/store size in elements, determines the size of interleaved data chunks.

1uint32_t veclen() const noexcept;

Returns

uint32_t

neighbors::ivf_flat::index::metric

Distance metric used for clustering.

1cuvs::distance::DistanceType metric() const noexcept;

Returns

cuvs::distance::DistanceType

neighbors::ivf_flat::index::adaptive_centers

Whether centers() change upon extending the index (ivf_flat::extend).

1bool adaptive_centers() const noexcept;

Returns

bool

neighbors::ivf_flat::index::list_sizes

Sizes of the lists (clusters) [n_lists]

1raft::device_vector_view<uint32_t, uint32_t> list_sizes() noexcept;

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]

1raft::device_matrix_view<float, uint32_t, raft::row_major> centers() noexcept;

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].

1std::optional<raft::device_vector_view<float, uint32_t>> center_norms() noexcept;

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].

1auto accum_sorted_sizes() noexcept -> raft::host_vector_view<IdxT, uint32_t>;

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.

1IdxT size() const noexcept;

Returns

IdxT

neighbors::ivf_flat::index::dim

Dimensionality of the data.

1uint32_t dim() const noexcept;

Returns

uint32_t

neighbors::ivf_flat::index::n_lists

Number of clusters/inverted lists.

1uint32_t n_lists() const noexcept;

Returns

uint32_t

neighbors::ivf_flat::index::inds_ptrs

Pointers to the inverted lists (clusters) indices [n_lists].

1raft::device_vector_view<IdxT*, uint32_t> inds_ptrs() noexcept;

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

1bool conservative_memory_allocation() const noexcept;

(see index_params.conservative_memory_allocation).

Returns

bool

neighbors::ivf_flat::index::lists

Lists’ data and indices.

1std::vector<std::shared_ptr<list_data<T, IdxT>>>& lists() noexcept;

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.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const float, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<float, int64_t>;

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const float, int64_t, raft::row_major>a device pointer to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::ivf_flat::index<float, int64_t>

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const float, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<float, int64_t>& idx);

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const float, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<float, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const half, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<half, int64_t>;

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const half, int64_t, raft::row_major>a device pointer to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::ivf_flat::index<half, int64_t>

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const half, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<half, int64_t>& idx);

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const half, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<half, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const int8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<int8_t, int64_t>;

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>a device pointer to a row-major matrix [n_rows, dim]

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.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const int8_t, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& idx);

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<int8_t, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>;

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>a device pointer to a row-major matrix [n_rows, dim]

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.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& idx);

NB: Currently, the following distance metrics are supported:

  • L2Expanded
  • L2Unexpanded
  • InnerProduct
  • CosineExpanded

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const float, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<float, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const float, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::ivf_flat::index<float, int64_t>

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const float, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<float, int64_t>& idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const float, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<float, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const half, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<half, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const half, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]

Returns

cuvs::neighbors::ivf_flat::index<half, int64_t>

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const half, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<half, int64_t>& idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const half, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<half, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const int8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<int8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>a host pointer to a row-major matrix [n_rows, dim]

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.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const int8_t, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<int8_t, int64_t>&reference to ivf_flat::index

Returns

void

Additional overload: neighbors::ivf_flat::build

Build the index from the dataset for efficient search.

1auto build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> dataset)
4-> cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>a host pointer to a row-major matrix [n_rows, dim]

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.

1void build(raft::resources const& handle,
2const cuvs::neighbors::ivf_flat::index_params& index_params,
3raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> dataset,
4cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
index_paramsinconst cuvs::neighbors::ivf_flat::index_params&configure the index building
datasetinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, dim]
idxoutcuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&reference to ivf_flat::index

Returns

void

IVF-Flat index extend

neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::device_matrix_view<const float, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<float, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<float, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const float, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<float, int64_t>&original index

Returns

cuvs::neighbors::ivf_flat::index<float, int64_t>

Additional overload: neighbors::ivf_flat::extend

Extend the index in-place with the new data.

1void extend(raft::resources const& handle,
2raft::device_matrix_view<const float, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<float, int64_t>* idx);

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const float, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<float, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::device_matrix_view<const half, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<half, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<half, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const half, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<half, int64_t>&original index

Returns

cuvs::neighbors::ivf_flat::index<half, int64_t>

Additional overload: neighbors::ivf_flat::extend

Extend the index in-place with the new data.

1void extend(raft::resources const& handle,
2raft::device_matrix_view<const half, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<half, int64_t>* idx);

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const half, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<half, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::device_matrix_view<const int8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<int8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<int8_t, int64_t>&original index

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.

1void extend(raft::resources const& handle,
2raft::device_matrix_view<const int8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<int8_t, int64_t>* idx);

Usage example:

If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const int8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows].
idxinoutcuvs::neighbors::ivf_flat::index<int8_t, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&original index

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.

1void extend(raft::resources const& handle,
2raft::device_matrix_view<const uint8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::device_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>* idx);

Usage example:

Parameters

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::device_matrix_view<const uint8_t, int64_t, raft::row_major>raft::device_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::device_vector_view<const int64_t, int64_t>>optional raft::device_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<uint8_t, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::host_matrix_view<const float, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<float, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<float, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const float, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<float, int64_t>&original index

Returns

cuvs::neighbors::ivf_flat::index<float, int64_t>

Additional overload: neighbors::ivf_flat::extend

Extend the index in-place with the new data.

1void extend(raft::resources const& handle,
2raft::host_matrix_view<const float, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<float, int64_t>* idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const float, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<float, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::host_matrix_view<const half, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<half, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<half, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const half, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<half, int64_t>&original index

Returns

cuvs::neighbors::ivf_flat::index<half, int64_t>

Additional overload: neighbors::ivf_flat::extend

Extend the index in-place with the new data.

1void extend(raft::resources const& handle,
2raft::host_matrix_view<const half, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<half, int64_t>* idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const half, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<half, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::host_matrix_view<const int8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<int8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<int8_t, int64_t>&original index

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.

1void extend(raft::resources const& handle,
2raft::host_matrix_view<const int8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<int8_t, int64_t>* idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const int8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<int8_t, int64_t>*pointer to index, to be overwritten in-place

Returns

void

Additional overload: neighbors::ivf_flat::extend

Build a new index containing the data of the original plus new extra vectors.

1auto extend(raft::resources const& handle,
2raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4const cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& idx)
5-> cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>;

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinconst cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&original index

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.

1void extend(raft::resources const& handle,
2raft::host_matrix_view<const uint8_t, int64_t, raft::row_major> new_vectors,
3std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices,
4cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>* idx);

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

NameDirectionTypeDescription
handleinraft::resources const&
new_vectorsinraft::host_matrix_view<const uint8_t, int64_t, raft::row_major>raft::host_matrix_view to a row-major matrix [n_rows, index.dim()]
new_indicesinstd::optional<raft::host_vector_view<const int64_t, int64_t>>optional raft::host_vector_view to a vector of indices [n_rows]. If the original index is empty (orig_index.size() == 0), you can pass std::nullopt here to imply a continuous range [0...n_rows).
idxinoutcuvs::neighbors::ivf_flat::index<uint8_t, int64_t>*pointer to index, to be overwritten in-place

Returns

void

IVF-Flat index serialize

neighbors::ivf_flat::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::ivf_flat::index<float, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::ivf_flat::index<float, int64_t>&IVF-Flat index

Returns

void

neighbors::ivf_flat::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::ivf_flat::index<float, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexincuvs::neighbors::ivf_flat::index<float, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::ivf_flat::index<float, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::ivf_flat::index<float, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::ivf_flat::index<float, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexincuvs::neighbors::ivf_flat::index<float, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::ivf_flat::index<half, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::ivf_flat::index<half, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::ivf_flat::index<half, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexincuvs::neighbors::ivf_flat::index<half, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::ivf_flat::index<half, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::ivf_flat::index<half, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::ivf_flat::index<half, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexincuvs::neighbors::ivf_flat::index<half, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::ivf_flat::index<int8_t, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::ivf_flat::index<int8_t, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexincuvs::neighbors::ivf_flat::index<int8_t, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::ivf_flat::index<int8_t, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::ivf_flat::index<int8_t, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::ivf_flat::index<int8_t, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexincuvs::neighbors::ivf_flat::index<int8_t, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Save the index to file.

1void serialize(raft::resources const& handle,
2const std::string& filename,
3const cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the file name for saving the index
indexinconst cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from file.

1void deserialize(raft::resources const& handle,
2const std::string& filename,
3cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
filenameinconst std::string&the name of the file that stores the index
indexincuvs::neighbors::ivf_flat::index<uint8_t, int64_t>*IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::serialize

Write the index to an output stream

1void serialize(raft::resources const& handle,
2std::ostream& os,
3const cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>& index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
osinstd::ostream&output stream
indexinconst cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>&IVF-Flat index

Returns

void

Additional overload: neighbors::ivf_flat::deserialize

Load index from input stream

1void deserialize(raft::resources const& handle,
2std::istream& is,
3cuvs::neighbors::ivf_flat::index<uint8_t, int64_t>* index);

Experimental, both the API and the serialization format are subject to change.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&the raft handle
isinstd::istream&input stream
indexincuvs::neighbors::ivf_flat::index<uint8_t, int64_t>*IVF-Flat index

Returns

void

Helper functions for IVF Flat

neighbors::ivf_flat::helpers::codepacker::pack

Write flat codes into an existing list by the given offset.

1void pack(raft::resources const& res,
2raft::device_matrix_view<const float, uint32_t, raft::row_major> codes,
3uint32_t veclen,
4uint32_t offset,
5raft::device_mdspan<float,
6typename list_spec<uint32_t, float, int64_t>::list_extents,
7raft::row_major> list_data);

NB: no memory allocation happens here; the list must fit the data (offset + n_vec).

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
codesinraft::device_matrix_view<const float, uint32_t, raft::row_major>flat codes [n_vec, dim]
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list
list_datainoutraft::device_mdspan<float, typename list_spec<uint32_t, float, int64_t>::list_extents, raft::row_major>block to write into

Returns

void

Additional overload: neighbors::ivf_flat::helpers::codepacker::pack

Write flat codes into an existing list by the given offset.

1void pack(raft::resources const& res,
2raft::device_matrix_view<const half, uint32_t, raft::row_major> codes,
3uint32_t veclen,
4uint32_t offset,
5raft::device_mdspan<half,
6typename list_spec<uint32_t, half, int64_t>::list_extents,
7raft::row_major> list_data);

NB: no memory allocation happens here; the list must fit the data (offset + n_vec).

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
codesinraft::device_matrix_view<const half, uint32_t, raft::row_major>flat codes [n_vec, dim]
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list
list_datainoutraft::device_mdspan<half, typename list_spec<uint32_t, half, int64_t>::list_extents, raft::row_major>block to write into

Returns

void

Additional overload: neighbors::ivf_flat::helpers::codepacker::pack

Write flat codes into an existing list by the given offset.

1void pack(raft::resources const& res,
2raft::device_matrix_view<const int8_t, uint32_t, raft::row_major> codes,
3uint32_t veclen,
4uint32_t offset,
5raft::device_mdspan<int8_t,
6typename list_spec<uint32_t, int8_t, int64_t>::list_extents,
7raft::row_major> list_data);

NB: no memory allocation happens here; the list must fit the data (offset + n_vec).

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
codesinraft::device_matrix_view<const int8_t, uint32_t, raft::row_major>flat codes [n_vec, dim]
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list
list_datainoutraft::device_mdspan<int8_t, typename list_spec<uint32_t, int8_t, int64_t>::list_extents, raft::row_major>block to write into

Returns

void

Additional overload: neighbors::ivf_flat::helpers::codepacker::pack

Write flat codes into an existing list by the given offset.

1void pack(raft::resources const& res,
2raft::device_matrix_view<const uint8_t, uint32_t, raft::row_major> codes,
3uint32_t veclen,
4uint32_t offset,
5raft::device_mdspan<uint8_t,
6typename list_spec<uint32_t, uint8_t, int64_t>::list_extents,
7raft::row_major> list_data);

NB: no memory allocation happens here; the list must fit the data (offset + n_vec).

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&
codesinraft::device_matrix_view<const uint8_t, uint32_t, raft::row_major>flat codes [n_vec, dim]
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list
list_datainoutraft::device_mdspan<uint8_t, typename list_spec<uint32_t, uint8_t, int64_t>::list_extents, raft::row_major>block to write into

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.

1void unpack(raft::resources const& res,
2raft::device_mdspan<const float,
3typename list_spec<uint32_t, float, int64_t>::list_extents,
4raft::row_major> list_data,
5uint32_t veclen,
6uint32_t offset,
7raft::device_matrix_view<float, uint32_t, raft::row_major> codes);

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resource
list_datainraft::device_mdspan<const float, typename list_spec<uint32_t, float, int64_t>::list_extents, raft::row_major>block to read from
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tHow many records in the list to skip.
codesinoutraft::device_matrix_view<float, uint32_t, raft::row_major>the destination buffer [n_take, index.dim()]. The length n_take defines how many records to unpack, it must be <= the list size.

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.

1void unpack(raft::resources const& res,
2raft::device_mdspan<const half,
3typename list_spec<uint32_t, half, int64_t>::list_extents,
4raft::row_major> list_data,
5uint32_t veclen,
6uint32_t offset,
7raft::device_matrix_view<half, uint32_t, raft::row_major> codes);

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resource
list_datainraft::device_mdspan<const half, typename list_spec<uint32_t, half, int64_t>::list_extents, raft::row_major>block to read from
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tHow many records in the list to skip.
codesinoutraft::device_matrix_view<half, uint32_t, raft::row_major>the destination buffer [n_take, index.dim()]. The length n_take defines how many records to unpack, it must be <= the list size.

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.

1void unpack(raft::resources const& res,
2raft::device_mdspan<const int8_t,
3typename list_spec<uint32_t, int8_t, int64_t>::list_extents,
4raft::row_major> list_data,
5uint32_t veclen,
6uint32_t offset,
7raft::device_matrix_view<int8_t, uint32_t, raft::row_major> codes);

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resource
list_datainraft::device_mdspan<const int8_t, typename list_spec<uint32_t, int8_t, int64_t>::list_extents, raft::row_major>block to read from
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tHow many records in the list to skip.
codesinoutraft::device_matrix_view<int8_t, uint32_t, raft::row_major>the destination buffer [n_take, index.dim()]. The length n_take defines how many records to unpack, it must be <= the list size.

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.

1void unpack(raft::resources const& res,
2raft::device_mdspan<const uint8_t,
3typename list_spec<uint32_t, uint8_t, int64_t>::list_extents,
4raft::row_major> list_data,
5uint32_t veclen,
6uint32_t offset,
7raft::device_matrix_view<uint8_t, uint32_t, raft::row_major> codes);

Usage example:

Parameters

NameDirectionTypeDescription
resinraft::resources const&raft resource
list_datainraft::device_mdspan<const uint8_t, typename list_spec<uint32_t, uint8_t, int64_t>::list_extents, raft::row_major>block to read from
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tHow many records in the list to skip.
codesinoutraft::device_matrix_view<uint8_t, uint32_t, raft::row_major>the destination buffer [n_take, index.dim()]. The length n_take defines how many records to unpack, it must be <= the list size.

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

1void pack_1(const float* flat_code, float* block, uint32_t dim, uint32_t veclen, uint32_t offset);

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

NameDirectionTypeDescription
flat_codeinconst float*input flat code
blockoutfloat*block of memory to write interleaved codes to
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list

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

1void pack_1(const half* flat_code, half* block, uint32_t dim, uint32_t veclen, uint32_t offset);

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

NameDirectionTypeDescription
flat_codeinconst half*input flat code
blockouthalf*block of memory to write interleaved codes to
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list

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

1void pack_1(const int8_t* flat_code, int8_t* block, uint32_t dim, uint32_t veclen, uint32_t offset);

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

NameDirectionTypeDescription
flat_codeinconst int8_t*input flat code
blockoutint8_t*block of memory to write interleaved codes to
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list

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

1void pack_1(
2const uint8_t* flat_code, uint8_t* block, uint32_t dim, uint32_t veclen, uint32_t offset);

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

NameDirectionTypeDescription
flat_codeinconst uint8_t*input flat code
blockoutuint8_t*block of memory to write interleaved codes to
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_thow many records to skip before writing the data into the list

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

1void unpack_1(const float* block, float* flat_code, uint32_t dim, uint32_t veclen, uint32_t offset);

indicates the id of the record. This function fetches one flat code from an interleaved code.

Parameters

NameDirectionTypeDescription
blockinconst float*interleaved block. The block can be thought of as the whole inverted list in interleaved format.
flat_codeoutfloat*output flat code
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tfetch the flat code by the given offset

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

1void unpack_1(const half* block, half* flat_code, uint32_t dim, uint32_t veclen, uint32_t offset);

indicates the id of the record. This function fetches one flat code from an interleaved code.

Parameters

NameDirectionTypeDescription
blockinconst half*interleaved block. The block can be thought of as the whole inverted list in interleaved format.
flat_codeouthalf*output flat code
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tfetch the flat code by the given offset

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

1void unpack_1(
2const int8_t* block, int8_t* flat_code, uint32_t dim, uint32_t veclen, uint32_t offset);

indicates the id of the record. This function fetches one flat code from an interleaved code.

Parameters

NameDirectionTypeDescription
blockinconst int8_t*interleaved block. The block can be thought of as the whole inverted list in interleaved format.
flat_codeoutint8_t*output flat code
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tfetch the flat code by the given offset

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

1void unpack_1(
2const uint8_t* block, uint8_t* flat_code, uint32_t dim, uint32_t veclen, uint32_t offset);

indicates the id of the record. This function fetches one flat code from an interleaved code.

Parameters

NameDirectionTypeDescription
blockinconst uint8_t*interleaved block. The block can be thought of as the whole inverted list in interleaved format.
flat_codeoutuint8_t*output flat code
diminuint32_tdimension of the flat code
vecleninuint32_tsize of interleaved data chunks
offsetinuint32_tfetch the flat code by the given offset

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.

1void reset_index(const raft::resources& res, index<float, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<float, int64_t>*pointer to IVF-Flat index

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.

1void reset_index(const raft::resources& res, index<half, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<half, int64_t>*pointer to IVF-Flat index

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.

1void reset_index(const raft::resources& res, index<int8_t, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<int8_t, int64_t>*pointer to IVF-Flat index

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.

1void reset_index(const raft::resources& res, index<uint8_t, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<uint8_t, int64_t>*pointer to IVF-Flat index

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.

1void recompute_internal_state(const raft::resources& res, index<float, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<float, int64_t>*pointer to IVF-Flat index

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.

1void recompute_internal_state(const raft::resources& res, index<half, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<half, int64_t>*pointer to IVF-Flat index

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.

1void recompute_internal_state(const raft::resources& res, index<int8_t, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<int8_t, int64_t>*pointer to IVF-Flat index

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.

1void recompute_internal_state(const raft::resources& res, index<uint8_t, int64_t>* index);

Usage example:

Parameters

NameDirectionTypeDescription
resinconst raft::resources&raft resource
indexinoutindex<uint8_t, int64_t>*pointer to IVF-Flat index

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

1template <typename T, typename AccT, int Veclen>
2struct point {
3 static constexpr int veclen;
4 storage_type data_;
5};

Fields

NameTypeDescription
veclenstatic constexpr int
data_storage_type

neighbors::ivf_flat::experimental::udf::metric_interface

Base interface for custom distance metrics.

1template <typename T, typename AccT, int Veclen = 1>
2struct metric_interface;