Skip to content

Commit

Permalink
Fixing deprecationsy
Browse files Browse the repository at this point in the history
  • Loading branch information
cjnolet committed Sep 24, 2024
1 parent a40ac62 commit 8ddcd3e
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 246 deletions.
126 changes: 64 additions & 62 deletions cpp/include/raft/cluster/kmeans.cuh

Large diffs are not rendered by default.

117 changes: 59 additions & 58 deletions cpp/include/raft/cluster/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,12 @@ namespace raft::cluster::kmeans_balanced {
* @param[in] mapping_op (optional) Functor to convert from the input datatype to the arithmetic
* datatype. If DataT == MathT, this must be the identity.
*/
[[deprecated("Use cuVS instead")]] template <typename DataT,
typename MathT,
typename IndexT,
typename MappingOpT = raft::identity_op>
void fit(const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
MappingOpT mapping_op = raft::identity_op())
template <typename DataT, typename MathT, typename IndexT, typename MappingOpT = raft::identity_op>
[[deprecated("Use cuVS instead")]] void fit(const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
MappingOpT mapping_op = raft::identity_op())
{
RAFT_EXPECTS(X.extent(1) == centroids.extent(1),
"Number of features in dataset and centroids are different");
Expand Down Expand Up @@ -129,17 +126,18 @@ void fit(const raft::resources& handle,
* @param[in] mapping_op (optional) Functor to convert from the input datatype to the arithmetic
* datatype. If DataT == MathT, this must be the identity.
*/
[[deprecated("Use cuVS instead")]] template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
void predict(const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<const MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
MappingOpT mapping_op = raft::identity_op())
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
[[deprecated("Use cuVS instead")]] void predict(
const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<const MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
MappingOpT mapping_op = raft::identity_op())
{
RAFT_EXPECTS(X.extent(0) == labels.extent(0),
"Number of rows in dataset and labels are different");
Expand Down Expand Up @@ -194,17 +192,18 @@ void predict(const raft::resources& handle,
* @param[in] mapping_op (optional) Functor to convert from the input datatype to the arithmetic
* datatype. If DataT and MathT are the same, this must be the identity.
*/
[[deprecated("Use cuVS instead")]] template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
void fit_predict(const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
MappingOpT mapping_op = raft::identity_op())
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
[[deprecated("Use cuVS instead")]] void fit_predict(
const raft::resources& handle,
kmeans_balanced_params const& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
MappingOpT mapping_op = raft::identity_op())
{
auto centroids_const = raft::make_device_matrix_view<const MathT, IndexT>(
centroids.data_handle(), centroids.extent(0), centroids.extent(1));
Expand Down Expand Up @@ -252,20 +251,21 @@ namespace helpers {
* arithmetic datatype. If DataT == MathT, this must be the identity.
* @param[in] X_norm (optional) Dataset's row norms [dim = n_samples]
*/
[[deprecated("Use cuVS instead")]] template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT>
void build_clusters(const raft::resources& handle,
const kmeans_balanced_params& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
raft::device_vector_view<CounterT, IndexT> cluster_sizes,
MappingOpT mapping_op = raft::identity_op(),
std::optional<raft::device_vector_view<const MathT>> X_norm = std::nullopt)
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT>
[[deprecated("Use cuVS instead")]] void build_clusters(
const raft::resources& handle,
const kmeans_balanced_params& params,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<LabelT, IndexT> labels,
raft::device_vector_view<CounterT, IndexT> cluster_sizes,
MappingOpT mapping_op = raft::identity_op(),
std::optional<raft::device_vector_view<const MathT>> X_norm = std::nullopt)
{
RAFT_EXPECTS(X.extent(0) == labels.extent(0),
"Number of rows in dataset and labels are different");
Expand Down Expand Up @@ -331,19 +331,20 @@ void build_clusters(const raft::resources& handle,
* @param[in] mapping_op (optional) Functor to convert from the input datatype to the
* arithmetic datatype. If DataT == MathT, this must be the identity.
*/
[[deprecated("Use cuVS instead")]] template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT = raft::identity_op>
void calc_centers_and_sizes(const raft::resources& handle,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_vector_view<const LabelT, IndexT> labels,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<CounterT, IndexT> cluster_sizes,
bool reset_counters = true,
MappingOpT mapping_op = raft::identity_op())
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT = raft::identity_op>
[[deprecated("Use cuVS instead")]] void calc_centers_and_sizes(
const raft::resources& handle,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_vector_view<const LabelT, IndexT> labels,
raft::device_matrix_view<MathT, IndexT> centroids,
raft::device_vector_view<CounterT, IndexT> cluster_sizes,
bool reset_counters = true,
MappingOpT mapping_op = raft::identity_op())
{
RAFT_EXPECTS(X.extent(0) == labels.extent(0),
"Number of rows in dataset and labels are different");
Expand Down
41 changes: 20 additions & 21 deletions cpp/include/raft/cluster/single_linkage.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ namespace raft::cluster {
* of k. The algorithm will set `k = log(n) + c`
* @param[in] n_clusters number of clusters to assign data samples
*/
[[deprecated("Use cuVS instead")]] template <typename value_idx,
typename value_t,
LinkageDistance dist_type = LinkageDistance::KNN_GRAPH>
void single_linkage(raft::resources const& handle,
const value_t* X,
size_t m,
size_t n,
raft::distance::DistanceType metric,
linkage_output<value_idx>* out,
int c,
size_t n_clusters)
template <typename value_idx,
typename value_t,
LinkageDistance dist_type = LinkageDistance::KNN_GRAPH>
[[deprecated("Use cuVS instead")]] void single_linkage(raft::resources const& handle,
const value_t* X,
size_t m,
size_t n,
raft::distance::DistanceType metric,
linkage_output<value_idx>* out,
int c,
size_t n_clusters)
{
detail::single_linkage<value_idx, value_t, dist_type>(
handle, X, m, n, metric, out, c, n_clusters);
Expand Down Expand Up @@ -86,16 +86,15 @@ constexpr int DEFAULT_CONST_C = 15;
* @param[in] c a constant used when constructing connectivities from knn graph. Allows the indirect
control of k. The algorithm will set `k = log(n) + c`
*/
[[deprecated("Use cuVS instead")]] template <typename value_t,
typename idx_t,
LinkageDistance dist_type = LinkageDistance::KNN_GRAPH>
void single_linkage(raft::resources const& handle,
raft::device_matrix_view<const value_t, idx_t, row_major> X,
raft::device_matrix_view<idx_t, idx_t, row_major> dendrogram,
raft::device_vector_view<idx_t, idx_t> labels,
raft::distance::DistanceType metric,
size_t n_clusters,
std::optional<int> c = std::make_optional<int>(DEFAULT_CONST_C))
template <typename value_t, typename idx_t, LinkageDistance dist_type = LinkageDistance::KNN_GRAPH>
[[deprecated("Use cuVS instead")]] void single_linkage(
raft::resources const& handle,
raft::device_matrix_view<const value_t, idx_t, row_major> X,
raft::device_matrix_view<idx_t, idx_t, row_major> dendrogram,
raft::device_vector_view<idx_t, idx_t> labels,
raft::distance::DistanceType metric,
size_t n_clusters,
std::optional<int> c = std::make_optional<int>(DEFAULT_CONST_C))
{
linkage_output<idx_t> out_arrs;
out_arrs.children = dendrogram.data_handle();
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/raft/cluster/single_linkage_types.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@ namespace raft::cluster::hierarchy {
/**
* Determines the method for computing the minimum spanning tree (MST)
*/
enum LinkageDistance {
[[deprecated("Use cuVS instead")]] enum LinkageDistance {

/**
* Use a pairwise distance matrix as input to the mst. This
Expand Down
25 changes: 13 additions & 12 deletions cpp/include/raft/neighbors/ball_cover_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ namespace raft::neighbors::ball_cover {
* @tparam value_t
* @tparam value_int
*/
[[deprecated("Use cuVS instead")]] template <typename value_idx,
typename value_t,
typename value_int = std::int64_t,
typename matrix_idx = std::int64_t>
template <typename value_idx,
typename value_t,
typename value_int = std::int64_t,
typename matrix_idx = std::int64_t>
class BallCoverIndex {
public:
explicit BallCoverIndex(raft::resources const& handle_,
const value_t* X_,
value_int m_,
value_int n_,
raft::distance::DistanceType metric_)
[[deprecated("Use cuVS instead")]] explicit BallCoverIndex(raft::resources const& handle_,
const value_t* X_,
value_int m_,
value_int n_,
raft::distance::DistanceType metric_)
: handle(handle_),
X(raft::make_device_matrix_view<const value_t, matrix_idx>(X_, m_, n_)),
m(m_),
Expand All @@ -75,9 +75,10 @@ class BallCoverIndex {
{
}

explicit BallCoverIndex(raft::resources const& handle_,
raft::device_matrix_view<const value_t, matrix_idx, row_major> X_,
raft::distance::DistanceType metric_)
[[deprecated("Use cuVS instead")]] explicit BallCoverIndex(
raft::resources const& handle_,
raft::device_matrix_view<const value_t, matrix_idx, row_major> X_,
raft::distance::DistanceType metric_)
: handle(handle_),
X(X_),
m(X_.extent(0)),
Expand Down
34 changes: 19 additions & 15 deletions cpp/include/raft/neighbors/brute_force_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using ann::search_params;
*
* @tparam T data element type
*/
[[deprecated("Use cuVS instead")]] template <typename T>
template <typename T>
struct index : ann::index {
public:
/** Distance metric used for retrieval */
Expand Down Expand Up @@ -94,12 +94,14 @@ struct index : ann::index {
* the dataset. If the dataset is in host memory, it will be copied to the device and the
* index will own the device memory.
*/

template <typename data_accessor>
index(raft::resources const& res,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
std::optional<raft::device_vector<T, int64_t>>&& norms,
raft::distance::DistanceType metric,
T metric_arg = 0.0)
[[deprecated("Use cuVS instead")]] index(
raft::resources const& res,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
std::optional<raft::device_vector<T, int64_t>>&& norms,
raft::distance::DistanceType metric,
T metric_arg = 0.0)
: ann::index(),
metric_(metric),
dataset_(make_device_matrix<T, int64_t>(res, 0, 0)),
Expand All @@ -116,11 +118,12 @@ struct index : ann::index {
* This class stores a non-owning reference to the dataset and norms here.
* Having precomputed norms gives us a performance advantage at query time.
*/
index(raft::resources const& res,
raft::device_matrix_view<const T, int64_t, row_major> dataset_view,
std::optional<raft::device_vector_view<const T, int64_t>> norms_view,
raft::distance::DistanceType metric,
T metric_arg = 0.0)
[[deprecated("Use cuVS instead")]] index(
raft::resources const& res,
raft::device_matrix_view<const T, int64_t, row_major> dataset_view,
std::optional<raft::device_vector_view<const T, int64_t>> norms_view,
raft::distance::DistanceType metric,
T metric_arg = 0.0)
: ann::index(),
metric_(metric),
dataset_(make_device_matrix<T, int64_t>(res, 0, 0)),
Expand All @@ -131,10 +134,11 @@ struct index : ann::index {
}

template <typename data_accessor>
index(raft::resources const& res,
index_params const& params,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
std::optional<raft::device_vector<T, int64_t>>&& norms = std::nullopt)
[[deprecated("Use cuVS instead")]] index(
raft::resources const& res,
index_params const& params,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
std::optional<raft::device_vector<T, int64_t>>&& norms = std::nullopt)
: ann::index(),
metric_(params.metric),
dataset_(make_device_matrix<T, int64_t>(res, 0, 0)),
Expand Down
16 changes: 9 additions & 7 deletions cpp/include/raft/neighbors/cagra_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static_assert(std::is_aggregate_v<search_params>);
* @tparam IdxT type of the vector indices (represent dataset.extent(0))
*
*/
[[deprecated("Use cuVS instead")]] template <typename T, typename IdxT>
template <typename T, typename IdxT>
struct index : ann::index {
static_assert(!raft::is_narrowing_v<uint32_t, IdxT>,
"IdxT must be able to represent all values of uint32_t");
Expand Down Expand Up @@ -201,8 +201,9 @@ struct index : ann::index {
~index() = default;

/** Construct an empty index. */
index(raft::resources const& res,
raft::distance::DistanceType metric = raft::distance::DistanceType::L2Expanded)
[[deprecated("Use cuVS instead")]] index(
raft::resources const& res,
raft::distance::DistanceType metric = raft::distance::DistanceType::L2Expanded)
: ann::index(),
metric_(metric),
graph_(make_device_matrix<IdxT, int64_t>(res, 0, 0)),
Expand Down Expand Up @@ -265,10 +266,11 @@ struct index : ann::index {
*
*/
template <typename data_accessor, typename graph_accessor>
index(raft::resources const& res,
raft::distance::DistanceType metric,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
mdspan<const IdxT, matrix_extent<int64_t>, row_major, graph_accessor> knn_graph)
[[deprecated("Use cuVS instead")]] index(
raft::resources const& res,
raft::distance::DistanceType metric,
mdspan<const T, matrix_extent<int64_t>, row_major, data_accessor> dataset,
mdspan<const IdxT, matrix_extent<int64_t>, row_major, graph_accessor> knn_graph)
: ann::index(),
metric_(metric),
graph_(make_device_matrix<IdxT, int64_t>(res, 0, 0)),
Expand Down
Loading

0 comments on commit 8ddcd3e

Please sign in to comment.