From 9841e6c62c4cb2ca5b2a944234b828e79b76f179 Mon Sep 17 00:00:00 2001 From: Tarang Jain Date: Thu, 16 Nov 2023 17:19:57 -0800 Subject: [PATCH] move get_list_size to index struct --- cpp/include/raft/neighbors/ivf_pq_helpers.cuh | 30 ------------------- cpp/include/raft/neighbors/ivf_pq_types.hpp | 24 +++++++++++++++ 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/cpp/include/raft/neighbors/ivf_pq_helpers.cuh b/cpp/include/raft/neighbors/ivf_pq_helpers.cuh index 8f467cde9a..fec31f1c61 100644 --- a/cpp/include/raft/neighbors/ivf_pq_helpers.cuh +++ b/cpp/include/raft/neighbors/ivf_pq_helpers.cuh @@ -713,36 +713,6 @@ void set_centers(raft::resources const& res, ivf_pq::detail::set_centers(res, index, cluster_centers.data_handle()); } -/** - * @brief Helper to fetch size of a particular IVF list in bytes using the list extents. - * - * Usage example: - * @code{.cpp} - * raft::resources res; - * // use default index params - * ivf_pq::index_params index_params; - * // extend the IVF lists while building the index - * index_params.add_data_on_build = true; - * // create and fill the index from a [N, D] dataset - * auto index = raft::neighbors::ivf_pq::build(res, index_params, dataset, N, D); - * // Fetch the size of the fourth list - * uint32_t size = raft::neighbors::ivf_pq::helpers::get_list_size_in_bytes(index, 3); - * @endcode - * - * @tparam IdxT - * - * @param[in] index IVF-PQ index (passed by reference) - * @param[in] label list ID - */ -template -auto get_list_size_in_bytes(const index& index, uint32_t label) -> uint32_t -{ - RAFT_EXPECTS(label < index.n_lists(), - "Expected label to be less than number of lists in the index"); - auto list_data = index.lists()[label]->data; - return list_data.size(); -} - /** * @brief Helper exposing the re-computation of list sizes and related arrays if IVF lists have been * modified. diff --git a/cpp/include/raft/neighbors/ivf_pq_types.hpp b/cpp/include/raft/neighbors/ivf_pq_types.hpp index 24df77b35a..45ab18c84f 100644 --- a/cpp/include/raft/neighbors/ivf_pq_types.hpp +++ b/cpp/include/raft/neighbors/ivf_pq_types.hpp @@ -487,6 +487,30 @@ struct index : ann::index { return centers_rot_.view(); } + /** fetch size of a particular IVF list in bytes using the list extents. + * Usage example: + * @code{.cpp} + * raft::resources res; + * // use default index params + * ivf_pq::index_params index_params; + * // extend the IVF lists while building the index + * index_params.add_data_on_build = true; + * // create and fill the index from a [N, D] dataset + * auto index = raft::neighbors::ivf_pq::build(res, index_params, dataset, N, D); + * // Fetch the size of the fourth list + * uint32_t size = index.get_list_size_in_bytes(3); + * @endcode + * + * @param[in] label list ID + */ + inline auto get_list_size_in_bytes(uint32_t label) -> uint32_t + { + RAFT_EXPECTS(label < this->n_lists(), + "Expected label to be less than number of lists in the index"); + auto list_data = this->lists()[label]->data; + return list_data.size(); + } + private: raft::distance::DistanceType metric_; codebook_gen codebook_kind_;