Skip to content

Commit

Permalink
Deprecating cluster APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
cjnolet committed Sep 24, 2024
1 parent 4b10bf6 commit a40ac62
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 59 deletions.
63 changes: 32 additions & 31 deletions cpp/include/raft/cluster/kmeans.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ using KeyValueIndexOp = detail::KeyValueIndexOp<IndexT, DataT>;
* closest cluster center.
* @param[out] n_iter Number of iterations run.
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void fit(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -149,7 +149,7 @@ void fit(raft::resources const& handle,
* @param[out] inertia Sum of squared distances of samples to
* their closest cluster center.
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void predict(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -212,7 +212,7 @@ void predict(raft::resources const& handle,
* closest cluster center.
* @param[out] n_iter Number of iterations run.
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void fit_predict(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -241,7 +241,7 @@ void fit_predict(raft::resources const& handle,
* @param[out] X_new X transformed in the new space.
* [dim = n_samples x n_features]
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void transform(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand All @@ -251,7 +251,7 @@ void transform(raft::resources const& handle,
detail::kmeans_transform<DataT, IndexT>(handle, params, X, centroids, X_new);
}

template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void transform(raft::resources const& handle,
const KMeansParams& params,
const DataT* X,
Expand Down Expand Up @@ -304,7 +304,7 @@ void transform(raft::resources const& handle,
* @param maxiter maximum number of iterations to run
* @param tol tolerance for early stopping convergence
*/
template <typename idx_t, typename value_t>
[[deprecated("Use cuVS instead")]] template <typename idx_t, typename value_t>
void find_k(raft::resources const& handle,
raft::device_matrix_view<const value_t, idx_t> X,
raft::host_scalar_view<idx_t> best_k,
Expand Down Expand Up @@ -337,7 +337,7 @@ void find_k(raft::resources const& handle,
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void sample_centroids(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_vector_view<DataT, IndexT> minClusterDistance,
Expand All @@ -364,7 +364,7 @@ void sample_centroids(raft::resources const& handle,
* @param[in] reduction_op The reduction operation used for the cost
*
*/
template <typename DataT, typename IndexT, typename ReductionOpT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT, typename ReductionOpT>
void cluster_cost(raft::resources const& handle,
raft::device_vector_view<DataT, IndexT> minClusterDistance,
rmm::device_uvector<char>& workspace,
Expand All @@ -390,7 +390,8 @@ void cluster_cost(raft::resources const& handle,
* @param[out] weight_per_cluster: sum of sample weights per cluster (size n_clusters)
* @param[out] new_centroids: output matrix of updated centroids (size n_clusters, n_features)
*/
template <typename DataT, typename IndexT, typename LabelsIterator>
[[deprecated(
"Use cuVS instead")]] template <typename DataT, typename IndexT, typename LabelsIterator>
void update_centroids(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT, row_major> X,
raft::device_vector_view<const DataT, IndexT> sample_weights,
Expand Down Expand Up @@ -431,7 +432,7 @@ void update_centroids(raft::resources const& handle,
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void min_cluster_distance(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_matrix_view<DataT, IndexT> centroids,
Expand Down Expand Up @@ -481,7 +482,7 @@ void min_cluster_distance(raft::resources const& handle,
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void min_cluster_and_distance(
raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -522,7 +523,7 @@ void min_cluster_and_distance(
* @param[in] seed Seed for the shuffle
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void shuffle_and_gather(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> in,
raft::device_matrix_view<DataT, IndexT> out,
Expand Down Expand Up @@ -551,7 +552,7 @@ void shuffle_and_gather(raft::resources const& handle,
* [dim = n_cluster]
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void count_samples_in_cluster(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -581,7 +582,7 @@ void count_samples_in_cluster(raft::resources const& handle,
* [dim = n_cluster x n_features]
* @param[in] workspace Temporary workspace buffer which can get resized
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void init_plus_plus(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -614,7 +615,7 @@ void init_plus_plus(raft::resources const& handle,
* @param[out] n_iter Number of iterations run.
* @param[in] workspace Temporary workspace buffer which can get resized
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void fit_main(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -661,7 +662,7 @@ namespace raft::cluster {
* closest cluster center.
* @param[out] n_iter Number of iterations run.
*/
template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_fit(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand All @@ -673,7 +674,7 @@ void kmeans_fit(raft::resources const& handle,
kmeans::fit<DataT, IndexT>(handle, params, X, sample_weight, centroids, inertia, n_iter);
}

template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_fit(raft::resources const& handle,
const KMeansParams& params,
const DataT* X,
Expand Down Expand Up @@ -708,7 +709,7 @@ void kmeans_fit(raft::resources const& handle,
* @param[out] inertia Sum of squared distances of samples to
* their closest cluster center.
*/
template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_predict(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand All @@ -722,7 +723,7 @@ void kmeans_predict(raft::resources const& handle,
handle, params, X, sample_weight, centroids, labels, normalize_weight, inertia);
}

template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_predict(raft::resources const& handle,
const KMeansParams& params,
const DataT* X,
Expand Down Expand Up @@ -773,7 +774,7 @@ void kmeans_predict(raft::resources const& handle,
* closest cluster center.
* @param[out] n_iter Number of iterations run.
*/
template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_fit_predict(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand All @@ -787,7 +788,7 @@ void kmeans_fit_predict(raft::resources const& handle,
handle, params, X, sample_weight, centroids, labels, inertia, n_iter);
}

template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_fit_predict(raft::resources const& handle,
const KMeansParams& params,
const DataT* X,
Expand Down Expand Up @@ -818,7 +819,7 @@ void kmeans_fit_predict(raft::resources const& handle,
* @param[out] X_new X transformed in the new space.
* [dim = n_samples x n_features]
*/
template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_transform(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand All @@ -828,7 +829,7 @@ void kmeans_transform(raft::resources const& handle,
kmeans::transform<DataT, IndexT>(handle, params, X, centroids, X_new);
}

template <typename DataT, typename IndexT = int>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT = int>
void kmeans_transform(raft::resources const& handle,
const KMeansParams& params,
const DataT* X,
Expand Down Expand Up @@ -865,7 +866,7 @@ using KeyValueIndexOp = kmeans::KeyValueIndexOp<IndexT, DataT>;
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void sampleCentroids(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> X,
raft::device_vector_view<DataT, IndexT> minClusterDistance,
Expand All @@ -892,7 +893,7 @@ void sampleCentroids(raft::resources const& handle,
* @param[in] reduction_op The reduction operation used for the cost
*
*/
template <typename DataT, typename IndexT, typename ReductionOpT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT, typename ReductionOpT>
void computeClusterCost(raft::resources const& handle,
raft::device_vector_view<DataT, IndexT> minClusterDistance,
rmm::device_uvector<char>& workspace,
Expand Down Expand Up @@ -923,7 +924,7 @@ void computeClusterCost(raft::resources const& handle,
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void minClusterDistanceCompute(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -969,7 +970,7 @@ void minClusterDistanceCompute(raft::resources const& handle,
* @param[in] workspace Temporary workspace buffer which can get resized
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void minClusterAndDistanceCompute(
raft::resources const& handle,
const KMeansParams& params,
Expand Down Expand Up @@ -1008,7 +1009,7 @@ void minClusterAndDistanceCompute(
* @param[in] seed Seed for the shuffle
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void shuffleAndGather(raft::resources const& handle,
raft::device_matrix_view<const DataT, IndexT> in,
raft::device_matrix_view<DataT, IndexT> out,
Expand Down Expand Up @@ -1037,7 +1038,7 @@ void shuffleAndGather(raft::resources const& handle,
* [dim = n_cluster]
*
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void countSamplesInCluster(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -1068,7 +1069,7 @@ void countSamplesInCluster(raft::resources const& handle,
* [dim = n_cluster x n_features]
* @param[in] workspace Temporary workspace buffer which can get resized
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void kmeansPlusPlus(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down Expand Up @@ -1101,7 +1102,7 @@ void kmeansPlusPlus(raft::resources const& handle,
* @param[out] n_iter Number of iterations run.
* @param[in] workspace Temporary workspace buffer which can get resized
*/
template <typename DataT, typename IndexT>
[[deprecated("Use cuVS instead")]] template <typename DataT, typename IndexT>
void kmeans_fit_main(raft::resources const& handle,
const KMeansParams& params,
raft::device_matrix_view<const DataT, IndexT> X,
Expand Down
49 changes: 26 additions & 23 deletions cpp/include/raft/cluster/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ 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.
*/
template <typename DataT, typename MathT, typename IndexT, typename MappingOpT = raft::identity_op>
[[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,
Expand Down Expand Up @@ -126,11 +129,11 @@ 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.
*/
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
[[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,
Expand Down Expand Up @@ -191,11 +194,11 @@ 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.
*/
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename MappingOpT = raft::identity_op>
[[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,
Expand Down Expand Up @@ -249,12 +252,12 @@ namespace helpers {
* arithmetic datatype. If DataT == MathT, this must be the identity.
* @param[in] X_norm (optional) Dataset's row norms [dim = n_samples]
*/
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT>
[[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,
Expand Down Expand Up @@ -328,12 +331,12 @@ 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.
*/
template <typename DataT,
typename MathT,
typename IndexT,
typename LabelT,
typename CounterT,
typename MappingOpT = raft::identity_op>
[[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,
Expand Down
Loading

0 comments on commit a40ac62

Please sign in to comment.