diff --git a/cpp/bench/common/benchmark.hpp b/cpp/bench/common/benchmark.hpp index 13ca40a033..85d5381e2c 100644 --- a/cpp/bench/common/benchmark.hpp +++ b/cpp/bench/common/benchmark.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ class fixture { rmm::device_buffer scratch_buf_; public: - raft::handle_t handle; + raft::device_resources handle; rmm::cuda_stream_view stream; fixture() : stream{handle.get_stream()} diff --git a/cpp/bench/distance/kernels.cu b/cpp/bench/distance/kernels.cu index 5c9c2cc2ed..027f93171e 100644 --- a/cpp/bench/distance/kernels.cu +++ b/cpp/bench/distance/kernels.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -77,7 +77,7 @@ struct GramMatrix : public fixture { } private: - const raft::handle_t handle; + const raft::device_resources handle; std::unique_ptr> kernel; GramTestParams params; diff --git a/cpp/bench/matrix/select_k.cu b/cpp/bench/matrix/select_k.cu index 3279c011cc..2c8b8bb67b 100644 --- a/cpp/bench/matrix/select_k.cu +++ b/cpp/bench/matrix/select_k.cu @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ struct selection : public fixture { void run_benchmark(::benchmark::State& state) override // NOLINT { - handle_t handle{stream}; + device_resources handle{stream}; using_pool_memory_res res; try { std::ostringstream label_stream; diff --git a/cpp/bench/neighbors/knn.cuh b/cpp/bench/neighbors/knn.cuh index d38631b289..60eb8c257d 100644 --- a/cpp/bench/neighbors/knn.cuh +++ b/cpp/bench/neighbors/knn.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,7 +148,7 @@ struct ivf_flat_knn { raft::neighbors::ivf_flat::search_params search_params; params ps; - ivf_flat_knn(const raft::handle_t& handle, const params& ps, const ValT* data) : ps(ps) + ivf_flat_knn(const raft::device_resources& handle, const params& ps, const ValT* data) : ps(ps) { index_params.n_lists = 4096; index_params.metric = raft::distance::DistanceType::L2Expanded; @@ -156,7 +156,7 @@ struct ivf_flat_knn { handle, index_params, data, IdxT(ps.n_samples), uint32_t(ps.n_dims))); } - void search(const raft::handle_t& handle, + void search(const raft::device_resources& handle, const ValT* search_items, dist_t* out_dists, IdxT* out_idxs) @@ -176,7 +176,7 @@ struct ivf_pq_knn { raft::neighbors::ivf_pq::search_params search_params; params ps; - ivf_pq_knn(const raft::handle_t& handle, const params& ps, const ValT* data) : ps(ps) + ivf_pq_knn(const raft::device_resources& handle, const params& ps, const ValT* data) : ps(ps) { index_params.n_lists = 4096; index_params.metric = raft::distance::DistanceType::L2Expanded; @@ -184,7 +184,7 @@ struct ivf_pq_knn { handle, index_params, data, IdxT(ps.n_samples), uint32_t(ps.n_dims))); } - void search(const raft::handle_t& handle, + void search(const raft::device_resources& handle, const ValT* search_items, dist_t* out_dists, IdxT* out_idxs) @@ -202,12 +202,12 @@ struct brute_force_knn { ValT* index; params ps; - brute_force_knn(const raft::handle_t& handle, const params& ps, const ValT* data) + brute_force_knn(const raft::device_resources& handle, const params& ps, const ValT* data) : index(const_cast(data)), ps(ps) { } - void search(const raft::handle_t& handle, + void search(const raft::device_resources& handle, const ValT* search_items, dist_t* out_dists, IdxT* out_idxs) @@ -287,7 +287,7 @@ struct knn : public fixture { std::ostringstream label_stream; label_stream << params_ << "#" << strategy_ << "#" << scope_; state.SetLabel(label_stream.str()); - raft::handle_t handle(stream); + raft::device_resources handle(stream); std::optional index; if (scope_ == Scope::SEARCH) { // also implies TransferStrategy::NO_COPY diff --git a/cpp/bench/neighbors/refine.cu b/cpp/bench/neighbors/refine.cu index cfce402968..3349b8b6ae 100644 --- a/cpp/bench/neighbors/refine.cu +++ b/cpp/bench/neighbors/refine.cu @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -94,7 +94,7 @@ class RefineAnn : public fixture { } private: - raft::handle_t handle_; + raft::device_resources handle_; RefineHelper data; }; diff --git a/cpp/bench/random/permute.cu b/cpp/bench/random/permute.cu index 5364bb44e3..cb9e21868b 100644 --- a/cpp/bench/random/permute.cu +++ b/cpp/bench/random/permute.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ struct permute : public fixture { } private: - raft::handle_t handle; + raft::device_resources handle; permute_inputs params; rmm::device_uvector out, in; rmm::device_uvector perms; diff --git a/cpp/bench/sparse/convert_csr.cu b/cpp/bench/sparse/convert_csr.cu index 830fab13cc..c9dcae6985 100644 --- a/cpp/bench/sparse/convert_csr.cu +++ b/cpp/bench/sparse/convert_csr.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ struct bench_base : public fixture { } protected: - raft::handle_t handle; + raft::device_resources handle; bench_param params; rmm::device_uvector adj; rmm::device_uvector row_ind; diff --git a/cpp/include/raft/cluster/detail/agglomerative.cuh b/cpp/include/raft/cluster/detail/agglomerative.cuh index 618f852bba..f4b2ecf051 100644 --- a/cpp/include/raft/cluster/detail/agglomerative.cuh +++ b/cpp/include/raft/cluster/detail/agglomerative.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include @@ -100,7 +100,7 @@ class UnionFind { * @param[out] out_size cluster sizes of output */ template -void build_dendrogram_host(const handle_t& handle, +void build_dendrogram_host(raft::device_resources const& handle, const value_idx* rows, const value_idx* cols, const value_t* data, @@ -236,7 +236,7 @@ struct init_label_roots { * @param n_leaves */ template -void extract_flattened_clusters(const raft::handle_t& handle, +void extract_flattened_clusters(raft::device_resources const& handle, value_idx* labels, const value_idx* children, size_t n_clusters, diff --git a/cpp/include/raft/cluster/detail/connectivities.cuh b/cpp/include/raft/cluster/detail/connectivities.cuh index a07045f0d2..163670f29a 100644 --- a/cpp/include/raft/cluster/detail/connectivities.cuh +++ b/cpp/include/raft/cluster/detail/connectivities.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -39,7 +40,7 @@ namespace raft::cluster::detail { template struct distance_graph_impl { - void run(const raft::handle_t& handle, + void run(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, @@ -57,7 +58,7 @@ struct distance_graph_impl { */ template struct distance_graph_impl { - void run(const raft::handle_t& handle, + void run(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, @@ -103,6 +104,98 @@ struct distance_graph_impl +__global__ void fill_indices2(value_idx* indices, size_t m, size_t nnz) +{ + value_idx tid = (blockIdx.x * blockDim.x) + threadIdx.x; + if (tid >= nnz) return; + value_idx v = tid % m; + indices[tid] = v; +} + +/** + * Compute connected CSR of pairwise distances + * @tparam value_idx + * @tparam value_t + * @param handle + * @param X + * @param m + * @param n + * @param metric + * @param[out] indptr + * @param[out] indices + * @param[out] data + */ +template +void pairwise_distances(const raft::device_resources& handle, + const value_t* X, + size_t m, + size_t n, + raft::distance::DistanceType metric, + value_idx* indptr, + value_idx* indices, + value_t* data) +{ + auto stream = handle.get_stream(); + auto exec_policy = handle.get_thrust_policy(); + + value_idx nnz = m * m; + + value_idx blocks = raft::ceildiv(nnz, (value_idx)256); + fill_indices2<<>>(indices, m, nnz); + + thrust::sequence(exec_policy, indptr, indptr + m, 0, (int)m); + + raft::update_device(indptr + m, &nnz, 1, stream); + + // TODO: It would ultimately be nice if the MST could accept + // dense inputs directly so we don't need to double the memory + // usage to hand it a sparse array here. + distance::pairwise_distance(handle, X, X, data, m, m, n, metric); + // self-loops get max distance + auto transform_in = + thrust::make_zip_iterator(thrust::make_tuple(thrust::make_counting_iterator(0), data)); + + thrust::transform(exec_policy, + transform_in, + transform_in + nnz, + data, + [=] __device__(const thrust::tuple& tup) { + value_idx idx = thrust::get<0>(tup); + bool self_loop = idx % m == idx / m; + return (self_loop * std::numeric_limits::max()) + + (!self_loop * thrust::get<1>(tup)); + }); +} + +/** + * Connectivities specialization for pairwise distances + * @tparam value_idx + * @tparam value_t + */ +template +struct distance_graph_impl { + void run(const raft::device_resources& handle, + const value_t* X, + size_t m, + size_t n, + raft::distance::DistanceType metric, + rmm::device_uvector& indptr, + rmm::device_uvector& indices, + rmm::device_uvector& data, + int c) + { + auto stream = handle.get_stream(); + + size_t nnz = m * m; + + indices.resize(nnz, stream); + data.resize(nnz, stream); + + pairwise_distances(handle, X, m, n, metric, indptr.data(), indices.data(), data.data()); + } +}; + /** * Returns a CSR connectivities graph based on the given linkage distance. * @tparam value_idx @@ -120,7 +213,7 @@ struct distance_graph_impl -void get_distance_graph(const raft::handle_t& handle, +void get_distance_graph(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, diff --git a/cpp/include/raft/cluster/detail/kmeans.cuh b/cpp/include/raft/cluster/detail/kmeans.cuh index e575849536..9632fedb9d 100644 --- a/cpp/include/raft/cluster/detail/kmeans.cuh +++ b/cpp/include/raft/cluster/detail/kmeans.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ namespace detail { // Selects 'n_clusters' samples randomly from X template -void initRandom(const raft::handle_t& handle, +void initRandom(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids) @@ -85,7 +85,7 @@ void initRandom(const raft::handle_t& handle, * 5: end for */ template -void kmeansPlusPlus(const raft::handle_t& handle, +void kmeansPlusPlus(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroidsRawData, @@ -282,7 +282,7 @@ void kmeansPlusPlus(const raft::handle_t& handle, * @param[inout] workspace */ template -void update_centroids(const raft::handle_t& handle, +void update_centroids(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view sample_weights, raft::device_matrix_view centroids, @@ -356,7 +356,7 @@ void update_centroids(const raft::handle_t& handle, // TODO: Resizing is needed to use mdarray instead of rmm::device_uvector template -void kmeans_fit_main(const raft::handle_t& handle, +void kmeans_fit_main(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view weight, @@ -573,7 +573,7 @@ void kmeans_fit_main(const raft::handle_t& handle, */ template -void initScalableKMeansPlusPlus(const raft::handle_t& handle, +void initScalableKMeansPlusPlus(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroidsRawData, @@ -816,7 +816,7 @@ void initScalableKMeansPlusPlus(const raft::handle_t& handle, * @param[out] n_iter Number of iterations run. */ template -void kmeans_fit(handle_t const& handle, +void kmeans_fit(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -955,7 +955,7 @@ void kmeans_fit(handle_t const& handle, } template -void kmeans_fit(handle_t const& handle, +void kmeans_fit(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -980,7 +980,7 @@ void kmeans_fit(handle_t const& handle, } template -void kmeans_predict(handle_t const& handle, +void kmeans_predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -1088,7 +1088,7 @@ void kmeans_predict(handle_t const& handle, } template -void kmeans_predict(handle_t const& handle, +void kmeans_predict(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -1120,7 +1120,7 @@ void kmeans_predict(handle_t const& handle, } template -void kmeans_fit_predict(handle_t const& handle, +void kmeans_fit_predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -1147,7 +1147,7 @@ void kmeans_fit_predict(handle_t const& handle, } template -void kmeans_fit_predict(handle_t const& handle, +void kmeans_fit_predict(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -1187,7 +1187,7 @@ void kmeans_fit_predict(handle_t const& handle, * @param[out] X_new X transformed in the new space.. */ template -void kmeans_transform(const raft::handle_t& handle, +void kmeans_transform(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -1228,7 +1228,7 @@ void kmeans_transform(const raft::handle_t& handle, } template -void kmeans_transform(const raft::handle_t& handle, +void kmeans_transform(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* centroids, diff --git a/cpp/include/raft/cluster/detail/kmeans_common.cuh b/cpp/include/raft/cluster/detail/kmeans_common.cuh index 559793442f..2ee9744c9d 100644 --- a/cpp/include/raft/cluster/detail/kmeans_common.cuh +++ b/cpp/include/raft/cluster/detail/kmeans_common.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ struct KeyValueIndexOp { // Computes the intensity histogram from a sequence of labels template -void countLabels(const raft::handle_t& handle, +void countLabels(raft::device_resources const& handle, SampleIteratorT labels, CounterT* count, IndexT n_samples, @@ -125,7 +125,7 @@ void countLabels(const raft::handle_t& handle, } template -void checkWeight(const raft::handle_t& handle, +void checkWeight(raft::device_resources const& handle, raft::device_vector_view weight, rmm::device_uvector& workspace) { @@ -183,7 +183,7 @@ template -void computeClusterCost(const raft::handle_t& handle, +void computeClusterCost(raft::device_resources const& handle, raft::device_vector_view minClusterDistance, rmm::device_uvector& workspace, raft::device_scalar_view clusterCost, @@ -218,7 +218,7 @@ void computeClusterCost(const raft::handle_t& handle, } template -void sampleCentroids(const raft::handle_t& handle, +void sampleCentroids(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view minClusterDistance, raft::device_vector_view isSampleCentroid, @@ -282,7 +282,7 @@ void sampleCentroids(const raft::handle_t& handle, // calculate pairwise distance between 'dataset[n x d]' and 'centroids[k x d]', // result will be stored in 'pairwiseDistance[n x k]' template -void pairwise_distance_kmeans(const raft::handle_t& handle, +void pairwise_distance_kmeans(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view centroids, raft::device_matrix_view pairwiseDistance, @@ -310,7 +310,7 @@ void pairwise_distance_kmeans(const raft::handle_t& handle, // shuffle and randomly select 'n_samples_to_gather' from input 'in' and stores // in 'out' does not modify the input template -void shuffleAndGather(const raft::handle_t& handle, +void shuffleAndGather(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, uint32_t n_samples_to_gather, @@ -345,7 +345,7 @@ void shuffleAndGather(const raft::handle_t& handle, // is the distance between the sample and the 'centroid[key]' template void minClusterAndDistanceCompute( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view centroids, raft::device_vector_view, IndexT> minClusterAndDistance, @@ -478,7 +478,7 @@ void minClusterAndDistanceCompute( } template -void minClusterDistanceCompute(const raft::handle_t& handle, +void minClusterDistanceCompute(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view centroids, raft::device_vector_view minClusterDistance, @@ -596,7 +596,7 @@ void minClusterDistanceCompute(const raft::handle_t& handle, } template -void countSamplesInCluster(const raft::handle_t& handle, +void countSamplesInCluster(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view L2NormX, diff --git a/cpp/include/raft/cluster/detail/kmeans_deprecated.cuh b/cpp/include/raft/cluster/detail/kmeans_deprecated.cuh index 2746b6f657..a9d8777304 100644 --- a/cpp/include/raft/cluster/detail/kmeans_deprecated.cuh +++ b/cpp/include/raft/cluster/detail/kmeans_deprecated.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include @@ -360,7 +360,7 @@ static __global__ void divideCentroids(index_type_t d, * @return Zero if successful. Otherwise non-zero. */ template -static int chooseNewCentroid(handle_t const& handle, +static int chooseNewCentroid(raft::device_resources const& handle, index_type_t n, index_type_t d, value_type_t rand, @@ -457,7 +457,7 @@ static int chooseNewCentroid(handle_t const& handle, * @return Zero if successful. Otherwise non-zero. */ template -static int initializeCentroids(handle_t const& handle, +static int initializeCentroids(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, @@ -568,7 +568,7 @@ static int initializeCentroids(handle_t const& handle, * @return Zero if successful. Otherwise non-zero. */ template -static int assignCentroids(handle_t const& handle, +static int assignCentroids(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, @@ -640,7 +640,7 @@ static int assignCentroids(handle_t const& handle, * @return Zero if successful. Otherwise non-zero. */ template -static int updateCentroids(handle_t const& handle, +static int updateCentroids(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, @@ -783,7 +783,7 @@ static int updateCentroids(handle_t const& handle, * @return error flag. */ template -int kmeans(handle_t const& handle, +int kmeans(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, @@ -950,7 +950,7 @@ int kmeans(handle_t const& handle, * @return error flag */ template -int kmeans(handle_t const& handle, +int kmeans(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, diff --git a/cpp/include/raft/cluster/detail/mst.cuh b/cpp/include/raft/cluster/detail/mst.cuh index 8143d21641..46e31b672e 100644 --- a/cpp/include/raft/cluster/detail/mst.cuh +++ b/cpp/include/raft/cluster/detail/mst.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ void merge_msts(sparse::solver::Graph_COO& coo1, */ template void connect_knn_graph( - const raft::handle_t& handle, + raft::device_resources const& handle, const value_t* X, sparse::solver::Graph_COO& msf, size_t m, @@ -130,7 +130,7 @@ void connect_knn_graph( */ template void build_sorted_mst( - const raft::handle_t& handle, + raft::device_resources const& handle, const value_t* X, const value_idx* indptr, const value_idx* indices, diff --git a/cpp/include/raft/cluster/detail/single_linkage.cuh b/cpp/include/raft/cluster/detail/single_linkage.cuh index d12db85e1b..473d858827 100644 --- a/cpp/include/raft/cluster/detail/single_linkage.cuh +++ b/cpp/include/raft/cluster/detail/single_linkage.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ static const size_t EMPTY = 0; * @param[in] n_clusters number of clusters to assign data samples */ template -void single_linkage(const raft::handle_t& handle, +void single_linkage(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, diff --git a/cpp/include/raft/cluster/kmeans.cuh b/cpp/include/raft/cluster/kmeans.cuh index 4b912dc966..ac9e66d5da 100644 --- a/cpp/include/raft/cluster/kmeans.cuh +++ b/cpp/include/raft/cluster/kmeans.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,12 +44,12 @@ using KeyValueIndexOp = detail::KeyValueIndexOp; * k-means++ algorithm. * * @code{.cpp} - * #include + * #include * #include * #include * using namespace raft::cluster; * ... - * raft::handle_t handle; + * raft::raft::device_resources handle; * raft::cluster::KMeansParams params; * int n_features = 15, inertia, n_iter; * auto centroids = raft::make_device_matrix(handle, params.n_clusters, n_features); @@ -83,7 +83,7 @@ using KeyValueIndexOp = detail::KeyValueIndexOp; * @param[out] n_iter Number of iterations run. */ template -void fit(handle_t const& handle, +void fit(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -98,12 +98,12 @@ void fit(handle_t const& handle, * @brief Predict the closest cluster each sample in X belongs to. * * @code{.cpp} - * #include + * #include * #include * #include * using namespace raft::cluster; * ... - * raft::handle_t handle; + * raft::raft::device_resources handle; * raft::cluster::KMeansParams params; * int n_features = 15, inertia, n_iter; * auto centroids = raft::make_device_matrix(handle, params.n_clusters, n_features); @@ -147,7 +147,7 @@ void fit(handle_t const& handle, * their closest cluster center. */ template -void predict(handle_t const& handle, +void predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -165,12 +165,12 @@ void predict(handle_t const& handle, * in the input. * * @code{.cpp} - * #include + * #include * #include * #include * using namespace raft::cluster; * ... - * raft::handle_t handle; + * raft::raft::device_resources handle; * raft::cluster::KMeansParams params; * int n_features = 15, inertia, n_iter; * auto centroids = raft::make_device_matrix(handle, params.n_clusters, n_features); @@ -210,7 +210,7 @@ void predict(handle_t const& handle, * @param[out] n_iter Number of iterations run. */ template -void fit_predict(handle_t const& handle, +void fit_predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -239,7 +239,7 @@ void fit_predict(handle_t const& handle, * [dim = n_samples x n_features] */ template -void transform(const raft::handle_t& handle, +void transform(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -249,7 +249,7 @@ void transform(const raft::handle_t& handle, } template -void transform(const raft::handle_t& handle, +void transform(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* centroids, @@ -281,7 +281,7 @@ void transform(const raft::handle_t& handle, * */ template -void sample_centroids(const raft::handle_t& handle, +void sample_centroids(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view minClusterDistance, raft::device_vector_view isSampleCentroid, @@ -308,7 +308,7 @@ void sample_centroids(const raft::handle_t& handle, * */ template -void cluster_cost(const raft::handle_t& handle, +void cluster_cost(raft::device_resources const& handle, raft::device_vector_view minClusterDistance, rmm::device_uvector& workspace, raft::device_scalar_view clusterCost, @@ -334,7 +334,7 @@ void cluster_cost(const raft::handle_t& handle, * @param[out] new_centroids: output matrix of updated centroids (size n_clusters, n_features) */ template -void update_centroids(const raft::handle_t& handle, +void update_centroids(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view sample_weights, raft::device_matrix_view centroids, @@ -375,7 +375,7 @@ void update_centroids(const raft::handle_t& handle, * */ template -void min_cluster_distance(const raft::handle_t& handle, +void min_cluster_distance(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view centroids, raft::device_vector_view minClusterDistance, @@ -426,7 +426,7 @@ void min_cluster_distance(const raft::handle_t& handle, */ template void min_cluster_and_distance( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view centroids, raft::device_vector_view, IndexT> minClusterAndDistance, @@ -466,7 +466,7 @@ void min_cluster_and_distance( * */ template -void shuffle_and_gather(const raft::handle_t& handle, +void shuffle_and_gather(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, uint32_t n_samples_to_gather, @@ -495,7 +495,7 @@ void shuffle_and_gather(const raft::handle_t& handle, * */ template -void count_samples_in_cluster(const raft::handle_t& handle, +void count_samples_in_cluster(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view L2NormX, @@ -525,7 +525,7 @@ void count_samples_in_cluster(const raft::handle_t& handle, * @param[in] workspace Temporary workspace buffer which can get resized */ template -void init_plus_plus(const raft::handle_t& handle, +void init_plus_plus(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -558,7 +558,7 @@ void init_plus_plus(const raft::handle_t& handle, * @param[in] workspace Temporary workspace buffer which can get resized */ template -void fit_main(const raft::handle_t& handle, +void fit_main(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view sample_weights, @@ -605,7 +605,7 @@ namespace raft::cluster { * @param[out] n_iter Number of iterations run. */ template -void kmeans_fit(handle_t const& handle, +void kmeans_fit(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -617,7 +617,7 @@ void kmeans_fit(handle_t const& handle, } template -void kmeans_fit(handle_t const& handle, +void kmeans_fit(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -652,7 +652,7 @@ void kmeans_fit(handle_t const& handle, * their closest cluster center. */ template -void kmeans_predict(handle_t const& handle, +void kmeans_predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -666,7 +666,7 @@ void kmeans_predict(handle_t const& handle, } template -void kmeans_predict(handle_t const& handle, +void kmeans_predict(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -717,7 +717,7 @@ void kmeans_predict(handle_t const& handle, * @param[out] n_iter Number of iterations run. */ template -void kmeans_fit_predict(handle_t const& handle, +void kmeans_fit_predict(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -731,7 +731,7 @@ void kmeans_fit_predict(handle_t const& handle, } template -void kmeans_fit_predict(handle_t const& handle, +void kmeans_fit_predict(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* sample_weight, @@ -762,7 +762,7 @@ void kmeans_fit_predict(handle_t const& handle, * [dim = n_samples x n_features] */ template -void kmeans_transform(const raft::handle_t& handle, +void kmeans_transform(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -772,7 +772,7 @@ void kmeans_transform(const raft::handle_t& handle, } template -void kmeans_transform(const raft::handle_t& handle, +void kmeans_transform(raft::device_resources const& handle, const KMeansParams& params, const DataT* X, const DataT* centroids, @@ -809,7 +809,7 @@ using KeyValueIndexOp = kmeans::KeyValueIndexOp; * */ template -void sampleCentroids(const raft::handle_t& handle, +void sampleCentroids(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view minClusterDistance, raft::device_vector_view isSampleCentroid, @@ -836,7 +836,7 @@ void sampleCentroids(const raft::handle_t& handle, * */ template -void computeClusterCost(const raft::handle_t& handle, +void computeClusterCost(raft::device_resources const& handle, raft::device_vector_view minClusterDistance, rmm::device_uvector& workspace, raft::device_scalar_view clusterCost, @@ -867,7 +867,7 @@ void computeClusterCost(const raft::handle_t& handle, * */ template -void minClusterDistanceCompute(const raft::handle_t& handle, +void minClusterDistanceCompute(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -914,7 +914,7 @@ void minClusterDistanceCompute(const raft::handle_t& handle, */ template void minClusterAndDistanceCompute( - const raft::handle_t& handle, + raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroids, @@ -952,7 +952,7 @@ void minClusterAndDistanceCompute( * */ template -void shuffleAndGather(const raft::handle_t& handle, +void shuffleAndGather(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, uint32_t n_samples_to_gather, @@ -981,7 +981,7 @@ void shuffleAndGather(const raft::handle_t& handle, * */ template -void countSamplesInCluster(const raft::handle_t& handle, +void countSamplesInCluster(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view L2NormX, @@ -1012,7 +1012,7 @@ void countSamplesInCluster(const raft::handle_t& handle, * @param[in] workspace Temporary workspace buffer which can get resized */ template -void kmeansPlusPlus(const raft::handle_t& handle, +void kmeansPlusPlus(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_matrix_view centroidsRawData, @@ -1045,7 +1045,7 @@ void kmeansPlusPlus(const raft::handle_t& handle, * @param[in] workspace Temporary workspace buffer which can get resized */ template -void kmeans_fit_main(const raft::handle_t& handle, +void kmeans_fit_main(raft::device_resources const& handle, const KMeansParams& params, raft::device_matrix_view X, raft::device_vector_view weight, diff --git a/cpp/include/raft/cluster/kmeans_deprecated.cuh b/cpp/include/raft/cluster/kmeans_deprecated.cuh index a4cac4cb0f..8e0861ada1 100644 --- a/cpp/include/raft/cluster/kmeans_deprecated.cuh +++ b/cpp/include/raft/cluster/kmeans_deprecated.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ namespace cluster { * @return error flag */ template -int kmeans(handle_t const& handle, +int kmeans(raft::device_resources const& handle, index_type_t n, index_type_t d, index_type_t k, diff --git a/cpp/include/raft/cluster/single_linkage.cuh b/cpp/include/raft/cluster/single_linkage.cuh index 2d74c364b2..91241b853b 100644 --- a/cpp/include/raft/cluster/single_linkage.cuh +++ b/cpp/include/raft/cluster/single_linkage.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ namespace raft::cluster { template -void single_linkage(const raft::handle_t& handle, +void single_linkage(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, @@ -87,7 +87,7 @@ constexpr int DEFAULT_CONST_C = 15; control of k. The algorithm will set `k = log(n) + c` */ template -void single_linkage(const raft::handle_t& handle, +void single_linkage(raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view dendrogram, raft::device_vector_view labels, diff --git a/cpp/include/raft/comms/comms_test.hpp b/cpp/include/raft/comms/comms_test.hpp index c7e5dd3ab6..c61bb32f79 100644 --- a/cpp/include/raft/comms/comms_test.hpp +++ b/cpp/include/raft/comms/comms_test.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include #include -#include +#include namespace raft { namespace comms { @@ -31,7 +31,7 @@ namespace comms { * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_allreduce(const handle_t& handle, int root) +bool test_collective_allreduce(raft::device_resources const& handle, int root) { return detail::test_collective_allreduce(handle, root); } @@ -43,7 +43,7 @@ bool test_collective_allreduce(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_broadcast(const handle_t& handle, int root) +bool test_collective_broadcast(raft::device_resources const& handle, int root) { return detail::test_collective_broadcast(handle, root); } @@ -55,7 +55,7 @@ bool test_collective_broadcast(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_reduce(const handle_t& handle, int root) +bool test_collective_reduce(raft::device_resources const& handle, int root) { return detail::test_collective_reduce(handle, root); } @@ -67,7 +67,7 @@ bool test_collective_reduce(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_allgather(const handle_t& handle, int root) +bool test_collective_allgather(raft::device_resources const& handle, int root) { return detail::test_collective_allgather(handle, root); } @@ -79,7 +79,7 @@ bool test_collective_allgather(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_gather(const handle_t& handle, int root) +bool test_collective_gather(raft::device_resources const& handle, int root) { return detail::test_collective_gather(handle, root); } @@ -91,7 +91,7 @@ bool test_collective_gather(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_gatherv(const handle_t& handle, int root) +bool test_collective_gatherv(raft::device_resources const& handle, int root) { return detail::test_collective_gatherv(handle, root); } @@ -103,7 +103,7 @@ bool test_collective_gatherv(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_reducescatter(const handle_t& handle, int root) +bool test_collective_reducescatter(raft::device_resources const& handle, int root) { return detail::test_collective_reducescatter(handle, root); } @@ -115,7 +115,7 @@ bool test_collective_reducescatter(const handle_t& handle, int root) * initialized comms instance. * @param[in] numTrials number of iterations of all-to-all messaging to perform */ -bool test_pointToPoint_simple_send_recv(const handle_t& h, int numTrials) +bool test_pointToPoint_simple_send_recv(raft::device_resources const& h, int numTrials) { return detail::test_pointToPoint_simple_send_recv(h, numTrials); } @@ -127,7 +127,7 @@ bool test_pointToPoint_simple_send_recv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_send_or_recv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_send_or_recv(raft::device_resources const& h, int numTrials) { return detail::test_pointToPoint_device_send_or_recv(h, numTrials); } @@ -139,7 +139,7 @@ bool test_pointToPoint_device_send_or_recv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_sendrecv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_sendrecv(raft::device_resources const& h, int numTrials) { return detail::test_pointToPoint_device_sendrecv(h, numTrials); } @@ -151,7 +151,7 @@ bool test_pointToPoint_device_sendrecv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_multicast_sendrecv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_multicast_sendrecv(raft::device_resources const& h, int numTrials) { return detail::test_pointToPoint_device_multicast_sendrecv(h, numTrials); } @@ -163,6 +163,9 @@ bool test_pointToPoint_device_multicast_sendrecv(const handle_t& h, int numTrial * initialized comms instance. * @param n_colors number of different colors to test */ -bool test_commsplit(const handle_t& h, int n_colors) { return detail::test_commsplit(h, n_colors); } +bool test_commsplit(raft::device_resources const& h, int n_colors) +{ + return detail::test_commsplit(h, n_colors); +} } // namespace comms }; // namespace raft diff --git a/cpp/include/raft/comms/detail/mpi_comms.hpp b/cpp/include/raft/comms/detail/mpi_comms.hpp index 508a9ce717..4062389eea 100644 --- a/cpp/include/raft/comms/detail/mpi_comms.hpp +++ b/cpp/include/raft/comms/detail/mpi_comms.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/cpp/include/raft/comms/detail/std_comms.hpp b/cpp/include/raft/comms/detail/std_comms.hpp index 33892597d8..0db27f0a45 100644 --- a/cpp/include/raft/comms/detail/std_comms.hpp +++ b/cpp/include/raft/comms/detail/std_comms.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/raft/comms/detail/test.hpp b/cpp/include/raft/comms/detail/test.hpp index 4f879540b4..2b12bf2d2a 100644 --- a/cpp/include/raft/comms/detail/test.hpp +++ b/cpp/include/raft/comms/detail/test.hpp @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include @@ -38,7 +38,7 @@ namespace detail { * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_allreduce(const handle_t& handle, int root) +bool test_collective_allreduce(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -69,7 +69,7 @@ bool test_collective_allreduce(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_broadcast(const handle_t& handle, int root) +bool test_collective_broadcast(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -104,7 +104,7 @@ bool test_collective_broadcast(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_reduce(const handle_t& handle, int root) +bool test_collective_reduce(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -140,7 +140,7 @@ bool test_collective_reduce(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_allgather(const handle_t& handle, int root) +bool test_collective_allgather(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -177,7 +177,7 @@ bool test_collective_allgather(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_gather(const handle_t& handle, int root) +bool test_collective_gather(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -214,7 +214,7 @@ bool test_collective_gather(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_gatherv(const handle_t& handle, int root) +bool test_collective_gatherv(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -273,7 +273,7 @@ bool test_collective_gatherv(const handle_t& handle, int root) * initialized comms instance. * @param[in] root the root rank id */ -bool test_collective_reducescatter(const handle_t& handle, int root) +bool test_collective_reducescatter(raft::device_resources const& handle, int root) { comms_t const& communicator = handle.get_comms(); @@ -308,7 +308,7 @@ bool test_collective_reducescatter(const handle_t& handle, int root) * initialized comms instance. * @param[in] numTrials number of iterations of all-to-all messaging to perform */ -bool test_pointToPoint_simple_send_recv(const handle_t& h, int numTrials) +bool test_pointToPoint_simple_send_recv(raft::device_resources const& h, int numTrials) { comms_t const& communicator = h.get_comms(); int const rank = communicator.get_rank(); @@ -373,7 +373,7 @@ bool test_pointToPoint_simple_send_recv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_send_or_recv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_send_or_recv(raft::device_resources const& h, int numTrials) { comms_t const& communicator = h.get_comms(); int const rank = communicator.get_rank(); @@ -415,7 +415,7 @@ bool test_pointToPoint_device_send_or_recv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_sendrecv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_sendrecv(raft::device_resources const& h, int numTrials) { comms_t const& communicator = h.get_comms(); int const rank = communicator.get_rank(); @@ -461,7 +461,7 @@ bool test_pointToPoint_device_sendrecv(const handle_t& h, int numTrials) * initialized comms instance. * @param numTrials number of iterations of send or receive messaging to perform */ -bool test_pointToPoint_device_multicast_sendrecv(const handle_t& h, int numTrials) +bool test_pointToPoint_device_multicast_sendrecv(raft::device_resources const& h, int numTrials) { comms_t const& communicator = h.get_comms(); int const rank = communicator.get_rank(); @@ -520,7 +520,7 @@ bool test_pointToPoint_device_multicast_sendrecv(const handle_t& h, int numTrial * initialized comms instance. * @param n_colors number of different colors to test */ -bool test_commsplit(const handle_t& h, int n_colors) +bool test_commsplit(raft::device_resources const& h, int n_colors) { comms_t const& communicator = h.get_comms(); int const rank = communicator.get_rank(); diff --git a/cpp/include/raft/comms/mpi_comms.hpp b/cpp/include/raft/comms/mpi_comms.hpp index b3ea62efd2..9076176ea6 100644 --- a/cpp/include/raft/comms/mpi_comms.hpp +++ b/cpp/include/raft/comms/mpi_comms.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ using mpi_comms = detail::mpi_comms; * #include * * MPI_Comm mpi_comm; - * raft::handle_t handle; + * raft::raft::device_resources handle; * * initialize_mpi_comms(&handle, mpi_comm); * ... @@ -55,7 +55,7 @@ using mpi_comms = detail::mpi_comms; * comm.sync_stream(handle.get_stream()); * @endcode */ -inline void initialize_mpi_comms(handle_t* handle, MPI_Comm comm) +inline void initialize_mpi_comms(device_resources* handle, MPI_Comm comm) { auto communicator = std::make_shared( std::unique_ptr(new mpi_comms(comm, false, handle->get_stream()))); diff --git a/cpp/include/raft/comms/std_comms.hpp b/cpp/include/raft/comms/std_comms.hpp index 5e619053da..6370d4a8e6 100644 --- a/cpp/include/raft/comms/std_comms.hpp +++ b/cpp/include/raft/comms/std_comms.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include @@ -39,7 +39,7 @@ using std_comms = detail::std_comms; * Factory function to construct a RAFT NCCL communicator and inject it into a * RAFT handle. * - * @param handle raft::handle_t for injecting the comms + * @param handle raft::device_resources for injecting the comms * @param nccl_comm initialized NCCL communicator to use for collectives * @param num_ranks number of ranks in communicator clique * @param rank rank of local instance @@ -49,7 +49,7 @@ using std_comms = detail::std_comms; * #include * * ncclComm_t nccl_comm; - * raft::handle_t handle; + * raft::raft::device_resources handle; * * build_comms_nccl_only(&handle, nccl_comm, 5, 0); * ... @@ -64,7 +64,7 @@ using std_comms = detail::std_comms; * comm.sync_stream(handle.get_stream()); * @endcode */ -void build_comms_nccl_only(handle_t* handle, ncclComm_t nccl_comm, int num_ranks, int rank) +void build_comms_nccl_only(device_resources* handle, ncclComm_t nccl_comm, int num_ranks, int rank) { cudaStream_t stream = handle->get_stream(); @@ -77,7 +77,7 @@ void build_comms_nccl_only(handle_t* handle, ncclComm_t nccl_comm, int num_ranks * Factory function to construct a RAFT NCCL+UCX and inject it into a RAFT * handle. * - * @param handle raft::handle_t for injecting the comms + * @param handle raft::device_resources for injecting the comms * @param nccl_comm initialized NCCL communicator to use for collectives * @param ucp_worker of local process * Note: This is purposefully left as void* so that the ucp_worker_h @@ -93,7 +93,7 @@ void build_comms_nccl_only(handle_t* handle, ncclComm_t nccl_comm, int num_ranks * #include * * ncclComm_t nccl_comm; - * raft::handle_t handle; + * raft::raft::device_resources handle; * ucp_worker_h ucp_worker; * ucp_ep_h *ucp_endpoints_arr; * @@ -110,8 +110,12 @@ void build_comms_nccl_only(handle_t* handle, ncclComm_t nccl_comm, int num_ranks * comm.sync_stream(handle.get_stream()); * @endcode */ -void build_comms_nccl_ucx( - handle_t* handle, ncclComm_t nccl_comm, void* ucp_worker, void* eps, int num_ranks, int rank) +void build_comms_nccl_ucx(device_resources* handle, + ncclComm_t nccl_comm, + void* ucp_worker, + void* eps, + int num_ranks, + int rank) { auto eps_sp = std::make_shared(new ucp_ep_h[num_ranks]); diff --git a/cpp/include/raft/core/detail/device_mdarray.hpp b/cpp/include/raft/core/detail/device_mdarray.hpp index ad6831794e..31dfaba70a 100644 --- a/cpp/include/raft/core/detail/device_mdarray.hpp +++ b/cpp/include/raft/core/detail/device_mdarray.hpp @@ -6,7 +6,7 @@ */ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ */ #pragma once #include -#include +#include #include #include // dynamic_extent diff --git a/cpp/include/raft/core/device_mdarray.hpp b/cpp/include/raft/core/device_mdarray.hpp index 693e50a506..03cb09eecb 100644 --- a/cpp/include/raft/core/device_mdarray.hpp +++ b/cpp/include/raft/core/device_mdarray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ using device_matrix = device_mdarray, Layo * @tparam ElementType the data type of the matrix elements * @tparam IndexType the index type of the extents * @tparam LayoutPolicy policy for strides and layout ordering - * @param handle raft::handle_t + * @param handle raft::device_resources * @param exts dimensionality of the array (series of integers) * @return raft::device_mdarray */ @@ -80,7 +80,7 @@ template -auto make_device_mdarray(const raft::handle_t& handle, extents exts) +auto make_device_mdarray(raft::device_resources const& handle, extents exts) { using mdarray_t = device_mdarray; @@ -95,7 +95,7 @@ auto make_device_mdarray(const raft::handle_t& handle, extents -auto make_device_mdarray(const raft::handle_t& handle, +auto make_device_mdarray(raft::device_resources const& handle, rmm::mr::device_memory_resource* mr, extents exts) { @@ -130,7 +130,7 @@ auto make_device_mdarray(const raft::handle_t& handle, template -auto make_device_matrix(raft::handle_t const& handle, IndexType n_rows, IndexType n_cols) +auto make_device_matrix(raft::device_resources const& handle, IndexType n_rows, IndexType n_cols) { return make_device_mdarray( handle.get_stream(), make_extents(n_rows, n_cols)); @@ -146,7 +146,7 @@ auto make_device_matrix(raft::handle_t const& handle, IndexType n_rows, IndexTyp * @return raft::device_scalar */ template -auto make_device_scalar(raft::handle_t const& handle, ElementType const& v) +auto make_device_scalar(raft::device_resources const& handle, ElementType const& v) { scalar_extent extents; using policy_t = typename device_scalar::container_policy_type; @@ -168,7 +168,7 @@ auto make_device_scalar(raft::handle_t const& handle, ElementType const& v) template -auto make_device_vector(raft::handle_t const& handle, IndexType n) +auto make_device_vector(raft::device_resources const& handle, IndexType n) { return make_device_mdarray(handle.get_stream(), make_extents(n)); diff --git a/cpp/include/raft/core/device_resources.hpp b/cpp/include/raft/core/device_resources.hpp index ec0b92dde2..68c56dc9b6 100644 --- a/cpp/include/raft/core/device_resources.hpp +++ b/cpp/include/raft/core/device_resources.hpp @@ -79,6 +79,8 @@ class device_resources : public resources { * @param[in] stream_view the default stream (which has the default per-thread stream if * unspecified) * @param[in] stream_pool the stream pool used (which has default of nullptr if unspecified) + * @param[in] workspace_resource an optional resource used by some functions for allocating + * temporary workspaces. */ device_resources(rmm::cuda_stream_view stream_view = rmm::cuda_stream_per_thread, std::shared_ptr stream_pool = {nullptr}, diff --git a/cpp/include/raft/core/handle.hpp b/cpp/include/raft/core/handle.hpp index c1e7aa538f..02efebec9e 100644 --- a/cpp/include/raft/core/handle.hpp +++ b/cpp/include/raft/core/handle.hpp @@ -24,11 +24,11 @@ namespace raft { * raft::handle_t is being kept around for backwards * compatibility and will be removed in a future version. * - * Extending the `raft::device_resources` instead of `using` to + * Extending the `raft::handle_t` instead of `using` to * minimize needed changes downstream * (e.g. existing forward declarations, etc...) * - * Use of `raft::resources` or `raft::device_resources` is preferred. + * Use of `raft::resources` or `raft::handle_t` is preferred. */ class handle_t : public raft::device_resources { public: @@ -48,6 +48,8 @@ class handle_t : public raft::device_resources { * @param[in] stream_view the default stream (which has the default per-thread stream if * unspecified) * @param[in] stream_pool the stream pool used (which has default of nullptr if unspecified) + * @param[in] workspace_resource an optional resource used by some functions for allocating + * temporary workspaces. */ handle_t(rmm::cuda_stream_view stream_view = rmm::cuda_stream_per_thread, std::shared_ptr stream_pool = {nullptr}, @@ -60,4 +62,4 @@ class handle_t : public raft::device_resources { ~handle_t() override {} }; -} // end NAMESPACE raft \ No newline at end of file +} // end NAMESPACE raft diff --git a/cpp/include/raft/core/resource/comms.hpp b/cpp/include/raft/core/resource/comms.hpp index b7a74b7dd5..73de166c14 100644 --- a/cpp/include/raft/core/resource/comms.hpp +++ b/cpp/include/raft/core/resource/comms.hpp @@ -51,6 +51,11 @@ class comms_resource_factory : public resource_factory { std::shared_ptr communicator_; }; +/** + * @defgroup resource_comms Comms resource functions + * @{ + */ + inline bool comms_initialized(resources const& res) { return res.has_resource_factory(resource_type::COMMUNICATOR); @@ -66,4 +71,8 @@ inline void set_comms(resources const& res, std::shared_ptr comm { res.add_resource_factory(std::make_shared(communicator)); } + +/** + * @} + */ } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/cublas_handle.hpp b/cpp/include/raft/core/resource/cublas_handle.hpp index cf6f51ee98..710fcc7e60 100644 --- a/cpp/include/raft/core/resource/cublas_handle.hpp +++ b/cpp/include/raft/core/resource/cublas_handle.hpp @@ -54,11 +54,16 @@ class cublas_resource_factory : public resource_factory { rmm::cuda_stream_view stream_; }; +/** + * @defgroup resource_cublas cuBLAS handle resource functions + * @{ + */ + /** * Load a cublasres_t from raft res if it exists, otherwise * add it and return it. - * @param res - * @return + * @param[in] res the raft resources object + * @return cublas handle */ inline cublasHandle_t get_cublas_handle(resources const& res) { @@ -68,4 +73,9 @@ inline cublasHandle_t get_cublas_handle(resources const& res) } return *res.get_resource(resource_type::CUBLAS_HANDLE); }; + +/** + * @} + */ + } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/cuda_stream.hpp b/cpp/include/raft/core/resource/cuda_stream.hpp index 2e01ce0123..318252199e 100644 --- a/cpp/include/raft/core/resource/cuda_stream.hpp +++ b/cpp/include/raft/core/resource/cuda_stream.hpp @@ -54,6 +54,10 @@ class cuda_stream_resource_factory : public resource_factory { rmm::cuda_stream_view stream; }; +/** + * @defgroup resource_cuda_stream CUDA stream resource functions + * @{ + */ /** * Load a rmm::cuda_stream_view from a resources instance (and populate it on the res * if needed). @@ -71,8 +75,8 @@ inline rmm::cuda_stream_view get_cuda_stream(resources const& res) /** * Load a rmm::cuda_stream_view from a resources instance (and populate it on the res * if needed). - * @param res raft res object for managing resources - * @return + * @param[in] res raft resources object for managing resources + * @param[in] stream_view cuda stream view */ inline void set_cuda_stream(resources const& res, rmm::cuda_stream_view stream_view) { @@ -81,6 +85,9 @@ inline void set_cuda_stream(resources const& res, rmm::cuda_stream_view stream_v /** * @brief synchronize a specific stream + * + * @param[in] res the raft resources object + * @param[in] stream stream to synchronize */ inline void sync_stream(const resources& res, rmm::cuda_stream_view stream) { @@ -91,4 +98,9 @@ inline void sync_stream(const resources& res, rmm::cuda_stream_view stream) * @brief synchronize main stream on the resources instance */ inline void sync_stream(const resources& res) { sync_stream(res, get_cuda_stream(res)); } + +/** + * @} + */ + } // namespace raft::resource \ No newline at end of file diff --git a/cpp/include/raft/core/resource/cuda_stream_pool.hpp b/cpp/include/raft/core/resource/cuda_stream_pool.hpp index 452523d3af..dbce75b3a5 100644 --- a/cpp/include/raft/core/resource/cuda_stream_pool.hpp +++ b/cpp/include/raft/core/resource/cuda_stream_pool.hpp @@ -65,6 +65,11 @@ inline bool is_stream_pool_initialized(const resources& res) resource_type::CUDA_STREAM_POOL) != nullptr; } +/** + * @defgroup resource_stream_pool CUDA Stream pool resource functions + * @{ + */ + /** * Load a cuda_stream_pool, and create a new one if it doesn't already exist * @param res raft res object for managing resources @@ -126,6 +131,7 @@ inline rmm::cuda_stream_view get_next_usable_stream(const resources& res) /** * @brief return stream from pool at index if size > 0, else main stream on res * + * @param[in] res the raft resources object * @param[in] stream_idx the required index of the stream in the stream pool if available */ inline rmm::cuda_stream_view get_next_usable_stream(const resources& res, std::size_t stream_idx) @@ -136,6 +142,8 @@ inline rmm::cuda_stream_view get_next_usable_stream(const resources& res, std::s /** * @brief synchronize the stream pool on the res + * + * @param[in] res the raft resources object */ inline void sync_stream_pool(const resources& res) { @@ -147,6 +155,7 @@ inline void sync_stream_pool(const resources& res) /** * @brief synchronize subset of stream pool * + * @param[in] res the raft resources object * @param[in] stream_indices the indices of the streams in the stream pool to synchronize */ inline void sync_stream_pool(const resources& res, const std::vector stream_indices) @@ -159,6 +168,8 @@ inline void sync_stream_pool(const resources& res, const std::vector(resource_type::CUSOLVER_DN_HANDLE); }; + +/** + * @} + */ + } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/cusolver_sp_handle.hpp b/cpp/include/raft/core/resource/cusolver_sp_handle.hpp index 1822955301..61fd95b44f 100644 --- a/cpp/include/raft/core/resource/cusolver_sp_handle.hpp +++ b/cpp/include/raft/core/resource/cusolver_sp_handle.hpp @@ -57,11 +57,16 @@ class cusolver_sp_resource_factory : public resource_factory { rmm::cuda_stream_view stream_; }; +/** + * @defgroup resource_cusolver_sp cuSolver SP handle resource functions + * @{ + */ + /** * Load a cusolverSpres_t from raft res if it exists, otherwise * add it and return it. - * @param res - * @return + * @param[in] res the raft resources object + * @return cusolver sp handle */ inline cusolverSpHandle_t get_cusolver_sp_handle(resources const& res) { @@ -71,4 +76,9 @@ inline cusolverSpHandle_t get_cusolver_sp_handle(resources const& res) } return *res.get_resource(resource_type::CUSOLVER_SP_HANDLE); }; + +/** + * @} + */ + } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/cusparse_handle.hpp b/cpp/include/raft/core/resource/cusparse_handle.hpp index 133e01f164..9893ed2f86 100644 --- a/cpp/include/raft/core/resource/cusparse_handle.hpp +++ b/cpp/include/raft/core/resource/cusparse_handle.hpp @@ -52,11 +52,16 @@ class cusparse_resource_factory : public resource_factory { rmm::cuda_stream_view stream_; }; +/** + * @defgroup resource_cusparse cuSparse handle resource functions + * @{ + */ + /** * Load a cusparseres_t from raft res if it exists, otherwise * add it and return it. - * @param res - * @return + * @param[in] res the raft resources object + * @return cusparse handle */ inline cusparseHandle_t get_cusparse_handle(resources const& res) { @@ -66,4 +71,9 @@ inline cusparseHandle_t get_cusparse_handle(resources const& res) } return *res.get_resource(resource_type::CUSPARSE_HANDLE); }; + +/** + * @} + */ + } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/device_id.hpp b/cpp/include/raft/core/resource/device_id.hpp index 76c57166b3..b55e56ca45 100644 --- a/cpp/include/raft/core/resource/device_id.hpp +++ b/cpp/include/raft/core/resource/device_id.hpp @@ -51,10 +51,15 @@ class device_id_resource_factory : public resource_factory { resource* make_resource() override { return new device_id_resource(); } }; +/** + * @defgroup resource_device_id Device ID resource functions + * @{ + */ + /** * Load a device id from a res (and populate it on the res if needed). * @param res raft res object for managing resources - * @return + * @return device id */ inline int get_device_id(resources const& res) { @@ -63,4 +68,8 @@ inline int get_device_id(resources const& res) } return *res.get_resource(resource_type::DEVICE_ID); }; + +/** + * @} + */ } // namespace raft::resource \ No newline at end of file diff --git a/cpp/include/raft/core/resource/device_memory_resource.hpp b/cpp/include/raft/core/resource/device_memory_resource.hpp index 0706f28f94..35ae3d715f 100644 --- a/cpp/include/raft/core/resource/device_memory_resource.hpp +++ b/cpp/include/raft/core/resource/device_memory_resource.hpp @@ -67,7 +67,6 @@ inline rmm::mr::device_memory_resource* get_workspace_resource(resources const& * * @param res raft resources object for managing resources * @param mr a valid rmm device_memory_resource - * @return */ inline void set_workspace_resource(resources const& res, rmm::mr::device_memory_resource* mr) { diff --git a/cpp/include/raft/core/resource/device_properties.hpp b/cpp/include/raft/core/resource/device_properties.hpp index d6193e7a95..c3b0b8f2b9 100644 --- a/cpp/include/raft/core/resource/device_properties.hpp +++ b/cpp/include/raft/core/resource/device_properties.hpp @@ -37,6 +37,11 @@ class device_properties_resource : public resource { cudaDeviceProp prop_; }; +/** + * @defgroup resource_device_props Device properties resource functions + * @{ + */ + /** * Factory that knows how to construct a * specific raft::resource to populate @@ -55,7 +60,7 @@ class device_properties_resource_factory : public resource_factory { /** * Load a cudaDeviceProp from a res (and populate it on the res if needed). * @param res raft res object for managing resources - * @return + * @return populated cuda device properties instance */ inline cudaDeviceProp& get_device_properties(resources const& res) { @@ -65,4 +70,8 @@ inline cudaDeviceProp& get_device_properties(resources const& res) } return *res.get_resource(resource_type::DEVICE_PROPERTIES); }; + +/** + * @} + */ } // namespace raft::resource \ No newline at end of file diff --git a/cpp/include/raft/core/resource/resource_types.hpp b/cpp/include/raft/core/resource/resource_types.hpp index ace4b7061b..cf302e25f9 100644 --- a/cpp/include/raft/core/resource/resource_types.hpp +++ b/cpp/include/raft/core/resource/resource_types.hpp @@ -18,6 +18,11 @@ namespace raft::resource { +/** + * @defgroup resource_types Core resource vocabulary types + * @{ + */ + /** * @brief Resource types can apply to any resource and don't have to be host- or device-specific. */ @@ -103,4 +108,8 @@ class empty_resource_factory : public resource_factory { empty_resource res; }; +/** + * @} + */ + } // namespace raft::resource diff --git a/cpp/include/raft/core/resource/sub_comms.hpp b/cpp/include/raft/core/resource/sub_comms.hpp index 9c2c67deed..7070b61c54 100644 --- a/cpp/include/raft/core/resource/sub_comms.hpp +++ b/cpp/include/raft/core/resource/sub_comms.hpp @@ -42,6 +42,11 @@ class sub_comms_resource_factory : public resource_factory { resource* make_resource() override { return new sub_comms_resource(); } }; +/** + * @defgroup resource_subcomms Subcommunicator resource functions + * @{ + */ + inline const comms::comms_t& get_subcomm(const resources& res, std::string key) { if (!res.has_resource_factory(resource_type::SUB_COMMUNICATOR)) { @@ -69,4 +74,9 @@ inline void set_subcomm(resources const& res, resource_type::SUB_COMMUNICATOR); sub_comms->insert(std::make_pair(key, subcomm)); } + +/** + * @} + */ + } // namespace raft::resource \ No newline at end of file diff --git a/cpp/include/raft/core/resource/thrust_policy.hpp b/cpp/include/raft/core/resource/thrust_policy.hpp index e3e3cf6aef..1e7441e5e4 100644 --- a/cpp/include/raft/core/resource/thrust_policy.hpp +++ b/cpp/include/raft/core/resource/thrust_policy.hpp @@ -48,10 +48,15 @@ class thrust_policy_resource_factory : public resource_factory { rmm::cuda_stream_view stream_view_; }; +/** + * @defgroup resource_thrust_policy Thrust policy resource functions + * @{ + */ + /** * Load a thrust policy from a res (and populate it on the res if needed). * @param res raft res object for managing resources - * @return + * @return thrust execution policy */ inline rmm::exec_policy& get_thrust_policy(resources const& res) { @@ -61,4 +66,9 @@ inline rmm::exec_policy& get_thrust_policy(resources const& res) } return *res.get_resource(resource_type::THRUST_POLICY); }; + +/** + * @} + */ + } // namespace raft::resource \ No newline at end of file diff --git a/cpp/include/raft/distance/distance.cuh b/cpp/include/raft/distance/distance.cuh index 1c069fc397..93a5ce7f1a 100644 --- a/cpp/include/raft/distance/distance.cuh +++ b/cpp/include/raft/distance/distance.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include #include @@ -238,7 +238,7 @@ void distance(const InType* x, * @param metric_arg metric argument (used for Minkowski distance) */ template -void pairwise_distance(const raft::handle_t& handle, +void pairwise_distance(raft::device_resources const& handle, const Type* x, const Type* y, Type* dist, @@ -333,7 +333,7 @@ void pairwise_distance(const raft::handle_t& handle, * @param metric_arg metric argument (used for Minkowski distance) */ template -void pairwise_distance(const raft::handle_t& handle, +void pairwise_distance(raft::device_resources const& handle, const Type* x, const Type* y, Type* dist, @@ -363,12 +363,12 @@ void pairwise_distance(const raft::handle_t& handle, * * Usage example: * @code{.cpp} - * #include + * #include * #include * #include * #include * - * raft::handle_t handle; + * raft::raft::device_resources handle; * int n_samples = 5000; * int n_features = 50; * @@ -398,7 +398,7 @@ template -void distance(raft::handle_t const& handle, +void distance(raft::device_resources const& handle, raft::device_matrix_view const x, raft::device_matrix_view const y, raft::device_matrix_view dist, @@ -441,7 +441,7 @@ void distance(raft::handle_t const& handle, * @param metric_arg metric argument (used for Minkowski distance) */ template -void pairwise_distance(raft::handle_t const& handle, +void pairwise_distance(raft::device_resources const& handle, device_matrix_view const x, device_matrix_view const y, device_matrix_view dist, diff --git a/cpp/include/raft/distance/fused_l2_nn.cuh b/cpp/include/raft/distance/fused_l2_nn.cuh index 1f677e919d..e832bcb020 100644 --- a/cpp/include/raft/distance/fused_l2_nn.cuh +++ b/cpp/include/raft/distance/fused_l2_nn.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -50,7 +50,8 @@ using MinReduceOp = detail::MinReduceOpImpl; * Initialize array using init value from reduction op */ template -void initialize(const raft::handle_t& handle, OutT* min, IdxT m, DataT maxVal, ReduceOpT redOp) +void initialize( + raft::device_resources const& handle, OutT* min, IdxT m, DataT maxVal, ReduceOpT redOp) { detail::initialize(min, m, maxVal, redOp, handle.get_stream()); } diff --git a/cpp/include/raft/handle.hpp b/cpp/include/raft/handle.hpp index 4525af49d2..caa68061db 100644 --- a/cpp/include/raft/handle.hpp +++ b/cpp/include/raft/handle.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,4 +21,4 @@ #pragma once -#include +#include diff --git a/cpp/include/raft/linalg/add.cuh b/cpp/include/raft/linalg/add.cuh index 27ab24abe8..608c63e1a9 100644 --- a/cpp/include/raft/linalg/add.cuh +++ b/cpp/include/raft/linalg/add.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ void addDevScalar( * @brief Elementwise add operation * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in1 First Input * @param[in] in2 Second Input * @param[out] out Output @@ -104,7 +104,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void add(const raft::handle_t& handle, InType in1, InType in2, OutType out) +void add(raft::device_resources const& handle, InType in1, InType in2, OutType out) { using in_value_t = typename InType::value_type; using out_value_t = typename OutType::value_type; @@ -135,7 +135,7 @@ void add(const raft::handle_t& handle, InType in1, InType in2, OutType out) * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[in] scalar raft::device_scalar_view * @param[in] out Output @@ -145,7 +145,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void add_scalar(const raft::handle_t& handle, +void add_scalar(raft::device_resources const& handle, InType in, OutType out, raft::device_scalar_view scalar) @@ -177,7 +177,7 @@ void add_scalar(const raft::handle_t& handle, * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[in] scalar raft::host_scalar_view * @param[in] out Output @@ -187,7 +187,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void add_scalar(const raft::handle_t& handle, +void add_scalar(raft::device_resources const& handle, const InType in, OutType out, raft::host_scalar_view scalar) diff --git a/cpp/include/raft/linalg/axpy.cuh b/cpp/include/raft/linalg/axpy.cuh index 35a34bc2b5..9b3af73234 100644 --- a/cpp/include/raft/linalg/axpy.cuh +++ b/cpp/include/raft/linalg/axpy.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ namespace raft::linalg { * @param [in] stream */ template -void axpy(const raft::handle_t& handle, +void axpy(raft::device_resources const& handle, const int n, const T* alpha, const T* x, @@ -62,7 +62,7 @@ void axpy(const raft::handle_t& handle, * @brief axpy function * It computes the following equation: y = alpha * x + y * - * @param [in] handle raft::handle_t + * @param [in] handle raft::device_resources * @param [in] alpha raft::device_scalar_view * @param [in] x Input vector * @param [inout] y Output vector @@ -72,7 +72,7 @@ template -void axpy(const raft::handle_t& handle, +void axpy(raft::device_resources const& handle, raft::device_scalar_view alpha, raft::device_vector_view x, raft::device_vector_view y) @@ -92,7 +92,7 @@ void axpy(const raft::handle_t& handle, /** * @brief axpy function * It computes the following equation: y = alpha * x + y - * @param [in] handle raft::handle_t + * @param [in] handle raft::device_resources * @param [in] alpha raft::device_scalar_view * @param [in] x Input vector * @param [inout] y Output vector @@ -102,7 +102,7 @@ template -void axpy(const raft::handle_t& handle, +void axpy(raft::device_resources const& handle, raft::host_scalar_view alpha, raft::device_vector_view x, raft::device_vector_view y) diff --git a/cpp/include/raft/linalg/binary_op.cuh b/cpp/include/raft/linalg/binary_op.cuh index 693ef961c2..966e84965d 100644 --- a/cpp/include/raft/linalg/binary_op.cuh +++ b/cpp/include/raft/linalg/binary_op.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "detail/binary_op.cuh" #include -#include +#include #include #include @@ -65,7 +65,7 @@ void binaryOp( * @tparam InType Input Type raft::device_mdspan * @tparam Lambda the device-lambda performing the actual operation * @tparam OutType Output Type raft::device_mdspan - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in1 First input * @param[in] in2 Second input * @param[out] out Output @@ -78,7 +78,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void binary_op(const raft::handle_t& handle, InType in1, InType in2, OutType out, Lambda op) +void binary_op(raft::device_resources const& handle, InType in1, InType in2, OutType out, Lambda op) { RAFT_EXPECTS(raft::is_row_or_column_major(out), "Output must be contiguous"); RAFT_EXPECTS(raft::is_row_or_column_major(in1), "Input 1 must be contiguous"); diff --git a/cpp/include/raft/linalg/cholesky_r1_update.cuh b/cpp/include/raft/linalg/cholesky_r1_update.cuh index af8d12d873..e10f43653b 100644 --- a/cpp/include/raft/linalg/cholesky_r1_update.cuh +++ b/cpp/include/raft/linalg/cholesky_r1_update.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ namespace linalg { * conditioned systems. Negative values mean no regularizaton. */ template -void choleskyRank1Update(const raft::handle_t& handle, +void choleskyRank1Update(raft::device_resources const& handle, math_t* L, int n, int ld, diff --git a/cpp/include/raft/linalg/coalesced_reduction.cuh b/cpp/include/raft/linalg/coalesced_reduction.cuh index 45cd640edc..674be207d8 100644 --- a/cpp/include/raft/linalg/coalesced_reduction.cuh +++ b/cpp/include/raft/linalg/coalesced_reduction.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "detail/coalesced_reduction.cuh" #include -#include +#include #include namespace raft { @@ -101,7 +101,7 @@ void coalescedReduction(OutType* dots, * @tparam FinalLambda the final lambda applied before STG (eg: Sqrt for L2 norm) * It must be a 'callable' supporting the following input and output: *
OutType (*FinalLambda)(OutType);
- * @param handle raft::handle_t + * @param handle raft::device_resources * @param[in] data Input of type raft::device_matrix_view * @param[out] dots Output of type raft::device_matrix_view * @param[in] init initial value to use for the reduction @@ -117,7 +117,7 @@ template -void coalesced_reduction(const raft::handle_t& handle, +void coalesced_reduction(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view dots, OutValueType init, diff --git a/cpp/include/raft/linalg/detail/axpy.cuh b/cpp/include/raft/linalg/detail/axpy.cuh index f3e1a177c8..5747e840c4 100644 --- a/cpp/include/raft/linalg/detail/axpy.cuh +++ b/cpp/include/raft/linalg/detail/axpy.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ #include "cublas_wrappers.hpp" -#include +#include namespace raft::linalg::detail { template -void axpy(const raft::handle_t& handle, +void axpy(raft::device_resources const& handle, const int n, const T* alpha, const T* x, diff --git a/cpp/include/raft/linalg/detail/cholesky_r1_update.cuh b/cpp/include/raft/linalg/detail/cholesky_r1_update.cuh index 47937815bd..afa9155753 100644 --- a/cpp/include/raft/linalg/detail/cholesky_r1_update.cuh +++ b/cpp/include/raft/linalg/detail/cholesky_r1_update.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include "cublas_wrappers.hpp" #include "cusolver_wrappers.hpp" -#include +#include #include namespace raft { @@ -26,7 +26,7 @@ namespace linalg { namespace detail { template -void choleskyRank1Update(const raft::handle_t& handle, +void choleskyRank1Update(raft::device_resources const& handle, math_t* L, int n, int ld, diff --git a/cpp/include/raft/linalg/detail/eig.cuh b/cpp/include/raft/linalg/detail/eig.cuh index d48b42fc57..94493efb24 100644 --- a/cpp/include/raft/linalg/detail/eig.cuh +++ b/cpp/include/raft/linalg/detail/eig.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include "cusolver_wrappers.hpp" #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace linalg { namespace detail { template -void eigDC_legacy(const raft::handle_t& handle, +void eigDC_legacy(raft::device_resources const& handle, const math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -74,7 +74,7 @@ void eigDC_legacy(const raft::handle_t& handle, } template -void eigDC(const raft::handle_t& handle, +void eigDC(raft::device_resources const& handle, const math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -137,7 +137,7 @@ void eigDC(const raft::handle_t& handle, enum EigVecMemUsage { OVERWRITE_INPUT, COPY_INPUT }; template -void eigSelDC(const raft::handle_t& handle, +void eigSelDC(raft::device_resources const& handle, math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -228,7 +228,7 @@ void eigSelDC(const raft::handle_t& handle, } template -void eigJacobi(const raft::handle_t& handle, +void eigJacobi(raft::device_resources const& handle, const math_t* in, std::size_t n_rows, std::size_t n_cols, diff --git a/cpp/include/raft/linalg/detail/gemm.hpp b/cpp/include/raft/linalg/detail/gemm.hpp index baa066984b..ba9496c3b9 100644 --- a/cpp/include/raft/linalg/detail/gemm.hpp +++ b/cpp/include/raft/linalg/detail/gemm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "cublas_wrappers.hpp" -#include +#include namespace raft { namespace linalg { @@ -49,7 +49,7 @@ namespace detail { * @param [in] stream */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const bool trans_a, const bool trans_b, const int m, @@ -103,7 +103,7 @@ void gemm(const raft::handle_t& handle, * @param stream cuda stream */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const math_t* a, int n_rows_a, int n_cols_a, @@ -130,7 +130,7 @@ void gemm(const raft::handle_t& handle, } template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const math_t* a, int n_rows_a, int n_cols_a, @@ -149,7 +149,7 @@ void gemm(const raft::handle_t& handle, } template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, T* z, T* x, T* y, diff --git a/cpp/include/raft/linalg/detail/gemv.hpp b/cpp/include/raft/linalg/detail/gemv.hpp index 38fcdcd82e..b3e001a851 100644 --- a/cpp/include/raft/linalg/detail/gemv.hpp +++ b/cpp/include/raft/linalg/detail/gemv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,14 @@ #include "cublas_wrappers.hpp" -#include +#include namespace raft { namespace linalg { namespace detail { template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const bool trans_a, const int m, const int n, @@ -59,7 +59,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows, const int n_cols, @@ -76,7 +76,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -91,7 +91,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -107,7 +107,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -126,7 +126,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, diff --git a/cpp/include/raft/linalg/detail/lanczos.cuh b/cpp/include/raft/linalg/detail/lanczos.cuh index 5a3c595512..8c0cfeba28 100644 --- a/cpp/include/raft/linalg/detail/lanczos.cuh +++ b/cpp/include/raft/linalg/detail/lanczos.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ #include #include "cublas_wrappers.hpp" -#include +#include #include #include #include @@ -82,7 +82,7 @@ inline curandStatus_t curandGenerateNormalX( * @return Zero if successful. Otherwise non-zero. */ template -int performLanczosIteration(handle_t const& handle, +int performLanczosIteration(raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t* iter, index_type_t maxIter, @@ -540,7 +540,7 @@ static int francisQRIteration(index_type_t n, * @return error flag. */ template -static int lanczosRestart(handle_t const& handle, +static int lanczosRestart(raft::device_resources const& handle, index_type_t n, index_type_t iter, index_type_t iter_new, @@ -743,7 +743,7 @@ static int lanczosRestart(handle_t const& handle, */ template int computeSmallestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t nEigVecs, index_type_t maxIter, @@ -984,7 +984,7 @@ int computeSmallestEigenvectors( template int computeSmallestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, @@ -1087,7 +1087,7 @@ int computeSmallestEigenvectors( */ template int computeLargestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t nEigVecs, index_type_t maxIter, @@ -1331,7 +1331,7 @@ int computeLargestEigenvectors( template int computeLargestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, diff --git a/cpp/include/raft/linalg/detail/lstsq.cuh b/cpp/include/raft/linalg/detail/lstsq.cuh index f0cf300e2f..207bcefc32 100644 --- a/cpp/include/raft/linalg/detail/lstsq.cuh +++ b/cpp/include/raft/linalg/detail/lstsq.cuh @@ -117,7 +117,7 @@ struct DivideByNonZero { * so it's not guaranteed to stay unmodified. */ template -void lstsqSvdQR(const raft::handle_t& handle, +void lstsqSvdQR(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, @@ -177,7 +177,7 @@ void lstsqSvdQR(const raft::handle_t& handle, * so it's not guaranteed to stay unmodified. */ template -void lstsqSvdJacobi(const raft::handle_t& handle, +void lstsqSvdJacobi(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, @@ -248,7 +248,7 @@ void lstsqSvdJacobi(const raft::handle_t& handle, * (`w = (A^T A)^-1 A^T b`) */ template -void lstsqEig(const raft::handle_t& handle, +void lstsqEig(raft::device_resources const& handle, const math_t* A, const int n_rows, const int n_cols, @@ -352,7 +352,7 @@ void lstsqEig(const raft::handle_t& handle, * Warning: the content of this vector is modified by the cuSOLVER routines. */ template -void lstsqQR(const raft::handle_t& handle, +void lstsqQR(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, diff --git a/cpp/include/raft/linalg/detail/map.cuh b/cpp/include/raft/linalg/detail/map.cuh index add003eb52..e0b473bdd4 100644 --- a/cpp/include/raft/linalg/detail/map.cuh +++ b/cpp/include/raft/linalg/detail/map.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include diff --git a/cpp/include/raft/linalg/detail/map_then_reduce.cuh b/cpp/include/raft/linalg/detail/map_then_reduce.cuh index 7ef9ca1c43..70bb2df4f5 100644 --- a/cpp/include/raft/linalg/detail/map_then_reduce.cuh +++ b/cpp/include/raft/linalg/detail/map_then_reduce.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include diff --git a/cpp/include/raft/linalg/detail/qr.cuh b/cpp/include/raft/linalg/detail/qr.cuh index 74e9c3e1aa..4cba028d87 100644 --- a/cpp/include/raft/linalg/detail/qr.cuh +++ b/cpp/include/raft/linalg/detail/qr.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ namespace detail { */ template void qrGetQ_inplace( - const raft::handle_t& handle, math_t* Q, int n_rows, int n_cols, cudaStream_t stream) + raft::device_resources const& handle, math_t* Q, int n_rows, int n_cols, cudaStream_t stream) { RAFT_EXPECTS(n_rows >= n_cols, "QR decomposition expects n_rows >= n_cols."); cusolverDnHandle_t cusolver = handle.get_cusolver_dn_handle(); @@ -83,7 +83,7 @@ void qrGetQ_inplace( } template -void qrGetQ(const raft::handle_t& handle, +void qrGetQ(raft::device_resources const& handle, const math_t* M, math_t* Q, int n_rows, @@ -95,7 +95,7 @@ void qrGetQ(const raft::handle_t& handle, } template -void qrGetQR(const raft::handle_t& handle, +void qrGetQR(raft::device_resources const& handle, math_t* M, math_t* Q, math_t* R, diff --git a/cpp/include/raft/linalg/detail/rsvd.cuh b/cpp/include/raft/linalg/detail/rsvd.cuh index f96598d9e6..a66a23179b 100644 --- a/cpp/include/raft/linalg/detail/rsvd.cuh +++ b/cpp/include/raft/linalg/detail/rsvd.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ namespace detail { * @param stream cuda stream */ template -void rsvdFixedRank(const raft::handle_t& handle, +void rsvdFixedRank(raft::device_resources const& handle, math_t* M, int n_rows, int n_cols, @@ -371,7 +371,7 @@ void rsvdFixedRank(const raft::handle_t& handle, * @param stream cuda stream */ template -void rsvdPerc(const raft::handle_t& handle, +void rsvdPerc(raft::device_resources const& handle, math_t* M, int n_rows, int n_cols, diff --git a/cpp/include/raft/linalg/detail/svd.cuh b/cpp/include/raft/linalg/detail/svd.cuh index 8626c7888b..4850744f51 100644 --- a/cpp/include/raft/linalg/detail/svd.cuh +++ b/cpp/include/raft/linalg/detail/svd.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -36,7 +36,7 @@ namespace linalg { namespace detail { template -void svdQR(const raft::handle_t& handle, +void svdQR(raft::device_resources const& handle, T* in, int n_rows, int n_cols, @@ -102,7 +102,7 @@ void svdQR(const raft::handle_t& handle, } template -void svdEig(const raft::handle_t& handle, +void svdEig(raft::device_resources const& handle, math_t* in, idx_t n_rows, idx_t n_cols, @@ -162,7 +162,7 @@ void svdEig(const raft::handle_t& handle, } template -void svdJacobi(const raft::handle_t& handle, +void svdJacobi(raft::device_resources const& handle, math_t* in, int n_rows, int n_cols, @@ -232,7 +232,7 @@ void svdJacobi(const raft::handle_t& handle, } template -void svdReconstruction(const raft::handle_t& handle, +void svdReconstruction(raft::device_resources const& handle, math_t* U, math_t* S, math_t* V, @@ -263,7 +263,7 @@ void svdReconstruction(const raft::handle_t& handle, } template -bool evaluateSVDByL2Norm(const raft::handle_t& handle, +bool evaluateSVDByL2Norm(raft::device_resources const& handle, math_t* A_d, math_t* U, math_t* S_vec, diff --git a/cpp/include/raft/linalg/detail/transpose.cuh b/cpp/include/raft/linalg/detail/transpose.cuh index ef5551ea7e..9e7b236fed 100644 --- a/cpp/include/raft/linalg/detail/transpose.cuh +++ b/cpp/include/raft/linalg/detail/transpose.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include "cublas_wrappers.hpp" #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace linalg { namespace detail { template -void transpose(const raft::handle_t& handle, +void transpose(raft::device_resources const& handle, math_t* in, math_t* out, int n_rows, @@ -82,7 +82,7 @@ void transpose(math_t* inout, int n, cudaStream_t stream) template void transpose_row_major_impl( - handle_t const& handle, + raft::device_resources const& handle, raft::mdspan, LayoutPolicy, AccessorPolicy> in, raft::mdspan, LayoutPolicy, AccessorPolicy> out) { @@ -108,7 +108,7 @@ void transpose_row_major_impl( template void transpose_col_major_impl( - handle_t const& handle, + raft::device_resources const& handle, raft::mdspan, LayoutPolicy, AccessorPolicy> in, raft::mdspan, LayoutPolicy, AccessorPolicy> out) { diff --git a/cpp/include/raft/linalg/divide.cuh b/cpp/include/raft/linalg/divide.cuh index 526d8a9716..0b18e6175c 100644 --- a/cpp/include/raft/linalg/divide.cuh +++ b/cpp/include/raft/linalg/divide.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ void divideScalar(OutT* out, const InT* in, InT scalar, IdxType len, cudaStream_ * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[in] scalar raft::host_scalar_view * @param[out] out Output @@ -66,7 +66,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void divide_scalar(const raft::handle_t& handle, +void divide_scalar(raft::device_resources const& handle, InType in, OutType out, raft::host_scalar_view scalar) diff --git a/cpp/include/raft/linalg/dot.cuh b/cpp/include/raft/linalg/dot.cuh index 4b1bc913e1..917188d695 100644 --- a/cpp/include/raft/linalg/dot.cuh +++ b/cpp/include/raft/linalg/dot.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace raft::linalg { @@ -33,7 +33,7 @@ namespace raft::linalg { /** * @brief Computes the dot product of two vectors. - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] x First input vector * @param[in] y Second input vector * @param[out] out The output dot product between the x and y vectors. @@ -43,7 +43,7 @@ template -void dot(const raft::handle_t& handle, +void dot(raft::device_resources const& handle, raft::device_vector_view x, raft::device_vector_view y, raft::device_scalar_view out) @@ -63,7 +63,7 @@ void dot(const raft::handle_t& handle, /** * @brief Computes the dot product of two vectors. - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] x First input vector * @param[in] y Second input vector * @param[out] out The output dot product between the x and y vectors. @@ -73,7 +73,7 @@ template -void dot(const raft::handle_t& handle, +void dot(raft::device_resources const& handle, raft::device_vector_view x, raft::device_vector_view y, raft::host_scalar_view out) diff --git a/cpp/include/raft/linalg/eig.cuh b/cpp/include/raft/linalg/eig.cuh index 271ff13db5..03e94a10b1 100644 --- a/cpp/include/raft/linalg/eig.cuh +++ b/cpp/include/raft/linalg/eig.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ namespace linalg { * @param stream cuda stream */ template -void eigDC(const raft::handle_t& handle, +void eigDC(raft::device_resources const& handle, const math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -68,7 +68,7 @@ using detail::OVERWRITE_INPUT; * @param stream cuda stream */ template -void eigSelDC(const raft::handle_t& handle, +void eigSelDC(raft::device_resources const& handle, math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -97,7 +97,7 @@ void eigSelDC(const raft::handle_t& handle, * accuracy. */ template -void eigJacobi(const raft::handle_t& handle, +void eigJacobi(raft::device_resources const& handle, const math_t* in, std::size_t n_rows, std::size_t n_cols, @@ -120,14 +120,14 @@ void eigJacobi(const raft::handle_t& handle, * symmetric matrices * @tparam ValueType the data-type of input and output * @tparam IntegerType Integer used for addressing - * @param handle raft::handle_t + * @param handle raft::device_resources * @param[in] in input raft::device_matrix_view (symmetric matrix that has real eig values and * vectors) * @param[out] eig_vectors: eigenvectors output of type raft::device_matrix_view * @param[out] eig_vals: eigen values output of type raft::device_vector_view */ template -void eig_dc(const raft::handle_t& handle, +void eig_dc(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view eig_vectors, raft::device_vector_view eig_vals) @@ -149,7 +149,7 @@ void eig_dc(const raft::handle_t& handle, * for the column-major symmetric matrices * @tparam ValueType the data-type of input and output * @tparam IntegerType Integer used for addressing - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in input raft::device_matrix_view (symmetric matrix that has real eig values and * vectors) * @param[out] eig_vectors: eigenvectors output of type raft::device_matrix_view @@ -158,7 +158,7 @@ void eig_dc(const raft::handle_t& handle, * @param[in] memUsage: the memory selection for eig vector output */ template -void eig_dc_selective(const raft::handle_t& handle, +void eig_dc_selective(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view eig_vectors, raft::device_vector_view eig_vals, @@ -185,7 +185,7 @@ void eig_dc_selective(const raft::handle_t& handle, * column-major symmetric matrices (in parameter) * @tparam ValueType the data-type of input and output * @tparam IntegerType Integer used for addressing - * @param handle raft::handle_t + * @param handle raft::device_resources * @param[in] in input raft::device_matrix_view (symmetric matrix that has real eig values and * vectors) * @param[out] eig_vectors: eigenvectors output of type raft::device_matrix_view @@ -196,7 +196,7 @@ void eig_dc_selective(const raft::handle_t& handle, * accuracy. */ template -void eig_jacobi(const raft::handle_t& handle, +void eig_jacobi(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view eig_vectors, raft::device_vector_view eig_vals, diff --git a/cpp/include/raft/linalg/gemm.cuh b/cpp/include/raft/linalg/gemm.cuh index f2354da6c6..d5dc5ffab5 100644 --- a/cpp/include/raft/linalg/gemm.cuh +++ b/cpp/include/raft/linalg/gemm.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ namespace linalg { * @param [in] stream */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const bool trans_a, const bool trans_b, const int m, @@ -91,7 +91,7 @@ void gemm(const raft::handle_t& handle, * @param stream cuda stream */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const math_t* a, int n_rows_a, int n_cols_a, @@ -126,7 +126,7 @@ void gemm(const raft::handle_t& handle, * @param stream cuda stream */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, const math_t* a, int n_rows_a, int n_cols_a, @@ -161,7 +161,7 @@ void gemm(const raft::handle_t& handle, * @param beta scalar */ template -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, T* z, T* x, T* y, @@ -213,7 +213,7 @@ template >, std::is_same>>>> -void gemm(const raft::handle_t& handle, +void gemm(raft::device_resources const& handle, raft::device_matrix_view x, raft::device_matrix_view y, raft::device_matrix_view z, diff --git a/cpp/include/raft/linalg/gemv.cuh b/cpp/include/raft/linalg/gemv.cuh index 8132a742f8..96846003f6 100644 --- a/cpp/include/raft/linalg/gemv.cuh +++ b/cpp/include/raft/linalg/gemv.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ namespace linalg { * @param [in] stream */ template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const bool trans_a, const int m, const int n, @@ -69,7 +69,7 @@ void gemv(const raft::handle_t& handle, } template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows, const int n_cols, @@ -103,7 +103,7 @@ void gemv(const raft::handle_t& handle, * @param stream stream on which this function is run */ template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -133,7 +133,7 @@ void gemv(const raft::handle_t& handle, * @param stream stream on which this function is run */ template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -165,7 +165,7 @@ void gemv(const raft::handle_t& handle, * @param stream stream on which this function is run */ template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -199,7 +199,7 @@ void gemv(const raft::handle_t& handle, * */ template -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, const math_t* A, const int n_rows_a, const int n_cols_a, @@ -246,7 +246,7 @@ template >, std::is_same>>>> -void gemv(const raft::handle_t& handle, +void gemv(raft::device_resources const& handle, raft::device_matrix_view A, raft::device_vector_view x, raft::device_vector_view y, diff --git a/cpp/include/raft/linalg/lstsq.cuh b/cpp/include/raft/linalg/lstsq.cuh index 7654812886..b36a9eba96 100644 --- a/cpp/include/raft/linalg/lstsq.cuh +++ b/cpp/include/raft/linalg/lstsq.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include namespace raft { namespace linalg { @@ -37,7 +37,7 @@ namespace linalg { * @param[in] stream cuda stream for ordering operations */ template -void lstsqSvdQR(const raft::handle_t& handle, +void lstsqSvdQR(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, @@ -62,7 +62,7 @@ void lstsqSvdQR(const raft::handle_t& handle, * @param[in] stream cuda stream for ordering operations */ template -void lstsqSvdJacobi(const raft::handle_t& handle, +void lstsqSvdJacobi(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, @@ -78,7 +78,7 @@ void lstsqSvdJacobi(const raft::handle_t& handle, * (`w = (A^T A)^-1 A^T b`) */ template -void lstsqEig(const raft::handle_t& handle, +void lstsqEig(raft::device_resources const& handle, const math_t* A, const int n_rows, const int n_cols, @@ -104,7 +104,7 @@ void lstsqEig(const raft::handle_t& handle, * @param[in] stream cuda stream for ordering operations */ template -void lstsqQR(const raft::handle_t& handle, +void lstsqQR(raft::device_resources const& handle, math_t* A, const int n_rows, const int n_cols, @@ -125,7 +125,7 @@ void lstsqQR(const raft::handle_t& handle, * Via SVD decomposition of `A = U S Vt`. * * @tparam ValueType the data-type of input/output - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[inout] A input raft::device_matrix_view * Warning: the content of this matrix is modified. * @param[inout] b input target raft::device_vector_view @@ -133,7 +133,7 @@ void lstsqQR(const raft::handle_t& handle, * @param[out] w output coefficient raft::device_vector_view */ template -void lstsq_svd_qr(const raft::handle_t& handle, +void lstsq_svd_qr(raft::device_resources const& handle, raft::device_matrix_view A, raft::device_vector_view b, raft::device_vector_view w) @@ -155,7 +155,7 @@ void lstsq_svd_qr(const raft::handle_t& handle, * Via SVD decomposition of `A = U S V^T` using Jacobi iterations. * * @tparam ValueType the data-type of input/output - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[inout] A input raft::device_matrix_view * Warning: the content of this matrix is modified. * @param[inout] b input target raft::device_vector_view @@ -163,7 +163,7 @@ void lstsq_svd_qr(const raft::handle_t& handle, * @param[out] w output coefficient raft::device_vector_view */ template -void lstsq_svd_jacobi(const raft::handle_t& handle, +void lstsq_svd_jacobi(raft::device_resources const& handle, raft::device_matrix_view A, raft::device_vector_view b, raft::device_vector_view w) @@ -186,7 +186,7 @@ void lstsq_svd_jacobi(const raft::handle_t& handle, * (`w = (A^T A)^-1 A^T b`) * * @tparam ValueType the data-type of input/output - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[inout] A input raft::device_matrix_view * Warning: the content of this matrix is modified by the cuSOLVER routines. * @param[inout] b input target raft::device_vector_view @@ -194,7 +194,7 @@ void lstsq_svd_jacobi(const raft::handle_t& handle, * @param[out] w output coefficient raft::device_vector_view */ template -void lstsq_eig(const raft::handle_t& handle, +void lstsq_eig(raft::device_resources const& handle, raft::device_matrix_view A, raft::device_vector_view b, raft::device_vector_view w) @@ -217,7 +217,7 @@ void lstsq_eig(const raft::handle_t& handle, * (triangular system of equations `Rw = Q^T b`) * * @tparam ValueType the data-type of input/output - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[inout] A input raft::device_matrix_view * Warning: the content of this matrix is modified. * @param[inout] b input target raft::device_vector_view @@ -225,7 +225,7 @@ void lstsq_eig(const raft::handle_t& handle, * @param[out] w output coefficient raft::device_vector_view */ template -void lstsq_qr(const raft::handle_t& handle, +void lstsq_qr(raft::device_resources const& handle, raft::device_matrix_view A, raft::device_vector_view b, raft::device_vector_view w) diff --git a/cpp/include/raft/linalg/map.cuh b/cpp/include/raft/linalg/map.cuh index c2e2e6303a..2b9e6c80a0 100644 --- a/cpp/include/raft/linalg/map.cuh +++ b/cpp/include/raft/linalg/map.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ #include "detail/map.cuh" #include +#include #include #include @@ -66,7 +67,7 @@ void map_k( * @tparam TPB threads-per-block in the final kernel launched * @tparam OutType data-type of result of type raft::device_mdspan * @tparam Args additional parameters - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input of type raft::device_mdspan * @param[out] out the output of the map operation of type raft::device_mdspan * @param[in] map the device-lambda @@ -79,7 +80,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void map(const raft::handle_t& handle, InType in, OutType out, MapOp map, Args... args) +void map(raft::device_resources const& handle, InType in, OutType out, MapOp map, Args... args) { using in_value_t = typename InType::value_type; using out_value_t = typename OutType::value_type; @@ -121,7 +122,7 @@ void map(const raft::handle_t& handle, InType in, OutType out, MapOp map, Args.. template > -void map_offset(const raft::handle_t& handle, OutType out, MapOp op) +void map_offset(const raft::device_resources& handle, OutType out, MapOp op) { RAFT_EXPECTS(raft::is_row_or_column_major(out), "Output must be contiguous"); @@ -136,4 +137,4 @@ void map_offset(const raft::handle_t& handle, OutType out, MapOp op) } // namespace linalg }; // namespace raft -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/linalg/map_reduce.cuh b/cpp/include/raft/linalg/map_reduce.cuh index 4158d35bca..b89f3bdd54 100644 --- a/cpp/include/raft/linalg/map_reduce.cuh +++ b/cpp/include/raft/linalg/map_reduce.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ void mapReduce(OutType* out, * @tparam OutValueType the data-type of the output * @tparam ScalarIdxType index type of scalar * @tparam Args additional parameters - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input of type raft::device_vector_view * @param[in] neutral The neutral element of the reduction operation. For example: * 0 for sum, 1 for multiply, +Inf for Min, -Inf for Max @@ -91,7 +91,7 @@ template -void map_reduce(const raft::handle_t& handle, +void map_reduce(raft::device_resources const& handle, raft::device_vector_view in, raft::device_scalar_view out, OutValueType neutral, diff --git a/cpp/include/raft/linalg/matrix_vector.cuh b/cpp/include/raft/linalg/matrix_vector.cuh index 5529ded16f..fa24ea28b7 100644 --- a/cpp/include/raft/linalg/matrix_vector.cuh +++ b/cpp/include/raft/linalg/matrix_vector.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ namespace raft::linalg { * the rows of the matrix or columns using enum class raft::linalg::Apply */ template -void binary_mult_skip_zero(const raft::handle_t& handle, +void binary_mult_skip_zero(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view vec, Apply apply) @@ -70,7 +70,7 @@ void binary_mult_skip_zero(const raft::handle_t& handle, * the rows of the matrix or columns using enum class raft::linalg::Apply */ template -void binary_div(const raft::handle_t& handle, +void binary_div(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view vec, Apply apply) @@ -105,7 +105,7 @@ void binary_div(const raft::handle_t& handle, * value if false */ template -void binary_div_skip_zero(const raft::handle_t& handle, +void binary_div_skip_zero(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view vec, Apply apply, @@ -140,7 +140,7 @@ void binary_div_skip_zero(const raft::handle_t& handle, * the rows of the matrix or columns using enum class raft::linalg::Apply */ template -void binary_add(const raft::handle_t& handle, +void binary_add(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view vec, Apply apply) @@ -173,7 +173,7 @@ void binary_add(const raft::handle_t& handle, * the rows of the matrix or columns using enum class raft::linalg::Apply */ template -void binary_sub(const raft::handle_t& handle, +void binary_sub(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view vec, Apply apply) diff --git a/cpp/include/raft/linalg/matrix_vector_op.cuh b/cpp/include/raft/linalg/matrix_vector_op.cuh index 8b5163a714..59b2ca5ee5 100644 --- a/cpp/include/raft/linalg/matrix_vector_op.cuh +++ b/cpp/include/raft/linalg/matrix_vector_op.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ void matrixVectorOp(MatT* out, * @tparam LayoutPolicy the layout of input and output (raft::row_major or raft::col_major) * @tparam Lambda a device function which represents a binary operator * @tparam IndexType Integer used for addressing - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] matrix input raft::matrix_view * @param[in] vec vector raft::vector_view * @param[out] out output raft::matrix_view @@ -135,7 +135,7 @@ template -void matrix_vector_op(const raft::handle_t& handle, +void matrix_vector_op(raft::device_resources const& handle, raft::device_matrix_view matrix, raft::device_vector_view vec, raft::device_matrix_view out, @@ -182,7 +182,7 @@ void matrix_vector_op(const raft::handle_t& handle, * @tparam LayoutPolicy the layout of input and output (raft::row_major or raft::col_major) * @tparam Lambda a device function which represents a binary operator * @tparam IndexType Integer used for addressing - * @param handle raft::handle_t + * @param handle raft::device_resources * @param matrix input raft::matrix_view * @param vec1 the first vector raft::vector_view * @param vec2 the second vector raft::vector_view @@ -197,7 +197,7 @@ template -void matrix_vector_op(const raft::handle_t& handle, +void matrix_vector_op(raft::device_resources const& handle, raft::device_matrix_view matrix, raft::device_vector_view vec1, raft::device_vector_view vec2, diff --git a/cpp/include/raft/linalg/mean_squared_error.cuh b/cpp/include/raft/linalg/mean_squared_error.cuh index a3360ae35a..62f4896d01 100644 --- a/cpp/include/raft/linalg/mean_squared_error.cuh +++ b/cpp/include/raft/linalg/mean_squared_error.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,14 +53,14 @@ void meanSquaredError( * @tparam IndexType Input/Output index type * @tparam OutValueType Output data-type * @tparam TPB threads-per-block - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] A input raft::device_vector_view * @param[in] B input raft::device_vector_view * @param[out] out the output mean squared error value of type raft::device_scalar_view * @param[in] weight weight to apply to every term in the mean squared error calculation */ template -void mean_squared_error(const raft::handle_t& handle, +void mean_squared_error(raft::device_resources const& handle, raft::device_vector_view A, raft::device_vector_view B, raft::device_scalar_view out, diff --git a/cpp/include/raft/linalg/multiply.cuh b/cpp/include/raft/linalg/multiply.cuh index 119cf667d1..574b88c63d 100644 --- a/cpp/include/raft/linalg/multiply.cuh +++ b/cpp/include/raft/linalg/multiply.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ void multiplyScalar(out_t* out, const in_t* in, in_t scalar, IdxType len, cudaSt * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input buffer * @param[out] out the output buffer * @param[in] scalar the scalar used in the operations @@ -68,7 +68,7 @@ template , typename = raft::enable_if_output_device_mdspan> void multiply_scalar( - const raft::handle_t& handle, + raft::device_resources const& handle, InType in, OutType out, raft::host_scalar_view scalar) diff --git a/cpp/include/raft/linalg/norm.cuh b/cpp/include/raft/linalg/norm.cuh index b64b128fa2..8bc6720b4e 100644 --- a/cpp/include/raft/linalg/norm.cuh +++ b/cpp/include/raft/linalg/norm.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +99,7 @@ void colNorm(Type* dots, * @tparam LayoutPolicy the layout of input (raft::row_major or raft::col_major) * @tparam IdxType Integer type used to for addressing * @tparam Lambda device final lambda - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input raft::device_matrix_view * @param[out] out the output raft::device_vector_view * @param[in] type the type of norm to be applied @@ -111,7 +111,7 @@ template -void norm(const raft::handle_t& handle, +void norm(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view out, NormType type, diff --git a/cpp/include/raft/linalg/normalize.cuh b/cpp/include/raft/linalg/normalize.cuh index bf6ef5a570..027ebb16e8 100644 --- a/cpp/include/raft/linalg/normalize.cuh +++ b/cpp/include/raft/linalg/normalize.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ namespace linalg { * @tparam MainLambda Type of main_op * @tparam ReduceLambda Type of reduce_op * @tparam FinalLambda Type of fin_op - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input raft::device_matrix_view * @param[out] out the output raft::device_matrix_view * @param[in] init Initialization value, i.e identity element for the reduction operation @@ -52,7 +52,7 @@ template -void row_normalize(const raft::handle_t& handle, +void row_normalize(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, ElementType init, @@ -85,14 +85,14 @@ void row_normalize(const raft::handle_t& handle, * * @tparam ElementType Input/Output data type * @tparam IndexType Integer type used to for addressing - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in the input raft::device_matrix_view * @param[out] out the output raft::device_matrix_view * @param[in] norm_type the type of norm to be applied * @param[in] eps If the norm is below eps, the row is considered zero and no division is applied */ template -void row_normalize(const raft::handle_t& handle, +void row_normalize(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, NormType norm_type, diff --git a/cpp/include/raft/linalg/power.cuh b/cpp/include/raft/linalg/power.cuh index 59c2cdf314..1fdfcb3780 100644 --- a/cpp/include/raft/linalg/power.cuh +++ b/cpp/include/raft/linalg/power.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ void power(out_t* out, const in_t* in1, const in_t* in2, IdxType len, cudaStream * @brief Elementwise power operation on the input buffers * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in1 First Input * @param[in] in2 Second Input * @param[out] out Output @@ -82,7 +82,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void power(const raft::handle_t& handle, InType in1, InType in2, OutType out) +void power(raft::device_resources const& handle, InType in1, InType in2, OutType out) { using in_value_t = typename InType::value_type; using out_value_t = typename OutType::value_type; @@ -113,7 +113,7 @@ void power(const raft::handle_t& handle, InType in1, InType in2, OutType out) * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[out] out Output * @param[in] scalar raft::host_scalar_view @@ -124,7 +124,7 @@ template , typename = raft::enable_if_output_device_mdspan> void power_scalar( - const raft::handle_t& handle, + raft::device_resources const& handle, InType in, OutType out, const raft::host_scalar_view scalar) diff --git a/cpp/include/raft/linalg/qr.cuh b/cpp/include/raft/linalg/qr.cuh index 7c5c0ea628..8e58af63c1 100644 --- a/cpp/include/raft/linalg/qr.cuh +++ b/cpp/include/raft/linalg/qr.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ namespace linalg { * @param stream cuda stream */ template -void qrGetQ(const raft::handle_t& handle, +void qrGetQ(raft::device_resources const& handle, const math_t* M, math_t* Q, int n_rows, @@ -54,7 +54,7 @@ void qrGetQ(const raft::handle_t& handle, * @param stream cuda stream */ template -void qrGetQR(const raft::handle_t& handle, +void qrGetQR(raft::device_resources const& handle, math_t* M, math_t* Q, math_t* R, @@ -72,12 +72,12 @@ void qrGetQR(const raft::handle_t& handle, /** * @brief Compute the QR decomposition of matrix M and return only the Q matrix. - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M Input raft::device_matrix_view * @param[out] Q Output raft::device_matrix_view */ template -void qr_get_q(const raft::handle_t& handle, +void qr_get_q(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_matrix_view Q) { @@ -88,13 +88,13 @@ void qr_get_q(const raft::handle_t& handle, /** * @brief Compute the QR decomposition of matrix M and return both the Q and R matrices. - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M Input raft::device_matrix_view * @param[in] Q Output raft::device_matrix_view * @param[out] R Output raft::device_matrix_view */ template -void qr_get_qr(const raft::handle_t& handle, +void qr_get_qr(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_matrix_view Q, raft::device_matrix_view R) diff --git a/cpp/include/raft/linalg/reduce.cuh b/cpp/include/raft/linalg/reduce.cuh index 3eb8196408..ae5457c44f 100644 --- a/cpp/include/raft/linalg/reduce.cuh +++ b/cpp/include/raft/linalg/reduce.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ void reduce(OutType* dots, * @tparam FinalLambda the final lambda applied before STG (eg: Sqrt for L2 norm) * It must be a 'callable' supporting the following input and output: *
OutType (*FinalLambda)(OutType);
- * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] data Input of type raft::device_matrix_view * @param[out] dots Output of type raft::device_matrix_view * @param[in] init initial value to use for the reduction @@ -122,7 +122,7 @@ template -void reduce(const raft::handle_t& handle, +void reduce(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view dots, OutElementType init, diff --git a/cpp/include/raft/linalg/reduce_cols_by_key.cuh b/cpp/include/raft/linalg/reduce_cols_by_key.cuh index 7b0ad2f984..2b744d8134 100644 --- a/cpp/include/raft/linalg/reduce_cols_by_key.cuh +++ b/cpp/include/raft/linalg/reduce_cols_by_key.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "detail/reduce_cols_by_key.cuh" #include -#include +#include namespace raft { namespace linalg { @@ -69,7 +69,7 @@ void reduce_cols_by_key(const T* data, * @tparam ElementType the input data type (as well as the output reduced matrix) * @tparam KeyType data type of the keys * @tparam IndexType indexing arithmetic type - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] data the input data (dim = nrows x ncols). This is assumed to be in * row-major layout of type raft::device_matrix_view * @param[in] keys keys raft::device_vector_view (len = ncols). It is assumed that each key in this @@ -84,7 +84,7 @@ void reduce_cols_by_key(const T* data, */ template void reduce_cols_by_key( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view keys, raft::device_matrix_view out, diff --git a/cpp/include/raft/linalg/reduce_rows_by_key.cuh b/cpp/include/raft/linalg/reduce_rows_by_key.cuh index 1dabd92087..484b60238b 100644 --- a/cpp/include/raft/linalg/reduce_rows_by_key.cuh +++ b/cpp/include/raft/linalg/reduce_rows_by_key.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "detail/reduce_rows_by_key.cuh" #include -#include +#include namespace raft { namespace linalg { @@ -136,7 +136,7 @@ void reduce_rows_by_key(const DataIteratorT d_A, * @tparam KeyType data-type of keys * @tparam WeightType data-type of weights * @tparam IndexType index type - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] d_A Input raft::device_mdspan (ncols * nrows) * @param[in] d_keys Keys for each row raft::device_vector_view (1 x nrows) * @param[out] d_sums Row sums by key raft::device_matrix_view (ncols x d_keys) @@ -148,7 +148,7 @@ void reduce_rows_by_key(const DataIteratorT d_A, */ template void reduce_rows_by_key( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view d_A, raft::device_vector_view d_keys, raft::device_matrix_view d_sums, diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index 6f0315642b..eb94547f13 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ namespace linalg { * @param stream cuda stream */ template -void rsvdFixedRank(const raft::handle_t& handle, +void rsvdFixedRank(raft::device_resources const& handle, math_t* M, int n_rows, int n_cols, @@ -104,7 +104,7 @@ void rsvdFixedRank(const raft::handle_t& handle, * @param stream cuda stream */ template -void rsvdPerc(const raft::handle_t& handle, +void rsvdPerc(raft::device_resources const& handle, math_t* M, int n_rows, int n_cols, @@ -154,7 +154,7 @@ void rsvdPerc(const raft::handle_t& handle, * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples @@ -164,7 +164,7 @@ void rsvdPerc(const raft::handle_t& handle, * raft::col_major */ template -void rsvd_fixed_rank(const raft::handle_t& handle, +void rsvd_fixed_rank(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, IndexType p, @@ -228,7 +228,7 @@ void rsvd_fixed_rank(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples @@ -239,7 +239,7 @@ void rsvd_fixed_rank(Args... args) */ template void rsvd_fixed_rank_symmetric( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, IndexType p, @@ -303,7 +303,7 @@ void rsvd_fixed_rank_symmetric(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples @@ -315,7 +315,7 @@ void rsvd_fixed_rank_symmetric(Args... args) * raft::col_major */ template -void rsvd_fixed_rank_jacobi(const raft::handle_t& handle, +void rsvd_fixed_rank_jacobi(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, IndexType p, @@ -381,7 +381,7 @@ void rsvd_fixed_rank_jacobi(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples @@ -394,7 +394,7 @@ void rsvd_fixed_rank_jacobi(Args... args) */ template void rsvd_fixed_rank_symmetric_jacobi( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, IndexType p, @@ -460,7 +460,7 @@ void rsvd_fixed_rank_symmetric_jacobi(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed @@ -471,7 +471,7 @@ void rsvd_fixed_rank_symmetric_jacobi(Args... args) * raft::col_major */ template -void rsvd_perc(const raft::handle_t& handle, +void rsvd_perc(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, ValueType PC_perc, @@ -536,7 +536,7 @@ void rsvd_perc(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed @@ -547,7 +547,7 @@ void rsvd_perc(Args... args) * raft::col_major */ template -void rsvd_perc_symmetric(const raft::handle_t& handle, +void rsvd_perc_symmetric(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, ValueType PC_perc, @@ -612,7 +612,7 @@ void rsvd_perc_symmetric(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed @@ -625,7 +625,7 @@ void rsvd_perc_symmetric(Args... args) * raft::col_major */ template -void rsvd_perc_jacobi(const raft::handle_t& handle, +void rsvd_perc_jacobi(raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, ValueType PC_perc, @@ -692,7 +692,7 @@ void rsvd_perc_jacobi(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed @@ -706,7 +706,7 @@ void rsvd_perc_jacobi(Args... args) */ template void rsvd_perc_symmetric_jacobi( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, ValueType PC_perc, diff --git a/cpp/include/raft/linalg/sqrt.cuh b/cpp/include/raft/linalg/sqrt.cuh index ad6cad2eb2..55e661897d 100644 --- a/cpp/include/raft/linalg/sqrt.cuh +++ b/cpp/include/raft/linalg/sqrt.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ void sqrt(out_t* out, const in_t* in, IdxType len, cudaStream_t stream) * @brief Elementwise sqrt operation * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[out] out Output */ @@ -59,7 +59,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void sqrt(const raft::handle_t& handle, InType in, OutType out) +void sqrt(raft::device_resources const& handle, InType in, OutType out) { using in_value_t = typename InType::value_type; using out_value_t = typename OutType::value_type; diff --git a/cpp/include/raft/linalg/strided_reduction.cuh b/cpp/include/raft/linalg/strided_reduction.cuh index d9c26910e7..d282a2e1fa 100644 --- a/cpp/include/raft/linalg/strided_reduction.cuh +++ b/cpp/include/raft/linalg/strided_reduction.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ void stridedReduction(OutType* dots, * @tparam FinalLambda the final lambda applied before STG (eg: Sqrt for L2 norm) * It must be a 'callable' supporting the following input and output: *
OutType (*FinalLambda)(OutType);
- * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] data Input of type raft::device_matrix_view * @param[out] dots Output of type raft::device_matrix_view * @param[in] init initial value to use for the reduction @@ -128,7 +128,7 @@ template -void strided_reduction(const raft::handle_t& handle, +void strided_reduction(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view dots, OutValueType init, diff --git a/cpp/include/raft/linalg/subtract.cuh b/cpp/include/raft/linalg/subtract.cuh index e6f2fa8724..da995b7a2a 100644 --- a/cpp/include/raft/linalg/subtract.cuh +++ b/cpp/include/raft/linalg/subtract.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ void subtractDevScalar(math_t* outDev, * @brief Elementwise subtraction operation on the input buffers * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan - * @param handle raft::handle_t + * @param handle raft::device_resources * @param[in] in1 First Input * @param[in] in2 Second Input * @param[out] out Output @@ -106,7 +106,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void subtract(const raft::handle_t& handle, InType in1, InType in2, OutType out) +void subtract(raft::device_resources const& handle, InType in1, InType in2, OutType out) { using in_value_t = typename InType::value_type; using out_value_t = typename OutType::value_type; @@ -137,7 +137,7 @@ void subtract(const raft::handle_t& handle, InType in1, InType in2, OutType out) * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[out] out Output * @param[in] scalar raft::device_scalar_view @@ -148,7 +148,7 @@ template , typename = raft::enable_if_output_device_mdspan> void subtract_scalar( - const raft::handle_t& handle, + raft::device_resources const& handle, InType in, OutType out, raft::device_scalar_view scalar) @@ -182,7 +182,7 @@ void subtract_scalar( * @tparam InType Input Type raft::device_mdspan * @tparam OutType Output Type raft::device_mdspan * @tparam ScalarIdxType Index Type of scalar - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in Input * @param[out] out Output * @param[in] scalar raft::host_scalar_view @@ -193,7 +193,7 @@ template , typename = raft::enable_if_output_device_mdspan> void subtract_scalar( - const raft::handle_t& handle, + raft::device_resources const& handle, InType in, OutType out, raft::host_scalar_view scalar) diff --git a/cpp/include/raft/linalg/svd.cuh b/cpp/include/raft/linalg/svd.cuh index 2c1b5a5cb7..eb51093240 100644 --- a/cpp/include/raft/linalg/svd.cuh +++ b/cpp/include/raft/linalg/svd.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ namespace linalg { * @param stream cuda stream */ template -void svdQR(const raft::handle_t& handle, +void svdQR(raft::device_resources const& handle, T* in, int n_rows, int n_cols, @@ -67,7 +67,7 @@ void svdQR(const raft::handle_t& handle, } template -void svdEig(const raft::handle_t& handle, +void svdEig(raft::device_resources const& handle, math_t* in, idx_t n_rows, idx_t n_cols, @@ -98,7 +98,7 @@ void svdEig(const raft::handle_t& handle, * @param stream cuda stream */ template -void svdJacobi(const raft::handle_t& handle, +void svdJacobi(raft::device_resources const& handle, math_t* in, int n_rows, int n_cols, @@ -139,7 +139,7 @@ void svdJacobi(const raft::handle_t& handle, * @param stream cuda stream */ template -void svdReconstruction(const raft::handle_t& handle, +void svdReconstruction(raft::device_resources const& handle, math_t* U, math_t* S, math_t* V, @@ -167,7 +167,7 @@ void svdReconstruction(const raft::handle_t& handle, * @param stream cuda stream */ template -bool evaluateSVDByL2Norm(const raft::handle_t& handle, +bool evaluateSVDByL2Norm(raft::device_resources const& handle, math_t* A_d, math_t* U, math_t* S_vec, @@ -195,7 +195,7 @@ bool evaluateSVDByL2Norm(const raft::handle_t& handle, * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout @@ -204,7 +204,7 @@ bool evaluateSVDByL2Norm(const raft::handle_t& handle, * layout raft::col_major and dimensions (n, n) */ template -void svd_qr(const raft::handle_t& handle, +void svd_qr(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view sing_vals, UType&& U_in, @@ -258,7 +258,7 @@ void svd_qr(Args... args) * U_in * @tparam VType std::optional> @c * V_in - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout @@ -268,7 +268,7 @@ void svd_qr(Args... args) */ template void svd_qr_transpose_right_vec( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view sing_vals, UType&& U_in, @@ -316,7 +316,7 @@ void svd_qr_transpose_right_vec(Args... args) /** * @brief singular value decomposition (SVD) on a column major * matrix using Eigen decomposition. A square symmetric covariance matrix is constructed for the SVD - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S singular values raft::device_vector_view of shape (K) * @param[out] V right singular values of raft::device_matrix_view with layout @@ -326,7 +326,7 @@ void svd_qr_transpose_right_vec(Args... args) */ template void svd_eig( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view S, raft::device_matrix_view V, @@ -352,7 +352,7 @@ void svd_eig( /** * @brief reconstruct a matrix use left and right singular vectors and * singular values - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] U left singular values of raft::device_matrix_view with layout * raft::col_major and dimensions (m, k) * @param[in] S singular values raft::device_vector_view of shape (k, k) @@ -361,7 +361,7 @@ void svd_eig( * @param[out] out output raft::device_matrix_view with layout raft::col_major of shape (m, n) */ template -void svd_reconstruction(const raft::handle_t& handle, +void svd_reconstruction(raft::device_resources const& handle, raft::device_matrix_view U, raft::device_vector_view S, raft::device_matrix_view V, diff --git a/cpp/include/raft/linalg/ternary_op.cuh b/cpp/include/raft/linalg/ternary_op.cuh index 10e91a0313..aa3859bc23 100644 --- a/cpp/include/raft/linalg/ternary_op.cuh +++ b/cpp/include/raft/linalg/ternary_op.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include "detail/ternary_op.cuh" #include -#include +#include #include namespace raft { @@ -63,7 +63,7 @@ void ternaryOp(out_t* out, * @tparam InType Input Type raft::device_mdspan * @tparam Lambda the device-lambda performing the actual operation * @tparam OutType Output Type raft::device_mdspan - * @param[in] handle raft::handle_t + * @param[in] handle raft::device_resources * @param[in] in1 First input * @param[in] in2 Second input * @param[in] in3 Third input @@ -78,7 +78,7 @@ template , typename = raft::enable_if_output_device_mdspan> void ternary_op( - const raft::handle_t& handle, InType in1, InType in2, InType in3, OutType out, Lambda op) + raft::device_resources const& handle, InType in1, InType in2, InType in3, OutType out, Lambda op) { RAFT_EXPECTS(raft::is_row_or_column_major(out), "Output must be contiguous"); RAFT_EXPECTS(raft::is_row_or_column_major(in1), "Input 1 must be contiguous"); diff --git a/cpp/include/raft/linalg/transpose.cuh b/cpp/include/raft/linalg/transpose.cuh index 608a87b489..a0f418b4f7 100644 --- a/cpp/include/raft/linalg/transpose.cuh +++ b/cpp/include/raft/linalg/transpose.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ namespace linalg { * @param stream: cuda stream */ template -void transpose(const raft::handle_t& handle, +void transpose(raft::device_resources const& handle, math_t* in, math_t* out, int n_rows, @@ -76,7 +76,7 @@ void transpose(math_t* inout, int n, cudaStream_t stream) * @param[out] out Output matirx, storage is pre-allocated by caller. */ template -auto transpose(handle_t const& handle, +auto transpose(raft::device_resources const& handle, raft::mdspan, LayoutPolicy, AccessorPolicy> in, raft::mdspan, LayoutPolicy, AccessorPolicy> out) -> std::enable_if_t, void> diff --git a/cpp/include/raft/linalg/unary_op.cuh b/cpp/include/raft/linalg/unary_op.cuh index e39821cf80..ce102adfd2 100644 --- a/cpp/include/raft/linalg/unary_op.cuh +++ b/cpp/include/raft/linalg/unary_op.cuh @@ -21,7 +21,7 @@ #include "detail/unary_op.cuh" #include -#include +#include #include namespace raft { @@ -95,7 +95,7 @@ template , typename = raft::enable_if_output_device_mdspan> -void unary_op(const raft::handle_t& handle, InType in, OutType out, Lambda op) +void unary_op(raft::device_resources const& handle, InType in, OutType out, Lambda op) { RAFT_EXPECTS(raft::is_row_or_column_major(out), "Output must be contiguous"); RAFT_EXPECTS(raft::is_row_or_column_major(in), "Input must be contiguous"); @@ -128,7 +128,7 @@ void unary_op(const raft::handle_t& handle, InType in, OutType out, Lambda op) template > -void write_only_unary_op(const raft::handle_t& handle, OutType out, Lambda op) +void write_only_unary_op(const raft::device_resources& handle, OutType out, Lambda op) { RAFT_EXPECTS(raft::is_row_or_column_major(out), "Output must be contiguous"); @@ -148,4 +148,4 @@ void write_only_unary_op(const raft::handle_t& handle, OutType out, Lambda op) }; // end namespace linalg }; // end namespace raft -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/matrix/argmax.cuh b/cpp/include/raft/matrix/argmax.cuh index a614f7043f..433c161079 100644 --- a/cpp/include/raft/matrix/argmax.cuh +++ b/cpp/include/raft/matrix/argmax.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ namespace raft::matrix { * @param[out] out: output vector of size n_rows */ template -void argmax(const raft::handle_t& handle, +void argmax(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view out) { diff --git a/cpp/include/raft/matrix/argmin.cuh b/cpp/include/raft/matrix/argmin.cuh index ca7b0252d2..31ef0c1c1b 100644 --- a/cpp/include/raft/matrix/argmin.cuh +++ b/cpp/include/raft/matrix/argmin.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ namespace raft::matrix { * @param[out] out: output vector of size n_rows */ template -void argmin(const raft::handle_t& handle, +void argmin(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_vector_view out) { diff --git a/cpp/include/raft/matrix/col_wise_sort.cuh b/cpp/include/raft/matrix/col_wise_sort.cuh index 662f62d865..a4daf097e5 100644 --- a/cpp/include/raft/matrix/col_wise_sort.cuh +++ b/cpp/include/raft/matrix/col_wise_sort.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ void sort_cols_per_row(const InType* in, * @param[out] sorted_keys_opt: std::optional, output matrix for sorted keys (input) */ template -void sort_cols_per_row(const raft::handle_t& handle, +void sort_cols_per_row(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, sorted_keys_t&& sorted_keys_opt) diff --git a/cpp/include/raft/matrix/copy.cuh b/cpp/include/raft/matrix/copy.cuh index 0727fac246..42d2562e5e 100644 --- a/cpp/include/raft/matrix/copy.cuh +++ b/cpp/include/raft/matrix/copy.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ namespace raft::matrix { * @param[in] indices of the rows to be copied */ template -void copy_rows(const raft::handle_t& handle, +void copy_rows(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, raft::device_vector_view indices) @@ -65,7 +65,7 @@ void copy_rows(const raft::handle_t& handle, * @param[out] out: output matrix */ template -void copy(const raft::handle_t& handle, +void copy(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out) { @@ -84,7 +84,7 @@ void copy(const raft::handle_t& handle, * @param out: output matrix */ template -void trunc_zero_origin(const raft::handle_t& handle, +void trunc_zero_origin(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out) { diff --git a/cpp/include/raft/matrix/detail/math.cuh b/cpp/include/raft/matrix/detail/math.cuh index f5c33d1cf6..96398e9c74 100644 --- a/cpp/include/raft/matrix/detail/math.cuh +++ b/cpp/include/raft/matrix/detail/math.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include @@ -194,7 +194,7 @@ void setValue(math_t* out, const math_t* in, math_t scalar, int len, cudaStream_ template void ratio( - const raft::handle_t& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) + raft::device_resources const& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) { auto d_src = src; auto d_dest = dest; diff --git a/cpp/include/raft/matrix/detail/matrix.cuh b/cpp/include/raft/matrix/detail/matrix.cuh index 17a40be5d6..ef3a873d90 100644 --- a/cpp/include/raft/matrix/detail/matrix.cuh +++ b/cpp/include/raft/matrix/detail/matrix.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -299,7 +299,7 @@ void getDiagonalInverseMatrix(m_t* in, idx_t len, cudaStream_t stream) } template -m_t getL2Norm(const raft::handle_t& handle, const m_t* in, idx_t size, cudaStream_t stream) +m_t getL2Norm(raft::device_resources const& handle, const m_t* in, idx_t size, cudaStream_t stream) { cublasHandle_t cublasH = handle.get_cublas_handle(); m_t normval = 0; diff --git a/cpp/include/raft/matrix/detail/print.hpp b/cpp/include/raft/matrix/detail/print.hpp index fc3d14861c..814c6a0b4b 100644 --- a/cpp/include/raft/matrix/detail/print.hpp +++ b/cpp/include/raft/matrix/detail/print.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpp/include/raft/matrix/diagonal.cuh b/cpp/include/raft/matrix/diagonal.cuh index 22862e43b6..22147e9f34 100644 --- a/cpp/include/raft/matrix/diagonal.cuh +++ b/cpp/include/raft/matrix/diagonal.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ namespace raft::matrix { * @param[out] matrix: matrix of size n_rows x n_cols */ template -void set_diagonal(const raft::handle_t& handle, +void set_diagonal(raft::device_resources const& handle, raft::device_vector_view vec, raft::device_matrix_view matrix) { @@ -55,7 +55,7 @@ void set_diagonal(const raft::handle_t& handle, * @param[out] vec: vector of length k = min(n_rows, n_cols) */ template -void get_diagonal(const raft::handle_t& handle, +void get_diagonal(raft::device_resources const& handle, raft::device_matrix_view matrix, raft::device_vector_view vec) { @@ -74,7 +74,7 @@ void get_diagonal(const raft::handle_t& handle, * @param[inout] inout: square input matrix with size len x len */ template -void invert_diagonal(const raft::handle_t& handle, +void invert_diagonal(raft::device_resources const& handle, raft::device_matrix_view inout) { // TODO: Use get_diagonal for this to support rectangular diff --git a/cpp/include/raft/matrix/gather.cuh b/cpp/include/raft/matrix/gather.cuh index 9487da35b5..7710789bfe 100644 --- a/cpp/include/raft/matrix/gather.cuh +++ b/cpp/include/raft/matrix/gather.cuh @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include @@ -210,7 +210,7 @@ template -void gather(const raft::handle_t& handle, +void gather(const raft::device_resources& handle, raft::device_matrix_view in, raft::device_vector_view map, raft::device_matrix_view out, @@ -261,7 +261,7 @@ template -void gather_if(const raft::handle_t& handle, +void gather_if(const raft::device_resources& handle, raft::device_matrix_view in, raft::device_matrix_view out, raft::device_vector_view map, diff --git a/cpp/include/raft/matrix/init.cuh b/cpp/include/raft/matrix/init.cuh index faf65a96fd..f597bbd1c6 100644 --- a/cpp/include/raft/matrix/init.cuh +++ b/cpp/include/raft/matrix/init.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ namespace raft::matrix { * @param[in] scalar scalar value to fill matrix elements */ template -void fill(const raft::handle_t& handle, +void fill(raft::device_resources const& handle, raft::device_mdspan in, raft::device_mdspan out, raft::host_scalar_view scalar) @@ -61,7 +61,7 @@ void fill(const raft::handle_t& handle, * @param[in] scalar scalar value to fill matrix elements */ template -void fill(const raft::handle_t& handle, +void fill(raft::device_resources const& handle, raft::device_mdspan inout, math_t scalar) { diff --git a/cpp/include/raft/matrix/linewise_op.cuh b/cpp/include/raft/matrix/linewise_op.cuh index cd80b539c4..33de112a35 100644 --- a/cpp/include/raft/matrix/linewise_op.cuh +++ b/cpp/include/raft/matrix/linewise_op.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ template > -void linewise_op(const raft::handle_t& handle, +void linewise_op(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, const bool alongLines, @@ -97,7 +97,7 @@ template > -void linewise_op(const raft::handle_t& handle, +void linewise_op(raft::device_resources const& handle, raft::device_aligned_matrix_view in, raft::device_aligned_matrix_view out, const bool alongLines, diff --git a/cpp/include/raft/matrix/math.cuh b/cpp/include/raft/matrix/math.cuh index fd5ddf2df3..7afb9572be 100644 --- a/cpp/include/raft/matrix/math.cuh +++ b/cpp/include/raft/matrix/math.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -295,7 +295,7 @@ void setValue(math_t* out, const math_t* in, math_t scalar, int len, cudaStream_ */ template void ratio( - const raft::handle_t& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) + raft::device_resources const& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) { detail::ratio(handle, src, dest, len, stream); } diff --git a/cpp/include/raft/matrix/matrix.cuh b/cpp/include/raft/matrix/matrix.cuh index cd6c4fa219..0780e41275 100644 --- a/cpp/include/raft/matrix/matrix.cuh +++ b/cpp/include/raft/matrix/matrix.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ void copy(const m_t* in, m_t* out, idx_t n_rows, idx_t n_cols, cudaStream_t stre * @param[out] out: output matrix */ template -void copy(const raft::handle_t& handle, +void copy(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out) { @@ -252,7 +252,7 @@ void getDiagonalInverseMatrix(m_t* in, idx_t len, cudaStream_t stream) * @param stream: cuda stream */ template -m_t getL2Norm(const raft::handle_t& handle, m_t* in, idx_t size, cudaStream_t stream) +m_t getL2Norm(raft::device_resources const& handle, m_t* in, idx_t size, cudaStream_t stream) { return detail::getL2Norm(handle, in, size, stream); } diff --git a/cpp/include/raft/matrix/norm.cuh b/cpp/include/raft/matrix/norm.cuh index c37b3995d8..eb94a19669 100644 --- a/cpp/include/raft/matrix/norm.cuh +++ b/cpp/include/raft/matrix/norm.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ namespace raft::matrix { * @returns matrix l2 norm */ template -m_t l2_norm(const raft::handle_t& handle, raft::device_mdspan in) +m_t l2_norm(raft::device_resources const& handle, raft::device_mdspan in) { return detail::getL2Norm(handle, in.data_handle(), in.size(), handle.get_stream()); } diff --git a/cpp/include/raft/matrix/power.cuh b/cpp/include/raft/matrix/power.cuh index 2bdbd475ca..c7c3757193 100644 --- a/cpp/include/raft/matrix/power.cuh +++ b/cpp/include/raft/matrix/power.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ namespace raft::matrix { * @param[in] scalar: every element is multiplied with scalar. */ template -void weighted_power(const raft::handle_t& handle, +void weighted_power(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, math_t scalar) @@ -56,7 +56,7 @@ void weighted_power(const raft::handle_t& handle, * @param[in] scalar: every element is multiplied with scalar. */ template -void weighted_power(const raft::handle_t& handle, +void weighted_power(raft::device_resources const& handle, raft::device_matrix_view inout, math_t scalar) { @@ -72,7 +72,8 @@ void weighted_power(const raft::handle_t& handle, * @param[inout] inout: input matrix and also the result is stored */ template -void power(const raft::handle_t& handle, raft::device_matrix_view inout) +void power(raft::device_resources const& handle, + raft::device_matrix_view inout) { detail::power(inout.data_handle(), inout.size(), handle.get_stream()); } @@ -88,7 +89,7 @@ void power(const raft::handle_t& handle, raft::device_matrix_view -void power(const raft::handle_t& handle, +void power(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out) { diff --git a/cpp/include/raft/matrix/print.cuh b/cpp/include/raft/matrix/print.cuh index 935af8233b..6a4bfbdd01 100644 --- a/cpp/include/raft/matrix/print.cuh +++ b/cpp/include/raft/matrix/print.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ namespace raft::matrix { * @param[in] separators: horizontal and vertical separator characters */ template -void print(const raft::handle_t& handle, +void print(raft::device_resources const& handle, raft::device_matrix_view in, print_separators& separators) { diff --git a/cpp/include/raft/matrix/ratio.cuh b/cpp/include/raft/matrix/ratio.cuh index 2e449698d5..cd96d1ffbc 100644 --- a/cpp/include/raft/matrix/ratio.cuh +++ b/cpp/include/raft/matrix/ratio.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ namespace raft::matrix { * @param[out] dest: output matrix. The result is stored in the dest matrix */ template -void ratio(const raft::handle_t& handle, +void ratio(raft::device_resources const& handle, raft::device_matrix_view src, raft::device_matrix_view dest) { @@ -53,7 +53,8 @@ void ratio(const raft::handle_t& handle, * @param[inout] inout: input matrix */ template -void ratio(const raft::handle_t& handle, raft::device_matrix_view inout) +void ratio(raft::device_resources const& handle, + raft::device_matrix_view inout) { detail::ratio( handle, inout.data_handle(), inout.data_handle(), inout.size(), handle.get_stream()); diff --git a/cpp/include/raft/matrix/reciprocal.cuh b/cpp/include/raft/matrix/reciprocal.cuh index f50216a153..aa2c48e143 100644 --- a/cpp/include/raft/matrix/reciprocal.cuh +++ b/cpp/include/raft/matrix/reciprocal.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ namespace raft::matrix { * @{ */ template -void reciprocal(const raft::handle_t& handle, +void reciprocal(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, raft::host_scalar_view scalar, @@ -70,7 +70,7 @@ void reciprocal(const raft::handle_t& handle, * @{ */ template -void reciprocal(const raft::handle_t& handle, +void reciprocal(raft::device_resources const& handle, raft::device_matrix_view inout, raft::host_scalar_view scalar, bool setzero = false, diff --git a/cpp/include/raft/matrix/reverse.cuh b/cpp/include/raft/matrix/reverse.cuh index 6f1235b059..3aaec56fee 100644 --- a/cpp/include/raft/matrix/reverse.cuh +++ b/cpp/include/raft/matrix/reverse.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,8 @@ namespace raft::matrix { * @param[inout] inout: input and output matrix */ template -void col_reverse(const raft::handle_t& handle, raft::device_matrix_view inout) +void col_reverse(raft::device_resources const& handle, + raft::device_matrix_view inout) { RAFT_EXPECTS(raft::is_row_or_column_major(inout), "Unsupported matrix layout"); if (raft::is_col_major(inout)) { @@ -51,7 +52,8 @@ void col_reverse(const raft::handle_t& handle, raft::device_matrix_view -void row_reverse(const raft::handle_t& handle, raft::device_matrix_view inout) +void row_reverse(raft::device_resources const& handle, + raft::device_matrix_view inout) { RAFT_EXPECTS(raft::is_row_or_column_major(inout), "Unsupported matrix layout"); if (raft::is_col_major(inout)) { diff --git a/cpp/include/raft/matrix/select_k.cuh b/cpp/include/raft/matrix/select_k.cuh index e40fc57e76..9a1a14fd73 100644 --- a/cpp/include/raft/matrix/select_k.cuh +++ b/cpp/include/raft/matrix/select_k.cuh @@ -19,7 +19,7 @@ #include "detail/select_k.cuh" #include -#include +#include #include #include @@ -75,7 +75,7 @@ namespace raft::matrix { * whether to select k smallest (true) or largest (false) keys. */ template -void select_k(const handle_t& handle, +void select_k(const device_resources& handle, raft::device_matrix_view in_val, std::optional> in_idx, raft::device_matrix_view out_val, diff --git a/cpp/include/raft/matrix/sign_flip.cuh b/cpp/include/raft/matrix/sign_flip.cuh index 8cabfb37a2..d069c55880 100644 --- a/cpp/include/raft/matrix/sign_flip.cuh +++ b/cpp/include/raft/matrix/sign_flip.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ namespace raft::matrix { * @param[inout] inout: input matrix. Result also stored in this parameter */ template -void sign_flip(const raft::handle_t& handle, +void sign_flip(raft::device_resources const& handle, raft::device_matrix_view inout) { detail::signFlip(inout.data_handle(), inout.extent(0), inout.extent(1), handle.get_stream()); diff --git a/cpp/include/raft/matrix/slice.cuh b/cpp/include/raft/matrix/slice.cuh index 016f762a70..bb92b2b86f 100644 --- a/cpp/include/raft/matrix/slice.cuh +++ b/cpp/include/raft/matrix/slice.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ struct slice_coordinates { * example: Slice the 2nd and 3rd columns of a 4x3 matrix: slice(handle, in, out, {0, 1, 4, 3}); */ template -void slice(const raft::handle_t& handle, +void slice(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, slice_coordinates coords) diff --git a/cpp/include/raft/matrix/sqrt.cuh b/cpp/include/raft/matrix/sqrt.cuh index ca9b280773..9729f9b3d5 100644 --- a/cpp/include/raft/matrix/sqrt.cuh +++ b/cpp/include/raft/matrix/sqrt.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ namespace raft::matrix { * @param[out] out: output matrix. The result is stored in the out matrix */ template -void sqrt(const raft::handle_t& handle, +void sqrt(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out) { @@ -55,7 +55,8 @@ void sqrt(const raft::handle_t& handle, * @param[inout] inout: input matrix with in-place results */ template -void sqrt(const raft::handle_t& handle, raft::device_matrix_view inout) +void sqrt(raft::device_resources const& handle, + raft::device_matrix_view inout) { detail::seqRoot(inout.data_handle(), inout.size(), handle.get_stream()); } @@ -72,7 +73,7 @@ void sqrt(const raft::handle_t& handle, raft::device_matrix_view -void weighted_sqrt(const raft::handle_t& handle, +void weighted_sqrt(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, raft::host_scalar_view scalar, @@ -98,7 +99,7 @@ void weighted_sqrt(const raft::handle_t& handle, * @param[in] set_neg_zero whether to set negative numbers to zero */ template -void weighted_sqrt(const raft::handle_t& handle, +void weighted_sqrt(raft::device_resources const& handle, raft::device_matrix_view inout, raft::host_scalar_view scalar, bool set_neg_zero = false) diff --git a/cpp/include/raft/matrix/threshold.cuh b/cpp/include/raft/matrix/threshold.cuh index 5ac7136a26..7dfb264d34 100644 --- a/cpp/include/raft/matrix/threshold.cuh +++ b/cpp/include/raft/matrix/threshold.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ namespace raft::matrix { * @param[in] thres threshold to set values to zero */ template -void zero_small_values(const raft::handle_t& handle, +void zero_small_values(raft::device_resources const& handle, raft::device_matrix_view in, raft::device_matrix_view out, math_t thres = 1e-15) @@ -57,7 +57,7 @@ void zero_small_values(const raft::handle_t& handle, * @param thres: threshold */ template -void zero_small_values(const raft::handle_t& handle, +void zero_small_values(raft::device_resources const& handle, raft::device_matrix_view inout, math_t thres = 1e-15) { diff --git a/cpp/include/raft/matrix/triangular.cuh b/cpp/include/raft/matrix/triangular.cuh index 7820af8b16..3c60cc362f 100644 --- a/cpp/include/raft/matrix/triangular.cuh +++ b/cpp/include/raft/matrix/triangular.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ namespace raft::matrix { * @param[out] dst: output matrix with a size of kxk, k = min(n_rows, n_cols) */ template -void upper_triangular(const raft::handle_t& handle, +void upper_triangular(raft::device_resources const& handle, raft::device_matrix_view src, raft::device_matrix_view dst) { diff --git a/cpp/include/raft/neighbors/ball_cover.cuh b/cpp/include/raft/neighbors/ball_cover.cuh index 3818399e5f..619c57a35a 100644 --- a/cpp/include/raft/neighbors/ball_cover.cuh +++ b/cpp/include/raft/neighbors/ball_cover.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,12 @@ namespace raft::neighbors::ball_cover { * Usage example: * @code{.cpp} * - * #include + * #include * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * auto metric = raft::distance::DistanceType::L2Expanded; * BallCoverIndex index(handle, X, metric); @@ -60,7 +60,7 @@ namespace raft::neighbors::ball_cover { * @param[inout] index an empty (and not previous built) instance of BallCoverIndex */ template -void build_index(const raft::handle_t& handle, +void build_index(raft::device_resources const& handle, BallCoverIndex& index) { ASSERT(index.n <= 3, "only 2d and 3d vectors are supported in current implementation"); @@ -109,7 +109,7 @@ void build_index(const raft::handle_t& handle, * looking in the closest landmark. */ template -void all_knn_query(const raft::handle_t& handle, +void all_knn_query(raft::device_resources const& handle, BallCoverIndex& index, int_t k, idx_t* inds, @@ -163,12 +163,12 @@ void all_knn_query(const raft::handle_t& handle, * Usage example: * @code{.cpp} * - * #include + * #include * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * auto metric = raft::distance::DistanceType::L2Expanded; * @@ -202,7 +202,7 @@ void all_knn_query(const raft::handle_t& handle, * looking in the closest landmark. */ template -void all_knn_query(const raft::handle_t& handle, +void all_knn_query(raft::device_resources const& handle, BallCoverIndex& index, raft::device_matrix_view inds, raft::device_matrix_view dists, @@ -256,7 +256,7 @@ void all_knn_query(const raft::handle_t& handle, * @param[in] n_query_pts number of query points */ template -void knn_query(const raft::handle_t& handle, +void knn_query(raft::device_resources const& handle, const BallCoverIndex& index, int_t k, const value_t* query, @@ -311,12 +311,12 @@ void knn_query(const raft::handle_t& handle, * Usage example: * @code{.cpp} * - * #include + * #include * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * auto metric = raft::distance::DistanceType::L2Expanded; * @@ -352,7 +352,7 @@ void knn_query(const raft::handle_t& handle, * looking in the closest landmark. */ template -void knn_query(const raft::handle_t& handle, +void knn_query(raft::device_resources const& handle, const BallCoverIndex& index, raft::device_matrix_view query, raft::device_matrix_view inds, diff --git a/cpp/include/raft/neighbors/ball_cover_types.hpp b/cpp/include/raft/neighbors/ball_cover_types.hpp index 1c5babbc4e..8cab1469fc 100644 --- a/cpp/include/raft/neighbors/ball_cover_types.hpp +++ b/cpp/include/raft/neighbors/ball_cover_types.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -45,7 +45,7 @@ template class BallCoverIndex { public: - explicit BallCoverIndex(const raft::handle_t& handle_, + explicit BallCoverIndex(raft::device_resources const& handle_, const value_t* X_, value_int m_, value_int n_, @@ -71,7 +71,7 @@ class BallCoverIndex { { } - explicit BallCoverIndex(const raft::handle_t& handle_, + explicit BallCoverIndex(raft::device_resources const& handle_, raft::device_matrix_view X_, raft::distance::DistanceType metric_) : handle(handle_), @@ -139,7 +139,7 @@ class BallCoverIndex { // This should only be set by internal functions void set_index_trained() { index_trained = true; } - const raft::handle_t& handle; + raft::device_resources const& handle; value_int m; value_int n; diff --git a/cpp/include/raft/neighbors/brute_force.cuh b/cpp/include/raft/neighbors/brute_force.cuh index 8d94ffd9a7..ac9d14ce17 100644 --- a/cpp/include/raft/neighbors/brute_force.cuh +++ b/cpp/include/raft/neighbors/brute_force.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,11 +54,11 @@ namespace raft::neighbors::brute_force { * * Usage example: * @code{.cpp} - * #include + * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * compute multiple knn graphs and aggregate row-wise * (see detailed description above) @@ -79,7 +79,7 @@ namespace raft::neighbors::brute_force { */ template inline void knn_merge_parts( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view in_keys, raft::device_matrix_view in_values, raft::device_matrix_view out_keys, @@ -116,12 +116,12 @@ inline void knn_merge_parts( * * Usage example: * @code{.cpp} - * #include + * #include * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * int k = 10; * auto metric = raft::distance::DistanceType::L2SqrtExpanded; @@ -146,7 +146,7 @@ template -void knn(raft::handle_t const& handle, +void knn(raft::device_resources const& handle, std::vector> index, raft::device_matrix_view search, raft::device_matrix_view indices, @@ -207,12 +207,12 @@ void knn(raft::handle_t const& handle, * * Usage example: * @code{.cpp} - * #include + * #include * #include * #include * using namespace raft::neighbors; * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * auto metric = raft::distance::DistanceType::L2SqrtExpanded; * brute_force::fused_l2_knn(handle, index, search, indices, distances, metric); @@ -230,7 +230,7 @@ void knn(raft::handle_t const& handle, * @param[in] metric type of distance computation to perform (must be a variant of L2) */ template -void fused_l2_knn(const raft::handle_t& handle, +void fused_l2_knn(raft::device_resources const& handle, raft::device_matrix_view index, raft::device_matrix_view query, raft::device_matrix_view out_inds, diff --git a/cpp/include/raft/neighbors/detail/refine.cuh b/cpp/include/raft/neighbors/detail/refine.cuh index 86aef8fad8..b264643584 100644 --- a/cpp/include/raft/neighbors/detail/refine.cuh +++ b/cpp/include/raft/neighbors/detail/refine.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include #include @@ -72,7 +72,7 @@ void check_input(extents_t dataset, * See raft::neighbors::refine for docs. */ template -void refine_device(raft::handle_t const& handle, +void refine_device(raft::device_resources const& handle, raft::device_matrix_view dataset, raft::device_matrix_view queries, raft::device_matrix_view neighbor_candidates, diff --git a/cpp/include/raft/neighbors/epsilon_neighborhood.cuh b/cpp/include/raft/neighbors/epsilon_neighborhood.cuh index ee92222066..7db5ef6877 100644 --- a/cpp/include/raft/neighbors/epsilon_neighborhood.cuh +++ b/cpp/include/raft/neighbors/epsilon_neighborhood.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include namespace raft::neighbors::epsilon_neighborhood { @@ -72,10 +72,10 @@ void epsUnexpL2SqNeighborhood(bool* adj, * * @code{.cpp} * #include - * #include + * #include * #include * using namespace raft::neighbors; - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * auto adj = raft::make_device_matrix(handle, m * n); * auto vd = raft::make_device_vector(handle, m+1); @@ -97,7 +97,7 @@ void epsUnexpL2SqNeighborhood(bool* adj, * squared as we compute L2-squared distance in this method) */ template -void eps_neighbors_l2sq(const raft::handle_t& handle, +void eps_neighbors_l2sq(raft::device_resources const& handle, raft::device_matrix_view x, raft::device_matrix_view y, raft::device_matrix_view adj, diff --git a/cpp/include/raft/neighbors/ivf_flat.cuh b/cpp/include/raft/neighbors/ivf_flat.cuh index e05f63ef61..f18611b9f1 100644 --- a/cpp/include/raft/neighbors/ivf_flat.cuh +++ b/cpp/include/raft/neighbors/ivf_flat.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -61,9 +61,11 @@ namespace raft::neighbors::ivf_flat { * @return the constructed ivf-flat index */ template -auto build( - const handle_t& handle, const index_params& params, const T* dataset, IdxT n_rows, uint32_t dim) - -> index +auto build(raft::device_resources const& handle, + const index_params& params, + const T* dataset, + IdxT n_rows, + uint32_t dim) -> index { return raft::spatial::knn::ivf_flat::detail::build(handle, params, dataset, n_rows, dim); } @@ -106,7 +108,7 @@ auto build( * @return the constructed ivf-flat index */ template -auto build(const handle_t& handle, +auto build(raft::device_resources const& handle, raft::device_matrix_view dataset, const index_params& params) -> index { @@ -152,7 +154,7 @@ auto build(const handle_t& handle, * @return the constructed extended ivf-flat index */ template -auto extend(const handle_t& handle, +auto extend(raft::device_resources const& handle, const index& orig_index, const T* new_vectors, const IdxT* new_indices, @@ -201,7 +203,7 @@ auto extend(const handle_t& handle, * @return the constructed extended ivf-flat index */ template -auto extend(const handle_t& handle, +auto extend(raft::device_resources const& handle, const index& orig_index, raft::device_matrix_view new_vectors, std::optional> new_indices = std::nullopt) @@ -244,7 +246,7 @@ auto extend(const handle_t& handle, * @param[in] n_rows the number of samples */ template -void extend(const handle_t& handle, +void extend(raft::device_resources const& handle, index* index, const T* new_vectors, const IdxT* new_indices, @@ -286,7 +288,7 @@ void extend(const handle_t& handle, * here to imply a continuous range `[0...n_rows)`. */ template -void extend(const handle_t& handle, +void extend(raft::device_resources const& handle, index* index, raft::device_matrix_view new_vectors, std::optional> new_indices = std::nullopt) @@ -343,7 +345,7 @@ void extend(const handle_t& handle, * enough memory pool here to avoid memory allocations within search). */ template -void search(const handle_t& handle, +void search(raft::device_resources const& handle, const search_params& params, const index& index, const T* queries, @@ -398,7 +400,7 @@ void search(const handle_t& handle, * @param[in] k the number of neighbors to find for each query. */ template -void search(const handle_t& handle, +void search(raft::device_resources const& handle, const index& index, raft::device_matrix_view queries, raft::device_matrix_view neighbors, diff --git a/cpp/include/raft/neighbors/ivf_flat_types.hpp b/cpp/include/raft/neighbors/ivf_flat_types.hpp index fc5a8116ab..d234822a23 100644 --- a/cpp/include/raft/neighbors/ivf_flat_types.hpp +++ b/cpp/include/raft/neighbors/ivf_flat_types.hpp @@ -223,7 +223,7 @@ struct index : ann::index { ~index() = default; /** Construct an empty index. It needs to be trained and then populated. */ - index(const handle_t& handle, + index(raft::device_resources const& handle, raft::distance::DistanceType metric, uint32_t n_lists, bool adaptive_centers, @@ -243,7 +243,7 @@ struct index : ann::index { } /** Construct an empty index. It needs to be trained and then populated. */ - index(const handle_t& handle, const index_params& params, uint32_t dim) + index(raft::device_resources const& handle, const index_params& params, uint32_t dim) : index(handle, params.metric, params.n_lists, params.adaptive_centers, dim) { } @@ -252,7 +252,7 @@ struct index : ann::index { * Replace the content of the index with new uninitialized mdarrays to hold the indicated amount * of data. */ - void allocate(const handle_t& handle, IdxT index_size) + void allocate(raft::device_resources const& handle, IdxT index_size) { data_ = make_device_mdarray(handle, make_extents(index_size, dim())); indices_ = make_device_mdarray(handle, make_extents(index_size)); diff --git a/cpp/include/raft/neighbors/ivf_pq.cuh b/cpp/include/raft/neighbors/ivf_pq.cuh index 2296339a2a..287f0bc5f4 100644 --- a/cpp/include/raft/neighbors/ivf_pq.cuh +++ b/cpp/include/raft/neighbors/ivf_pq.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -65,9 +65,11 @@ namespace raft::neighbors::ivf_pq { * @return the constructed ivf-pq index */ template -inline auto build( - const handle_t& handle, const index_params& params, const T* dataset, IdxT n_rows, uint32_t dim) - -> index +inline auto build(raft::device_resources const& handle, + const index_params& params, + const T* dataset, + IdxT n_rows, + uint32_t dim) -> index { return raft::spatial::knn::ivf_pq::detail::build(handle, params, dataset, n_rows, dim); } @@ -105,7 +107,7 @@ inline auto build( * @return the constructed extended ivf-pq index */ template -inline auto extend(const handle_t& handle, +inline auto extend(raft::device_resources const& handle, const index& orig_index, const T* new_vectors, const IdxT* new_indices, @@ -130,7 +132,7 @@ inline auto extend(const handle_t& handle, * @param n_rows the number of samples */ template -inline void extend(const handle_t& handle, +inline void extend(raft::device_resources const& handle, index* index, const T* new_vectors, const IdxT* new_indices, @@ -182,7 +184,7 @@ inline void extend(const handle_t& handle, * memory pool here to avoid memory allocations within search). */ template -inline void search(const handle_t& handle, +inline void search(raft::device_resources const& handle, const search_params& params, const index& index, const T* queries, diff --git a/cpp/include/raft/neighbors/ivf_pq_types.hpp b/cpp/include/raft/neighbors/ivf_pq_types.hpp index 51364e1ee6..a6f71877f3 100644 --- a/cpp/include/raft/neighbors/ivf_pq_types.hpp +++ b/cpp/include/raft/neighbors/ivf_pq_types.hpp @@ -263,7 +263,7 @@ struct index : ann::index { ~index() = default; /** Construct an empty index. It needs to be trained and then populated. */ - index(const handle_t& handle, + index(raft::device_resources const& handle, raft::distance::DistanceType metric, codebook_gen codebook_kind, uint32_t n_lists, @@ -295,7 +295,7 @@ struct index : ann::index { } /** Construct an empty index. It needs to be trained and then populated. */ - index(const handle_t& handle, + index(raft::device_resources const& handle, const index_params& params, uint32_t dim, uint32_t n_nonempty_lists = 0) @@ -314,7 +314,7 @@ struct index : ann::index { * Replace the content of the index with new uninitialized mdarrays to hold the indicated amount * of data. */ - void allocate(const handle_t& handle, IdxT index_size) + void allocate(raft::device_resources const& handle, IdxT index_size) { try { pq_dataset_ = make_device_mdarray(handle, make_pq_dataset_extents(index_size)); diff --git a/cpp/include/raft/neighbors/refine.cuh b/cpp/include/raft/neighbors/refine.cuh index 6f373c0a2f..4243d7e723 100644 --- a/cpp/include/raft/neighbors/refine.cuh +++ b/cpp/include/raft/neighbors/refine.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ namespace raft::neighbors { * @param[in] metric distance metric to use. Euclidean (L2) is used by default */ template -void refine(raft::handle_t const& handle, +void refine(raft::device_resources const& handle, raft::device_matrix_view dataset, raft::device_matrix_view queries, raft::device_matrix_view neighbor_candidates, @@ -90,7 +90,7 @@ void refine(raft::handle_t const& handle, * @param[in] metric distance metric to use. Euclidean (L2) is used by default */ template -void refine(raft::handle_t const& handle, +void refine(raft::device_resources const& handle, raft::host_matrix_view dataset, raft::host_matrix_view queries, raft::host_matrix_view neighbor_candidates, diff --git a/cpp/include/raft/neighbors/specializations/ball_cover.cuh b/cpp/include/raft/neighbors/specializations/ball_cover.cuh index f20d1adc35..d44cb7064f 100644 --- a/cpp/include/raft/neighbors/specializations/ball_cover.cuh +++ b/cpp/include/raft/neighbors/specializations/ball_cover.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ extern template class BallCoverIndex; extern template class BallCoverIndex; extern template void build_index( - const raft::handle_t& handle, + raft::device_resources const& handle, BallCoverIndex& index); extern template void knn_query( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, std::uint32_t k, const float* query, @@ -41,7 +41,7 @@ extern template void knn_query( float weight); extern template void all_knn_query( - const raft::handle_t& handle, + raft::device_resources const& handle, BallCoverIndex& index, std::uint32_t k, std::int64_t* inds, diff --git a/cpp/include/raft/neighbors/specializations/detail/ball_cover_lowdim.hpp b/cpp/include/raft/neighbors/specializations/detail/ball_cover_lowdim.hpp index 31df566b3f..c558ab8b56 100644 --- a/cpp/include/raft/neighbors/specializations/detail/ball_cover_lowdim.hpp +++ b/cpp/include/raft/neighbors/specializations/detail/ball_cover_lowdim.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace knn { namespace detail { extern template void rbc_low_dim_pass_one( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, @@ -38,7 +38,7 @@ extern template void rbc_low_dim_pass_one std::uint32_t* dists_counter); extern template void rbc_low_dim_pass_two( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, @@ -52,7 +52,7 @@ extern template void rbc_low_dim_pass_two std::uint32_t* post_dists_counter); extern template void rbc_low_dim_pass_one( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, @@ -66,7 +66,7 @@ extern template void rbc_low_dim_pass_one std::uint32_t* dists_counter); extern template void rbc_low_dim_pass_two( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, diff --git a/cpp/include/raft/neighbors/specializations/detail/ivf_pq_search.cuh b/cpp/include/raft/neighbors/specializations/detail/ivf_pq_search.cuh index 768a8739c3..ca5e4ac761 100644 --- a/cpp/include/raft/neighbors/specializations/detail/ivf_pq_search.cuh +++ b/cpp/include/raft/neighbors/specializations/detail/ivf_pq_search.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,15 +50,15 @@ RAFT_INST_ALL_OUT_T(fp8u_t) #undef RAFT_INST_ALL_IDX_T #undef RAFT_INST_ALL_OUT_T -#define RAFT_INST(T, IdxT) \ - extern template void search(const handle_t&, \ - const search_params&, \ - const index&, \ - const T*, \ - uint32_t, \ - uint32_t, \ - IdxT*, \ - float*, \ +#define RAFT_INST(T, IdxT) \ + extern template void search(raft::device_resources const&, \ + const search_params&, \ + const index&, \ + const T*, \ + uint32_t, \ + uint32_t, \ + IdxT*, \ + float*, \ rmm::mr::device_memory_resource*); RAFT_INST(float, int64_t); diff --git a/cpp/include/raft/neighbors/specializations/knn.cuh b/cpp/include/raft/neighbors/specializations/knn.cuh index bbbbf67d71..b1cfa278d6 100644 --- a/cpp/include/raft/neighbors/specializations/knn.cuh +++ b/cpp/include/raft/neighbors/specializations/knn.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ namespace raft { namespace spatial { namespace knn { -extern template void brute_force_knn(raft::handle_t const& handle, +extern template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, int D, @@ -36,22 +36,23 @@ extern template void brute_force_knn(raft::handle_t const& han distance::DistanceType metric, float metric_arg); -extern template void brute_force_knn(raft::handle_t const& handle, - std::vector& input, - std::vector& sizes, - unsigned int D, - float* search_items, - unsigned int n, - long* res_I, - float* res_D, - unsigned int k, - bool rowMajorIndex, - bool rowMajorQuery, - std::vector* translations, - distance::DistanceType metric, - float metric_arg); +extern template void brute_force_knn( + raft::device_resources const& handle, + std::vector& input, + std::vector& sizes, + unsigned int D, + float* search_items, + unsigned int n, + long* res_I, + float* res_D, + unsigned int k, + bool rowMajorIndex, + bool rowMajorQuery, + std::vector* translations, + distance::DistanceType metric, + float metric_arg); -extern template void brute_force_knn(raft::handle_t const& handle, +extern template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, int D, @@ -67,7 +68,7 @@ extern template void brute_force_knn(raft::handle_t const& float metric_arg); extern template void brute_force_knn( - raft::handle_t const& handle, + raft::device_resources const& handle, std::vector& input, std::vector& sizes, unsigned int D, diff --git a/cpp/include/raft/random/detail/make_blobs.cuh b/cpp/include/raft/random/detail/make_blobs.cuh index fb4db5184e..b37dabb366 100644 --- a/cpp/include/raft/random/detail/make_blobs.cuh +++ b/cpp/include/raft/random/detail/make_blobs.cuh @@ -17,6 +17,7 @@ #pragma once #include "permute.cuh" +#include #include #include #include diff --git a/cpp/include/raft/random/detail/make_regression.cuh b/cpp/include/raft/random/detail/make_regression.cuh index 057196cd74..01d97d496d 100644 --- a/cpp/include/raft/random/detail/make_regression.cuh +++ b/cpp/include/raft/random/detail/make_regression.cuh @@ -22,7 +22,7 @@ #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ static __global__ void _singular_profile_kernel(DataT* out, IdxT n, DataT tail_s /* Internal auxiliary function to generate a low-rank matrix */ template -static void _make_low_rank_matrix(const raft::handle_t& handle, +static void _make_low_rank_matrix(raft::device_resources const& handle, DataT* out, IdxT n_rows, IdxT n_cols, @@ -143,7 +143,7 @@ static __global__ void _gather2d_kernel( } template -void make_regression_caller(const raft::handle_t& handle, +void make_regression_caller(raft::device_resources const& handle, DataT* out, DataT* values, IdxT n_rows, diff --git a/cpp/include/raft/random/detail/multi_variable_gaussian.cuh b/cpp/include/raft/random/detail/multi_variable_gaussian.cuh index 750ebf2ef1..8b77608e62 100644 --- a/cpp/include/raft/random/detail/multi_variable_gaussian.cuh +++ b/cpp/include/raft/random/detail/multi_variable_gaussian.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -139,13 +139,15 @@ class multi_variable_gaussian_impl { int *info, Lwork, info_h; syevjInfo_t syevj_params = NULL; curandGenerator_t gen; - const raft::handle_t& handle; + raft::device_resources const& handle; cusolverEigMode_t jobz = CUSOLVER_EIG_MODE_VECTOR; bool deinitilized = false; public: // functions multi_variable_gaussian_impl() = delete; - multi_variable_gaussian_impl(const raft::handle_t& handle, const int dim, Decomposer method) + multi_variable_gaussian_impl(raft::device_resources const& handle, + const int dim, + Decomposer method) : handle(handle), dim(dim), method(method) { auto cusolverHandle = handle.get_cusolver_dn_handle(); @@ -297,7 +299,7 @@ class multi_variable_gaussian_setup_token; template multi_variable_gaussian_setup_token build_multi_variable_gaussian_token_impl( - const raft::handle_t& handle, + raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, const int dim, const multi_variable_gaussian_decomposition_method method); @@ -313,7 +315,7 @@ template class multi_variable_gaussian_setup_token { template friend multi_variable_gaussian_setup_token build_multi_variable_gaussian_token_impl( - const raft::handle_t& handle, + raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, const int dim, const multi_variable_gaussian_decomposition_method method); @@ -340,7 +342,7 @@ class multi_variable_gaussian_setup_token { // Constructor, only for use by friend functions. // Hiding this will let us change the implementation in the future. - multi_variable_gaussian_setup_token(const raft::handle_t& handle, + multi_variable_gaussian_setup_token(raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, const int dim, const multi_variable_gaussian_decomposition_method method) @@ -397,7 +399,7 @@ class multi_variable_gaussian_setup_token { private: std::unique_ptr> impl_; - const raft::handle_t& handle_; + raft::device_resources const& handle_; rmm::mr::device_memory_resource& mem_resource_; int dim_ = 0; @@ -412,7 +414,7 @@ class multi_variable_gaussian_setup_token { template multi_variable_gaussian_setup_token build_multi_variable_gaussian_token_impl( - const raft::handle_t& handle, + raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, const int dim, const multi_variable_gaussian_decomposition_method method) @@ -432,7 +434,7 @@ void compute_multi_variable_gaussian_impl( template void compute_multi_variable_gaussian_impl( - const raft::handle_t& handle, + raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, std::optional> x, raft::device_matrix_view P, @@ -453,7 +455,7 @@ class multi_variable_gaussian : public detail::multi_variable_gaussian_impl { // using detail::multi_variable_gaussian_impl::Decomposer::qr; multi_variable_gaussian() = delete; - multi_variable_gaussian(const raft::handle_t& handle, + multi_variable_gaussian(raft::device_resources const& handle, const int dim, typename detail::multi_variable_gaussian_impl::Decomposer method) : detail::multi_variable_gaussian_impl{handle, dim, method} diff --git a/cpp/include/raft/random/detail/rmat_rectangular_generator.cuh b/cpp/include/raft/random/detail/rmat_rectangular_generator.cuh index 5ce7e909ee..b5e0610405 100644 --- a/cpp/include/raft/random/detail/rmat_rectangular_generator.cuh +++ b/cpp/include/raft/random/detail/rmat_rectangular_generator.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include "rmat_rectangular_generator_types.cuh" -#include +#include #include #include #include @@ -206,7 +206,7 @@ void rmat_rectangular_gen_caller(IdxT* out, * @param[in] c_scale 2^c_scale represents the number of destination nodes */ template -void rmat_rectangular_gen_impl(const raft::handle_t& handle, +void rmat_rectangular_gen_impl(raft::device_resources const& handle, raft::random::RngState& r, raft::device_vector_view theta, raft::random::detail::rmat_rectangular_gen_output output, @@ -259,7 +259,7 @@ void rmat_rectangular_gen_impl(const raft::handle_t& handle, * `theta` parameter. */ template -void rmat_rectangular_gen_impl(const raft::handle_t& handle, +void rmat_rectangular_gen_impl(raft::device_resources const& handle, raft::random::RngState& r, raft::random::detail::rmat_rectangular_gen_output output, ProbT a, diff --git a/cpp/include/raft/random/detail/rng_impl_deprecated.cuh b/cpp/include/raft/random/detail/rng_impl_deprecated.cuh index f9b55dd9d0..362c844fb3 100644 --- a/cpp/include/raft/random/detail/rng_impl_deprecated.cuh +++ b/cpp/include/raft/random/detail/rng_impl_deprecated.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include "rng_device.cuh" #include -#include +#include #include #include #include @@ -259,7 +259,7 @@ class RngImpl { template METHOD_DEPR(sampleWithoutReplacement) - void sampleWithoutReplacement(const raft::handle_t& handle, + void sampleWithoutReplacement(raft::device_resources const& handle, DataT* out, IdxT* outIdx, const DataT* in, diff --git a/cpp/include/raft/random/make_blobs.cuh b/cpp/include/raft/random/make_blobs.cuh index 4f6ddaa2b2..7aa0362f6d 100644 --- a/cpp/include/raft/random/make_blobs.cuh +++ b/cpp/include/raft/random/make_blobs.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ void make_blobs(DataT* out, */ template void make_blobs( - raft::handle_t const& handle, + raft::device_resources const& handle, raft::device_matrix_view out, raft::device_vector_view labels, IdxT n_clusters = 5, diff --git a/cpp/include/raft/random/make_regression.cuh b/cpp/include/raft/random/make_regression.cuh index e203de4ade..df7dea3156 100644 --- a/cpp/include/raft/random/make_regression.cuh +++ b/cpp/include/raft/random/make_regression.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ namespace raft::random { * @param[in] type Random generator type */ template -void make_regression(const raft::handle_t& handle, +void make_regression(raft::device_resources const& handle, DataT* out, DataT* values, IdxT n_rows, @@ -138,7 +138,7 @@ void make_regression(const raft::handle_t& handle, * @param[in] type Random generator type */ template -void make_regression(const raft::handle_t& handle, +void make_regression(raft::device_resources const& handle, raft::device_matrix_view out, raft::device_matrix_view values, IdxT n_informative, diff --git a/cpp/include/raft/random/multi_variable_gaussian.cuh b/cpp/include/raft/random/multi_variable_gaussian.cuh index 37ea58c0fb..91a7695f2c 100644 --- a/cpp/include/raft/random/multi_variable_gaussian.cuh +++ b/cpp/include/raft/random/multi_variable_gaussian.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace raft::random { */ template -void multi_variable_gaussian(const raft::handle_t& handle, +void multi_variable_gaussian(raft::device_resources const& handle, rmm::mr::device_memory_resource& mem_resource, std::optional> x, raft::device_matrix_view P, @@ -41,7 +41,7 @@ void multi_variable_gaussian(const raft::handle_t& handle, } template -void multi_variable_gaussian(const raft::handle_t& handle, +void multi_variable_gaussian(raft::device_resources const& handle, std::optional> x, raft::device_matrix_view P, raft::device_matrix_view X, diff --git a/cpp/include/raft/random/permute.cuh b/cpp/include/raft/random/permute.cuh index b532cb584d..f84b603549 100644 --- a/cpp/include/raft/random/permute.cuh +++ b/cpp/include/raft/random/permute.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include #include -#include +#include #include namespace raft::random { @@ -95,7 +95,7 @@ using perms_out_view_t = typename perms_out_view -void permute(const raft::handle_t& handle, +void permute(raft::device_resources const& handle, raft::device_matrix_view in, std::optional> permsOut, std::optional> out) @@ -142,7 +142,7 @@ template -void permute(const raft::handle_t& handle, +void permute(raft::device_resources const& handle, raft::device_matrix_view in, PermsOutType&& permsOut, OutType&& out) diff --git a/cpp/include/raft/random/rmat_rectangular_generator.cuh b/cpp/include/raft/random/rmat_rectangular_generator.cuh index cd9acda999..d578794d31 100644 --- a/cpp/include/raft/random/rmat_rectangular_generator.cuh +++ b/cpp/include/raft/random/rmat_rectangular_generator.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ namespace raft::random { */ template void rmat_rectangular_gen( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::random::RngState& r, raft::device_vector_view theta, raft::device_mdspan, raft::row_major> out, @@ -102,7 +102,7 @@ void rmat_rectangular_gen( * @pre `out_src.extent(0) == out_dst.extent(0)` is `true` */ template -void rmat_rectangular_gen(const raft::handle_t& handle, +void rmat_rectangular_gen(raft::device_resources const& handle, raft::random::RngState& r, raft::device_vector_view theta, raft::device_vector_view out_src, @@ -125,7 +125,7 @@ void rmat_rectangular_gen(const raft::handle_t& handle, */ template void rmat_rectangular_gen( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::random::RngState& r, raft::device_vector_view theta, raft::device_mdspan, raft::row_major> out, @@ -152,7 +152,7 @@ void rmat_rectangular_gen( */ template void rmat_rectangular_gen( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::random::RngState& r, raft::device_mdspan, raft::row_major> out, raft::device_vector_view out_src, @@ -179,7 +179,7 @@ void rmat_rectangular_gen( * @pre `out_src.extent(0) == out_dst.extent(0)` is `true` */ template -void rmat_rectangular_gen(const raft::handle_t& handle, +void rmat_rectangular_gen(raft::device_resources const& handle, raft::random::RngState& r, raft::device_vector_view out_src, raft::device_vector_view out_dst, @@ -204,7 +204,7 @@ void rmat_rectangular_gen(const raft::handle_t& handle, */ template void rmat_rectangular_gen( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::random::RngState& r, raft::device_mdspan, raft::row_major> out, ProbT a, diff --git a/cpp/include/raft/random/rng.cuh b/cpp/include/raft/random/rng.cuh index 9469c393f1..d03975d0db 100644 --- a/cpp/include/raft/random/rng.cuh +++ b/cpp/include/raft/random/rng.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ namespace raft::random { * @param[in] end end of the range */ template -void uniform(const raft::handle_t& handle, +void uniform(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType start, @@ -63,7 +63,7 @@ void uniform(const raft::handle_t& handle, * @param[in] end end of the range */ template -void uniform(const raft::handle_t& handle, +void uniform(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -86,7 +86,7 @@ void uniform(const raft::handle_t& handle, * @param[in] end end of the range */ template -void uniformInt(const raft::handle_t& handle, +void uniformInt(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType start, @@ -114,7 +114,7 @@ void uniformInt(const raft::handle_t& handle, * @param[in] end end of the range */ template -void uniformInt(const raft::handle_t& handle, +void uniformInt(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -138,7 +138,7 @@ void uniformInt(const raft::handle_t& handle, * @param[in] sigma std-dev of the distribution */ template -void normal(const raft::handle_t& handle, +void normal(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -160,7 +160,7 @@ void normal(const raft::handle_t& handle, * @param[in] sigma std-dev of the distribution */ template -void normal(const raft::handle_t& handle, +void normal(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -183,7 +183,7 @@ void normal(const raft::handle_t& handle, * @param[in] sigma standard deviation of the distribution */ template -void normalInt(const raft::handle_t& handle, +void normalInt(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -212,7 +212,7 @@ void normalInt(const raft::handle_t& handle, * @param[in] sigma std-dev of the distribution */ template -void normalInt(const raft::handle_t& handle, +void normalInt(raft::device_resources const& handle, RngState& rng_state, IntType* ptr, LenType len, @@ -244,7 +244,7 @@ void normalInt(const raft::handle_t& handle, */ template void normalTable( - const raft::handle_t& handle, + raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view mu_vec, std::variant, OutputValueType> sigma, @@ -307,7 +307,7 @@ void normalTable( * @param[in] sigma scalar sigma to be used if 'sigma_vec' is nullptr */ template -void normalTable(const raft::handle_t& handle, +void normalTable(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType n_rows, @@ -332,7 +332,7 @@ void normalTable(const raft::handle_t& handle, * @param[out] out the output vector */ template -void fill(const raft::handle_t& handle, +void fill(raft::device_resources const& handle, RngState& rng_state, OutputValueType val, raft::device_vector_view out) @@ -352,7 +352,8 @@ void fill(const raft::handle_t& handle, * @param[in] val value to be filled */ template -void fill(const raft::handle_t& handle, RngState& rng_state, OutType* ptr, LenType len, OutType val) +void fill( + raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, OutType val) { detail::fill(rng_state, ptr, len, val, handle.get_stream()); } @@ -371,7 +372,7 @@ void fill(const raft::handle_t& handle, RngState& rng_state, OutType* ptr, LenTy * @param[in] prob coin-toss probability for heads */ template -void bernoulli(const raft::handle_t& handle, +void bernoulli(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, Type prob) @@ -394,7 +395,7 @@ void bernoulli(const raft::handle_t& handle, */ template void bernoulli( - const raft::handle_t& handle, RngState& rng_state, OutType* ptr, LenType len, Type prob) + raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, Type prob) { detail::bernoulli(rng_state, ptr, len, prob, handle.get_stream()); } @@ -412,7 +413,7 @@ void bernoulli( * @param[in] scale scaling factor */ template -void scaled_bernoulli(const raft::handle_t& handle, +void scaled_bernoulli(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType prob, @@ -435,7 +436,7 @@ void scaled_bernoulli(const raft::handle_t& handle, * @param[in] scale scaling factor */ template -void scaled_bernoulli(const raft::handle_t& handle, +void scaled_bernoulli(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -459,7 +460,7 @@ void scaled_bernoulli(const raft::handle_t& handle, * @note https://en.wikipedia.org/wiki/Gumbel_distribution */ template -void gumbel(const raft::handle_t& handle, +void gumbel(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -482,7 +483,7 @@ void gumbel(const raft::handle_t& handle, * @note https://en.wikipedia.org/wiki/Gumbel_distribution */ template -void gumbel(const raft::handle_t& handle, +void gumbel(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -505,7 +506,7 @@ void gumbel(const raft::handle_t& handle, * @param[in] sigma standard deviation of the distribution */ template -void lognormal(const raft::handle_t& handle, +void lognormal(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -527,7 +528,7 @@ void lognormal(const raft::handle_t& handle, * @param[in] sigma standard deviation of the distribution */ template -void lognormal(const raft::handle_t& handle, +void lognormal(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -550,7 +551,7 @@ void lognormal(const raft::handle_t& handle, * @param[in] scale scale value */ template -void logistic(const raft::handle_t& handle, +void logistic(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -572,7 +573,7 @@ void logistic(const raft::handle_t& handle, * @param[in] scale scale value */ template -void logistic(const raft::handle_t& handle, +void logistic(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -594,7 +595,7 @@ void logistic(const raft::handle_t& handle, * @param[in] lambda the exponential distribution's lambda parameter */ template -void exponential(const raft::handle_t& handle, +void exponential(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType lambda) @@ -614,8 +615,11 @@ void exponential(const raft::handle_t& handle, * @param[in] lambda the exponential distribution's lambda parameter */ template -void exponential( - const raft::handle_t& handle, RngState& rng_state, OutType* ptr, LenType len, OutType lambda) +void exponential(raft::device_resources const& handle, + RngState& rng_state, + OutType* ptr, + LenType len, + OutType lambda) { detail::exponential(rng_state, ptr, len, lambda, handle.get_stream()); } @@ -632,7 +636,7 @@ void exponential( * @param[in] sigma the distribution's sigma parameter */ template -void rayleigh(const raft::handle_t& handle, +void rayleigh(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType sigma) @@ -652,8 +656,11 @@ void rayleigh(const raft::handle_t& handle, * @param[in] sigma the distribution's sigma parameter */ template -void rayleigh( - const raft::handle_t& handle, RngState& rng_state, OutType* ptr, LenType len, OutType sigma) +void rayleigh(raft::device_resources const& handle, + RngState& rng_state, + OutType* ptr, + LenType len, + OutType sigma) { detail::rayleigh(rng_state, ptr, len, sigma, handle.get_stream()); } @@ -671,7 +678,7 @@ void rayleigh( * @param[in] scale the scale */ template -void laplace(const raft::handle_t& handle, +void laplace(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, OutputValueType mu, @@ -693,7 +700,7 @@ void laplace(const raft::handle_t& handle, * @param[in] scale the scale */ template -void laplace(const raft::handle_t& handle, +void laplace(raft::device_resources const& handle, RngState& rng_state, OutType* ptr, LenType len, @@ -709,10 +716,10 @@ void laplace(const raft::handle_t& handle, * Usage example: * @code{.cpp} * #include - * #include + * #include * #include * - * raft::handle_t handle; + * raft::raft::device_resources handle; * ... * raft::random::RngState rng(seed); * auto indices = raft::make_device_vector(handle, n_samples); @@ -730,7 +737,7 @@ void laplace(const raft::handle_t& handle, */ template std::enable_if_t> discrete( - const raft::handle_t& handle, + raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view out, raft::device_vector_view weights) @@ -763,7 +770,7 @@ std::enable_if_t> discrete( * @param[in] len input array length */ template -void sampleWithoutReplacement(const raft::handle_t& handle, +void sampleWithoutReplacement(raft::device_resources const& handle, RngState& rng_state, DataT* out, IdxT* outIdx, @@ -1099,7 +1106,7 @@ class DEPR Rng : public detail::RngImpl { * @param stream cuda stream */ template - void sampleWithoutReplacement(const raft::handle_t& handle, + void sampleWithoutReplacement(raft::device_resources const& handle, DataT* out, IdxT* outIdx, const DataT* in, diff --git a/cpp/include/raft/random/sample_without_replacement.cuh b/cpp/include/raft/random/sample_without_replacement.cuh index e4428c28d6..8998db98ae 100644 --- a/cpp/include/raft/random/sample_without_replacement.cuh +++ b/cpp/include/raft/random/sample_without_replacement.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -94,7 +94,7 @@ using weight_t = typename weight_alias::type; * equals the number of inputs `in.extent(0)`. */ template -void sample_without_replacement(const raft::handle_t& handle, +void sample_without_replacement(raft::device_resources const& handle, RngState& rng_state, raft::device_vector_view in, WeightsVectorType&& weights_opt, diff --git a/cpp/include/raft/solver/detail/lap_functions.cuh b/cpp/include/raft/solver/detail/lap_functions.cuh index cbfe12fd23..440e6901c6 100644 --- a/cpp/include/raft/solver/detail/lap_functions.cuh +++ b/cpp/include/raft/solver/detail/lap_functions.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * Copyright 2020 KETAN DATE & RAKESH NAGI * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ #include -#include +#include #include #include #include @@ -98,7 +98,7 @@ inline void calculateRectangularDims( } template -inline void initialReduction(raft::handle_t const& handle, +inline void initialReduction(raft::device_resources const& handle, weight_t const* d_costs, Vertices& d_vertices_dev, int SP, @@ -125,7 +125,7 @@ inline void initialReduction(raft::handle_t const& handle, } template -inline void computeInitialAssignments(raft::handle_t const& handle, +inline void computeInitialAssignments(raft::device_resources const& handle, weight_t const* d_costs, Vertices& d_vertices, int SP, @@ -164,7 +164,7 @@ inline void computeInitialAssignments(raft::handle_t const& handle, // Function for finding row cover on individual devices. template -inline int computeRowCovers(raft::handle_t const& handle, +inline int computeRowCovers(raft::device_resources const& handle, Vertices& d_vertices, VertexData& d_row_data, VertexData& d_col_data, @@ -198,7 +198,7 @@ inline int computeRowCovers(raft::handle_t const& handle, // Function for covering the zeros in uncovered rows and expanding the frontier. template -inline void coverZeroAndExpand(raft::handle_t const& handle, +inline void coverZeroAndExpand(raft::device_resources const& handle, weight_t const* d_costs_dev, vertex_t const* d_rows_csr_neighbors, vertex_t const* d_rows_csr_ptrs, @@ -230,7 +230,7 @@ inline void coverZeroAndExpand(raft::handle_t const& handle, } template -inline vertex_t zeroCoverIteration(raft::handle_t const& handle, +inline vertex_t zeroCoverIteration(raft::device_resources const& handle, weight_t const* d_costs_dev, Vertices& d_vertices_dev, VertexData& d_row_data_dev, @@ -310,7 +310,7 @@ inline vertex_t zeroCoverIteration(raft::handle_t const& handle, // Function for executing recursive zero cover. Returns the next step (Step 4 or Step 5) depending // on the presence of uncovered zeros. template -inline void executeZeroCover(raft::handle_t const& handle, +inline void executeZeroCover(raft::device_resources const& handle, weight_t const* d_costs_dev, Vertices& d_vertices_dev, VertexData& d_row_data_dev, @@ -329,7 +329,7 @@ inline void executeZeroCover(raft::handle_t const& handle, // Function for executing reverse pass of the maximum matching. template -inline void reversePass(raft::handle_t const& handle, +inline void reversePass(raft::device_resources const& handle, VertexData& d_row_data_dev, VertexData& d_col_data_dev, int SP, @@ -385,7 +385,7 @@ inline void reversePass(raft::handle_t const& handle, // Function for executing augmentation pass of the maximum matching. template -inline void augmentationPass(raft::handle_t const& handle, +inline void augmentationPass(raft::device_resources const& handle, Vertices& d_vertices_dev, VertexData& d_row_data_dev, VertexData& d_col_data_dev, @@ -448,7 +448,7 @@ inline void augmentationPass(raft::handle_t const& handle, } template -inline void dualUpdate(raft::handle_t const& handle, +inline void dualUpdate(raft::device_resources const& handle, Vertices& d_vertices_dev, VertexData& d_row_data_dev, VertexData& d_col_data_dev, @@ -493,7 +493,7 @@ inline void dualUpdate(raft::handle_t const& handle, // Function for calculating optimal objective function value using dual variables. template -inline void calcObjValDual(raft::handle_t const& handle, +inline void calcObjValDual(raft::device_resources const& handle, weight_t* d_obj_val, Vertices& d_vertices_dev, int SP, @@ -513,7 +513,7 @@ inline void calcObjValDual(raft::handle_t const& handle, // Function for calculating optimal objective function value using dual variables. template -inline void calcObjValPrimal(raft::handle_t const& handle, +inline void calcObjValPrimal(raft::device_resources const& handle, weight_t* d_obj_val, weight_t const* d_costs, vertex_t const* d_row_assignments, diff --git a/cpp/include/raft/solver/detail/lap_kernels.cuh b/cpp/include/raft/solver/detail/lap_kernels.cuh index d66a9d72d5..69930a1460 100644 --- a/cpp/include/raft/solver/detail/lap_kernels.cuh +++ b/cpp/include/raft/solver/detail/lap_kernels.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * Copyright 2020 KETAN DATE & RAKESH NAGI * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ #include "../linear_assignment_types.hpp" -#include +#include #include #include diff --git a/cpp/include/raft/solver/linear_assignment.cuh b/cpp/include/raft/solver/linear_assignment.cuh index 3e17b557f2..7904c04ede 100644 --- a/cpp/include/raft/solver/linear_assignment.cuh +++ b/cpp/include/raft/solver/linear_assignment.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * Copyright 2020 KETAN DATE & RAKESH NAGI * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +28,7 @@ #pragma once -#include +#include #include #include @@ -61,7 +61,7 @@ class LinearAssignmentProblem { Vertices d_vertices_dev; VertexData d_row_data_dev, d_col_data_dev; - raft::handle_t const& handle_; + raft::device_resources const& handle_; rmm::device_uvector row_covers_v; rmm::device_uvector col_covers_v; rmm::device_uvector row_duals_v; @@ -84,7 +84,7 @@ class LinearAssignmentProblem { * @param batchsize * @param epsilon */ - LinearAssignmentProblem(raft::handle_t const& handle, + LinearAssignmentProblem(raft::device_resources const& handle, vertex_t size, vertex_t batchsize, weight_t epsilon) diff --git a/cpp/include/raft/sparse/convert/csr.cuh b/cpp/include/raft/sparse/convert/csr.cuh index abdacdc426..09f4135a51 100644 --- a/cpp/include/raft/sparse/convert/csr.cuh +++ b/cpp/include/raft/sparse/convert/csr.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ namespace sparse { namespace convert { template -void coo_to_csr(const raft::handle_t& handle, +void coo_to_csr(raft::device_resources const& handle, const int* srcRows, const int* srcCols, const value_t* srcVals, @@ -90,7 +90,7 @@ void sorted_coo_to_csr(COO* coo, int* row_ind, cudaStream_t stream) * number of non-zeros in adj. */ template -void adj_to_csr(const raft::handle_t& handle, +void adj_to_csr(raft::device_resources const& handle, const bool* adj, // Row-major adjacency matrix const index_t* row_ind, // Precomputed row indices index_t num_rows, // # rows of adj diff --git a/cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh b/cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh index 4549fbe343..87c534d7b8 100644 --- a/cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh +++ b/cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include @@ -129,7 +129,7 @@ __global__ void __launch_bounds__(adj_to_csr_tpb) * number of non-zeros in adj. */ template -void adj_to_csr(const raft::handle_t& handle, +void adj_to_csr(raft::device_resources const& handle, const bool* adj, // row-major adjacency matrix const index_t* row_ind, // precomputed row indices index_t num_rows, // # rows of adj diff --git a/cpp/include/raft/sparse/convert/detail/csr.cuh b/cpp/include/raft/sparse/convert/detail/csr.cuh index acb77de358..3f155854c0 100644 --- a/cpp/include/raft/sparse/convert/detail/csr.cuh +++ b/cpp/include/raft/sparse/convert/detail/csr.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ namespace convert { namespace detail { template -void coo_to_csr(const raft::handle_t& handle, +void coo_to_csr(raft::device_resources const& handle, const int* srcRows, const int* srcCols, const value_t* srcVals, diff --git a/cpp/include/raft/sparse/detail/cusparse_wrappers.h b/cpp/include/raft/sparse/detail/cusparse_wrappers.h index 3bb2db7902..6ae6874466 100644 --- a/cpp/include/raft/sparse/detail/cusparse_wrappers.h +++ b/cpp/include/raft/sparse/detail/cusparse_wrappers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -779,7 +779,7 @@ cusparseStatus_t cusparsegemmi( // NOLINT auto return_value = cusparsespmm(handle, opB, opA, alpha, matB, matA, beta, matC, alg, ext_buf, stream); - raft::handle_t rhandle; + raft::device_resources rhandle; raft::linalg::transpose(rhandle, CT.data(), C, n, m, stream); // destroy matrix/vector descriptors CUSPARSE_CHECK(cusparseDestroyDnMat(matA)); diff --git a/cpp/include/raft/sparse/distance/common.h b/cpp/include/raft/sparse/distance/common.h index a69352d74b..1e5aeb5210 100644 --- a/cpp/include/raft/sparse/distance/common.h +++ b/cpp/include/raft/sparse/distance/common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace raft { namespace sparse { @@ -24,7 +24,7 @@ namespace distance { template struct distances_config_t { - distances_config_t(const raft::handle_t& handle_) : handle(handle_) {} + distances_config_t(raft::device_resources const& handle_) : handle(handle_) {} // left side value_idx a_nrows; @@ -42,7 +42,7 @@ struct distances_config_t { value_idx* b_indices; value_t* b_data; - const raft::handle_t& handle; + raft::device_resources const& handle; }; template diff --git a/cpp/include/raft/sparse/linalg/detail/spectral.cuh b/cpp/include/raft/sparse/linalg/detail/spectral.cuh index cdc0e62130..3be33820cc 100644 --- a/cpp/include/raft/sparse/linalg/detail/spectral.cuh +++ b/cpp/include/raft/sparse/linalg/detail/spectral.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ namespace spectral { namespace detail { template -void fit_embedding(const raft::handle_t& handle, +void fit_embedding(raft::device_resources const& handle, int* rows, int* cols, T* vals, @@ -88,7 +88,7 @@ void fit_embedding(const raft::handle_t& handle, using size_type_t = index_type; using value_type_t = value_type; - std::pair solve(handle_t const& handle, + std::pair solve(raft::device_resources const& handle, size_type_t n_obs_vecs, size_type_t dim, value_type_t const* __restrict__ obs, diff --git a/cpp/include/raft/sparse/linalg/detail/symmetrize.cuh b/cpp/include/raft/sparse/linalg/detail/symmetrize.cuh index 358e7d6d29..4ecd447cc4 100644 --- a/cpp/include/raft/sparse/linalg/detail/symmetrize.cuh +++ b/cpp/include/raft/sparse/linalg/detail/symmetrize.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -325,7 +325,7 @@ void from_knn_symmetrize_matrix(const value_idx* __restrict__ knn_indices, * Symmetrizes a COO matrix */ template -void symmetrize(const raft::handle_t& handle, +void symmetrize(raft::device_resources const& handle, const value_idx* rows, const value_idx* cols, const value_t* vals, diff --git a/cpp/include/raft/sparse/linalg/spectral.cuh b/cpp/include/raft/sparse/linalg/spectral.cuh index 0a97619e87..35d85e893f 100644 --- a/cpp/include/raft/sparse/linalg/spectral.cuh +++ b/cpp/include/raft/sparse/linalg/spectral.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #ifndef __SPARSE_SPECTRAL_H #define __SPARSE_SPECTRAL_H -#include +#include #include namespace raft { @@ -24,7 +24,7 @@ namespace sparse { namespace spectral { template -void fit_embedding(const raft::handle_t& handle, +void fit_embedding(raft::device_resources const& handle, int* rows, int* cols, T* vals, diff --git a/cpp/include/raft/sparse/linalg/symmetrize.cuh b/cpp/include/raft/sparse/linalg/symmetrize.cuh index a01145376a..f34ba4dbd0 100644 --- a/cpp/include/raft/sparse/linalg/symmetrize.cuh +++ b/cpp/include/raft/sparse/linalg/symmetrize.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -149,7 +149,7 @@ void from_knn_symmetrize_matrix(const value_idx* __restrict__ knn_indices, * Symmetrizes a COO matrix */ template -void symmetrize(const raft::handle_t& handle, +void symmetrize(raft::device_resources const& handle, const value_idx* rows, const value_idx* cols, const value_t* vals, diff --git a/cpp/include/raft/sparse/linalg/transpose.cuh b/cpp/include/raft/sparse/linalg/transpose.cuh index ae527fe34c..dd5a56bed1 100644 --- a/cpp/include/raft/sparse/linalg/transpose.cuh +++ b/cpp/include/raft/sparse/linalg/transpose.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include #include namespace raft { @@ -40,7 +40,7 @@ namespace linalg { * @param[in] stream : Cuda stream for ordering events */ template -void csr_transpose(const raft::handle_t& handle, +void csr_transpose(raft::device_resources const& handle, const value_idx* csr_indptr, const value_idx* csr_indices, const value_t* csr_data, diff --git a/cpp/include/raft/sparse/neighbors/brute_force.cuh b/cpp/include/raft/sparse/neighbors/brute_force.cuh index 9639ddc24c..515213d250 100644 --- a/cpp/include/raft/sparse/neighbors/brute_force.cuh +++ b/cpp/include/raft/sparse/neighbors/brute_force.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include @@ -61,7 +61,7 @@ void knn(const value_idx* idxIndptr, value_idx* output_indices, value_t* output_dists, int k, - const raft::handle_t& handle, + raft::device_resources const& handle, size_t batch_size_index = 2 << 14, // approx 1M size_t batch_size_query = 2 << 14, raft::distance::DistanceType metric = raft::distance::DistanceType::L2Expanded, diff --git a/cpp/include/raft/sparse/neighbors/connect_components.cuh b/cpp/include/raft/sparse/neighbors/connect_components.cuh index e468643518..90343c1215 100644 --- a/cpp/include/raft/sparse/neighbors/connect_components.cuh +++ b/cpp/include/raft/sparse/neighbors/connect_components.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include #include @@ -64,7 +64,7 @@ value_idx get_n_components(value_idx* colors, size_t n_rows, cudaStream_t stream */ template void connect_components( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::sparse::COO& out, const value_t* X, const value_idx* orig_colors, diff --git a/cpp/include/raft/sparse/neighbors/detail/connect_components.cuh b/cpp/include/raft/sparse/neighbors/detail/connect_components.cuh index 38ba1137ac..583ff4dfdc 100644 --- a/cpp/include/raft/sparse/neighbors/detail/connect_components.cuh +++ b/cpp/include/raft/sparse/neighbors/detail/connect_components.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -320,7 +320,7 @@ void min_components_by_color(raft::sparse::COO& coo, */ template void connect_components( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::sparse::COO& out, const value_t* X, const value_idx* orig_colors, diff --git a/cpp/include/raft/sparse/neighbors/detail/knn.cuh b/cpp/include/raft/sparse/neighbors/detail/knn.cuh index 38e67036fe..7bedec9830 100644 --- a/cpp/include/raft/sparse/neighbors/detail/knn.cuh +++ b/cpp/include/raft/sparse/neighbors/detail/knn.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ class sparse_knn_t { value_idx* output_indices_, value_t* output_dists_, int k_, - const raft::handle_t& handle_, + raft::device_resources const& handle_, size_t batch_size_index_ = 2 << 14, // approx 1M size_t batch_size_query_ = 2 << 14, raft::distance::DistanceType metric_ = raft::distance::DistanceType::L2Expanded, @@ -422,7 +422,7 @@ class sparse_knn_t { int n_idx_rows, n_idx_cols, n_query_rows, n_query_cols, k; - const raft::handle_t& handle; + raft::device_resources const& handle; }; }; // namespace raft::sparse::neighbors::detail \ No newline at end of file diff --git a/cpp/include/raft/sparse/neighbors/detail/knn_graph.cuh b/cpp/include/raft/sparse/neighbors/detail/knn_graph.cuh index ffd742f080..d53f2f8df3 100644 --- a/cpp/include/raft/sparse/neighbors/detail/knn_graph.cuh +++ b/cpp/include/raft/sparse/neighbors/detail/knn_graph.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,7 @@ void conv_indices(in_t* inds, out_t* out, size_t size, cudaStream_t stream) * @param c */ template -void knn_graph(const handle_t& handle, +void knn_graph(raft::device_resources const& handle, const value_t* X, size_t m, size_t n, diff --git a/cpp/include/raft/sparse/neighbors/knn.cuh b/cpp/include/raft/sparse/neighbors/knn.cuh index 14404adcb4..d5714fbbd1 100644 --- a/cpp/include/raft/sparse/neighbors/knn.cuh +++ b/cpp/include/raft/sparse/neighbors/knn.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ void brute_force_knn(const value_idx* idxIndptr, value_idx* output_indices, value_t* output_dists, int k, - const raft::handle_t& handle, + raft::device_resources const& handle, size_t batch_size_index = 2 << 14, // approx 1M size_t batch_size_query = 2 << 14, raft::distance::DistanceType metric = raft::distance::DistanceType::L2Expanded, diff --git a/cpp/include/raft/sparse/neighbors/knn_graph.cuh b/cpp/include/raft/sparse/neighbors/knn_graph.cuh index 582df703db..dab4b53482 100644 --- a/cpp/include/raft/sparse/neighbors/knn_graph.cuh +++ b/cpp/include/raft/sparse/neighbors/knn_graph.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ namespace raft::sparse::neighbors { * @param c */ template -void knn_graph(const handle_t& handle, +void knn_graph(raft::device_resources const& handle, const value_t* X, std::size_t m, std::size_t n, diff --git a/cpp/include/raft/sparse/op/detail/reduce.cuh b/cpp/include/raft/sparse/op/detail/reduce.cuh index 2b2566f107..8cdfa49c45 100644 --- a/cpp/include/raft/sparse/op/detail/reduce.cuh +++ b/cpp/include/raft/sparse/op/detail/reduce.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,7 @@ void compute_duplicates_mask( * @param[in] stream cuda ops will be ordered wrt this stream */ template -void max_duplicates(const raft::handle_t& handle, +void max_duplicates(raft::device_resources const& handle, raft::sparse::COO& out, const value_idx* rows, const value_idx* cols, diff --git a/cpp/include/raft/sparse/op/filter.cuh b/cpp/include/raft/sparse/op/filter.cuh index 488d926fe9..7418b26ec8 100644 --- a/cpp/include/raft/sparse/op/filter.cuh +++ b/cpp/include/raft/sparse/op/filter.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include diff --git a/cpp/include/raft/sparse/op/reduce.cuh b/cpp/include/raft/sparse/op/reduce.cuh index 80b479f98d..5223100b2a 100644 --- a/cpp/include/raft/sparse/op/reduce.cuh +++ b/cpp/include/raft/sparse/op/reduce.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include @@ -69,7 +69,7 @@ void compute_duplicates_mask( * @param[in] n number of columns in COO input matrix */ template -void max_duplicates(const raft::handle_t& handle, +void max_duplicates(raft::device_resources const& handle, raft::sparse::COO& out, const value_idx* rows, const value_idx* cols, diff --git a/cpp/include/raft/sparse/op/row_op.cuh b/cpp/include/raft/sparse/op/row_op.cuh index d73d05785d..17e3659355 100644 --- a/cpp/include/raft/sparse/op/row_op.cuh +++ b/cpp/include/raft/sparse/op/row_op.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #define __SPARSE_ROW_OP_H #pragma once -#include +#include #include namespace raft { diff --git a/cpp/include/raft/sparse/op/slice.cuh b/cpp/include/raft/sparse/op/slice.cuh index 30f7a97ffc..22d3f0168d 100644 --- a/cpp/include/raft/sparse/op/slice.cuh +++ b/cpp/include/raft/sparse/op/slice.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include namespace raft { diff --git a/cpp/include/raft/sparse/op/sort.cuh b/cpp/include/raft/sparse/op/sort.cuh index ddb4b2830c..e4e69a93c7 100644 --- a/cpp/include/raft/sparse/op/sort.cuh +++ b/cpp/include/raft/sparse/op/sort.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #pragma once -#include +#include #include namespace raft { diff --git a/cpp/include/raft/sparse/solver/detail/lanczos.cuh b/cpp/include/raft/sparse/solver/detail/lanczos.cuh index 49f4e01362..63bc98b404 100644 --- a/cpp/include/raft/sparse/solver/detail/lanczos.cuh +++ b/cpp/include/raft/sparse/solver/detail/lanczos.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -80,7 +80,7 @@ inline curandStatus_t curandGenerateNormalX( * @return Zero if successful. Otherwise non-zero. */ template -int performLanczosIteration(handle_t const& handle, +int performLanczosIteration(raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t* iter, index_type_t maxIter, @@ -541,7 +541,7 @@ static int francisQRIteration(index_type_t n, * @return error flag. */ template -static int lanczosRestart(handle_t const& handle, +static int lanczosRestart(raft::device_resources const& handle, index_type_t n, index_type_t iter, index_type_t iter_new, @@ -744,7 +744,7 @@ static int lanczosRestart(handle_t const& handle, */ template int computeSmallestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t nEigVecs, index_type_t maxIter, @@ -988,7 +988,7 @@ int computeSmallestEigenvectors( template int computeSmallestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, @@ -1091,7 +1091,7 @@ int computeSmallestEigenvectors( */ template int computeLargestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const* A, index_type_t nEigVecs, index_type_t maxIter, @@ -1338,7 +1338,7 @@ int computeLargestEigenvectors( template int computeLargestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, diff --git a/cpp/include/raft/sparse/solver/detail/mst_solver_inl.cuh b/cpp/include/raft/sparse/solver/detail/mst_solver_inl.cuh index d68d9f68b0..3ed58ea4ef 100644 --- a/cpp/include/raft/sparse/solver/detail/mst_solver_inl.cuh +++ b/cpp/include/raft/sparse/solver/detail/mst_solver_inl.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,17 +60,18 @@ inline curandStatus_t curand_generate_uniformX(curandGenerator_t generator, } template -MST_solver::MST_solver(const raft::handle_t& handle_, - const edge_t* offsets_, - const vertex_t* indices_, - const weight_t* weights_, - const vertex_t v_, - const edge_t e_, - vertex_t* color_, - cudaStream_t stream_, - bool symmetrize_output_, - bool initialize_colors_, - int iterations_) +MST_solver::MST_solver( + raft::device_resources const& handle_, + const edge_t* offsets_, + const vertex_t* indices_, + const weight_t* weights_, + const vertex_t v_, + const edge_t e_, + vertex_t* color_, + cudaStream_t stream_, + bool symmetrize_output_, + bool initialize_colors_, + int iterations_) : handle(handle_), offsets(offsets_), indices(indices_), diff --git a/cpp/include/raft/sparse/solver/lanczos.cuh b/cpp/include/raft/sparse/solver/lanczos.cuh index 9b5301988a..cdfaaa97f2 100644 --- a/cpp/include/raft/sparse/solver/lanczos.cuh +++ b/cpp/include/raft/sparse/solver/lanczos.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ namespace raft::sparse::solver { */ template int computeSmallestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, raft::spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, @@ -130,7 +130,7 @@ int computeSmallestEigenvectors( */ template int computeLargestEigenvectors( - handle_t const& handle, + raft::device_resources const& handle, raft::spectral::matrix::sparse_matrix_t const& A, index_type_t nEigVecs, index_type_t maxIter, diff --git a/cpp/include/raft/sparse/solver/mst.cuh b/cpp/include/raft/sparse/solver/mst.cuh index a941ce7c80..4f7600824a 100644 --- a/cpp/include/raft/sparse/solver/mst.cuh +++ b/cpp/include/raft/sparse/solver/mst.cuh @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace raft::sparse::solver { * when an msf is encountered) */ template -Graph_COO mst(const raft::handle_t& handle, +Graph_COO mst(raft::device_resources const& handle, edge_t const* offsets, vertex_t const* indices, weight_t const* weights, diff --git a/cpp/include/raft/sparse/solver/mst_solver.cuh b/cpp/include/raft/sparse/solver/mst_solver.cuh index a10b74d77b..c10d7caf59 100644 --- a/cpp/include/raft/sparse/solver/mst_solver.cuh +++ b/cpp/include/raft/sparse/solver/mst_solver.cuh @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include @@ -39,7 +39,7 @@ struct Graph_COO { template class MST_solver { public: - MST_solver(const raft::handle_t& handle_, + MST_solver(raft::device_resources const& handle_, const edge_t* offsets_, const vertex_t* indices_, const weight_t* weights_, @@ -56,7 +56,7 @@ class MST_solver { ~MST_solver() {} private: - const raft::handle_t& handle; + raft::device_resources const& handle; cudaStream_t stream; bool symmetrize_output, initialize_colors; int iterations; diff --git a/cpp/include/raft/spatial/knn/ann.cuh b/cpp/include/raft/spatial/knn/ann.cuh index befb5524ac..3d11ffbef4 100644 --- a/cpp/include/raft/spatial/knn/ann.cuh +++ b/cpp/include/raft/spatial/knn/ann.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ namespace raft::spatial::knn { */ template [[deprecated("Consider using new-style raft::spatial::knn::*::build functions")]] inline void -approx_knn_build_index(raft::handle_t& handle, +approx_knn_build_index(raft::device_resources& handle, raft::spatial::knn::knnIndex* index, knnIndexParam* params, raft::distance::DistanceType metric, @@ -67,7 +67,7 @@ approx_knn_build_index(raft::handle_t& handle, */ template [[deprecated("Consider using new-style raft::spatial::knn::*::search functions")]] inline void -approx_knn_search(raft::handle_t& handle, +approx_knn_search(raft::device_resources& handle, float* distances, int64_t* indices, raft::spatial::knn::knnIndex* index, diff --git a/cpp/include/raft/spatial/knn/ball_cover.cuh b/cpp/include/raft/spatial/knn/ball_cover.cuh index fdc2d41161..dda353e1c6 100644 --- a/cpp/include/raft/spatial/knn/ball_cover.cuh +++ b/cpp/include/raft/spatial/knn/ball_cover.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,14 +34,14 @@ namespace raft::spatial::knn { template -void rbc_build_index(const raft::handle_t& handle, +void rbc_build_index(raft::device_resources const& handle, BallCoverIndex& index) { raft::neighbors::ball_cover::build_index(handle, index); } template -void rbc_all_knn_query(const raft::handle_t& handle, +void rbc_all_knn_query(raft::device_resources const& handle, BallCoverIndex& index, int_t k, idx_t* inds, @@ -54,7 +54,7 @@ void rbc_all_knn_query(const raft::handle_t& handle, } template -void rbc_knn_query(const raft::handle_t& handle, +void rbc_knn_query(raft::device_resources const& handle, const BallCoverIndex& index, int_t k, const value_t* query, diff --git a/cpp/include/raft/spatial/knn/detail/ann_kmeans_balanced.cuh b/cpp/include/raft/spatial/knn/detail/ann_kmeans_balanced.cuh index ba88924da5..87818f49cf 100644 --- a/cpp/include/raft/spatial/knn/detail/ann_kmeans_balanced.cuh +++ b/cpp/include/raft/spatial/knn/detail/ann_kmeans_balanced.cuh @@ -74,7 +74,7 @@ constexpr static inline const float kAdjustCentersWeight = 7.0f; * @param mr (optional) memory resource to use for temporary allocations */ template -inline void predict_float_core(const handle_t& handle, +inline void predict_float_core(raft::device_resources const& handle, const float* centers, uint32_t n_clusters, uint32_t dim, @@ -243,7 +243,7 @@ constexpr auto calc_minibatch_size( * @param mr (optional) memory resource to use for temporary allocations on the device */ template -void calc_centers_and_sizes(const handle_t& handle, +void calc_centers_and_sizes(raft::device_resources const& handle, float* centers, uint32_t* cluster_sizes, uint32_t n_clusters, @@ -376,7 +376,7 @@ void compute_norm(float* dataset_norm, * @param mr (optional) memory resource to use for temporary allocations */ template -void predict(const handle_t& handle, +void predict(raft::device_resources const& handle, const float* centers, uint32_t n_clusters, uint32_t dim, @@ -632,7 +632,7 @@ auto adjust_centers(float* centers, * a memory resource for device allocations (makes sense to provide a memory pool here) */ template -void balancing_em_iters(const handle_t& handle, +void balancing_em_iters(raft::device_resources const& handle, uint32_t n_iters, uint32_t dim, const T* dataset, @@ -713,7 +713,7 @@ void balancing_em_iters(const handle_t& handle, /** Randomly initialize cluster centers and then call `balancing_em_iters`. */ template -void build_clusters(const handle_t& handle, +void build_clusters(raft::device_resources const& handle, uint32_t n_iters, uint32_t dim, const T* dataset, @@ -847,7 +847,7 @@ inline auto arrange_fine_clusters(uint32_t n_clusters, * is ignored and a warning is reported. */ template -auto build_fine_clusters(const handle_t& handle, +auto build_fine_clusters(raft::device_resources const& handle, uint32_t n_iters, uint32_t dim, const T* dataset_mptr, @@ -955,7 +955,7 @@ auto build_fine_clusters(const handle_t& handle, * @param stream */ template -void build_hierarchical(const handle_t& handle, +void build_hierarchical(raft::device_resources const& handle, uint32_t n_iters, uint32_t dim, const T* dataset, diff --git a/cpp/include/raft/spatial/knn/detail/ann_quantized.cuh b/cpp/include/raft/spatial/knn/detail/ann_quantized.cuh index f651e943e3..427e812cda 100644 --- a/cpp/include/raft/spatial/knn/detail/ann_quantized.cuh +++ b/cpp/include/raft/spatial/knn/detail/ann_quantized.cuh @@ -36,7 +36,7 @@ namespace raft::spatial::knn::detail { template -void approx_knn_build_index(const handle_t& handle, +void approx_knn_build_index(raft::device_resources const& handle, knnIndex* index, knnIndexParam* params, raft::distance::DistanceType metric, @@ -88,7 +88,7 @@ void approx_knn_build_index(const handle_t& handle, } template -void approx_knn_search(const handle_t& handle, +void approx_knn_search(raft::device_resources const& handle, float* distances, int64_t* indices, knnIndex* index, diff --git a/cpp/include/raft/spatial/knn/detail/ann_serialization.h b/cpp/include/raft/spatial/knn/detail/ann_serialization.h index cf2aeedcfc..34dc3cf00f 100644 --- a/cpp/include/raft/spatial/knn/detail/ann_serialization.h +++ b/cpp/include/raft/spatial/knn/detail/ann_serialization.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ T read_scalar(std::ifstream& file) template void write_mdspan( - const raft::handle_t& handle, + raft::device_resources const& handle, std::ofstream& of, const raft::device_mdspan& obj) { @@ -91,7 +91,7 @@ void write_mdspan( } template -void read_mdspan(const raft::handle_t& handle, +void read_mdspan(raft::device_resources const& handle, std::ifstream& file, raft::device_mdspan& obj) { @@ -131,7 +131,7 @@ void read_mdspan(const raft::handle_t& handle, } template -void read_mdspan(const raft::handle_t& handle, +void read_mdspan(raft::device_resources const& handle, std::ifstream& file, raft::device_mdspan&& obj) { diff --git a/cpp/include/raft/spatial/knn/detail/ball_cover.cuh b/cpp/include/raft/spatial/knn/detail/ball_cover.cuh index fd0314dbcc..7b3cf2d8f7 100644 --- a/cpp/include/raft/spatial/knn/detail/ball_cover.cuh +++ b/cpp/include/raft/spatial/knn/detail/ball_cover.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include "../ball_cover_types.hpp" #include "ball_cover/common.cuh" @@ -64,7 +64,7 @@ namespace detail { * @param index */ template -void sample_landmarks(const raft::handle_t& handle, +void sample_landmarks(raft::device_resources const& handle, BallCoverIndex& index) { rmm::device_uvector R_1nn_cols2(index.n_landmarks, handle.get_stream()); @@ -116,7 +116,7 @@ void sample_landmarks(const raft::handle_t& handle, * @param index */ template -void construct_landmark_1nn(const raft::handle_t& handle, +void construct_landmark_1nn(raft::device_resources const& handle, const value_idx* R_knn_inds_ptr, const value_t* R_knn_dists_ptr, value_int k, @@ -170,7 +170,7 @@ void construct_landmark_1nn(const raft::handle_t& handle, * @param R_knn_dists */ template -void k_closest_landmarks(const raft::handle_t& handle, +void k_closest_landmarks(raft::device_resources const& handle, const BallCoverIndex& index, const value_t* query_pts, value_int n_query_pts, @@ -206,7 +206,7 @@ void k_closest_landmarks(const raft::handle_t& handle, * @param index */ template -void compute_landmark_radii(const raft::handle_t& handle, +void compute_landmark_radii(raft::device_resources const& handle, BallCoverIndex& index) { auto entries = thrust::make_counting_iterator(0); @@ -237,7 +237,7 @@ template -void perform_rbc_query(const raft::handle_t& handle, +void perform_rbc_query(raft::device_resources const& handle, const BallCoverIndex& index, const value_t* query, value_int n_query_pts, @@ -339,7 +339,7 @@ template -void rbc_build_index(const raft::handle_t& handle, +void rbc_build_index(raft::device_resources const& handle, BallCoverIndex& index, distance_func dfunc) { @@ -398,7 +398,7 @@ template -void rbc_all_knn_query(const raft::handle_t& handle, +void rbc_all_knn_query(raft::device_resources const& handle, BallCoverIndex& index, value_int k, value_idx* inds, @@ -467,7 +467,7 @@ template -void rbc_knn_query(const raft::handle_t& handle, +void rbc_knn_query(raft::device_resources const& handle, const BallCoverIndex& index, value_int k, const value_t* query, diff --git a/cpp/include/raft/spatial/knn/detail/ball_cover/registers.cuh b/cpp/include/raft/spatial/knn/detail/ball_cover/registers.cuh index 530b0d3d04..394d27235b 100644 --- a/cpp/include/raft/spatial/knn/detail/ball_cover/registers.cuh +++ b/cpp/include/raft/spatial/knn/detail/ball_cover/registers.cuh @@ -467,7 +467,7 @@ template -void rbc_low_dim_pass_one(const raft::handle_t& handle, +void rbc_low_dim_pass_one(raft::device_resources const& handle, const BallCoverIndex& index, const value_t* query, const value_int n_query_rows, @@ -599,7 +599,7 @@ template -void rbc_low_dim_pass_two(const raft::handle_t& handle, +void rbc_low_dim_pass_two(raft::device_resources const& handle, const BallCoverIndex& index, const value_t* query, const value_int n_query_rows, diff --git a/cpp/include/raft/spatial/knn/detail/haversine_distance.cuh b/cpp/include/raft/spatial/knn/detail/haversine_distance.cuh index 9cecc0adf4..7d361ba4fb 100644 --- a/cpp/include/raft/spatial/knn/detail/haversine_distance.cuh +++ b/cpp/include/raft/spatial/knn/detail/haversine_distance.cuh @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/include/raft/spatial/knn/detail/ivf_flat_build.cuh b/cpp/include/raft/spatial/knn/detail/ivf_flat_build.cuh index 6e038db68f..b15acfe914 100644 --- a/cpp/include/raft/spatial/knn/detail/ivf_flat_build.cuh +++ b/cpp/include/raft/spatial/knn/detail/ivf_flat_build.cuh @@ -21,7 +21,7 @@ #include "ann_serialization.h" #include "ann_utils.cuh" -#include +#include #include #include #include @@ -116,7 +116,7 @@ __global__ void build_index_kernel(const LabelT* labels, /** See raft::spatial::knn::ivf_flat::extend docs */ template -inline auto extend(const handle_t& handle, +inline auto extend(raft::device_resources const& handle, const index& orig_index, const T* new_vectors, const IdxT* new_indices, @@ -256,9 +256,11 @@ inline auto extend(const handle_t& handle, /** See raft::spatial::knn::ivf_flat::build docs */ template -inline auto build( - const handle_t& handle, const index_params& params, const T* dataset, IdxT n_rows, uint32_t dim) - -> index +inline auto build(raft::device_resources const& handle, + const index_params& params, + const T* dataset, + IdxT n_rows, + uint32_t dim) -> index { auto stream = handle.get_stream(); common::nvtx::range fun_scope( @@ -323,7 +325,7 @@ inline auto build( * @param[in] n_candidates of neighbor_candidates */ template -inline void fill_refinement_index(const handle_t& handle, +inline void fill_refinement_index(raft::device_resources const& handle, index* refinement_index, const T* dataset, const IdxT* candidate_idx, @@ -391,7 +393,9 @@ static const int serialization_version = 1; * */ template -void save(const handle_t& handle, const std::string& filename, const index& index_) +void save(raft::device_resources const& handle, + const std::string& filename, + const index& index_) { std::ofstream of(filename, std::ios::out | std::ios::binary); if (!of) { RAFT_FAIL("Cannot open %s", filename.c_str()); } @@ -432,7 +436,7 @@ void save(const handle_t& handle, const std::string& filename, const index -auto load(const handle_t& handle, const std::string& filename) -> index +auto load(raft::device_resources const& handle, const std::string& filename) -> index { std::ifstream infile(filename, std::ios::in | std::ios::binary); diff --git a/cpp/include/raft/spatial/knn/detail/ivf_flat_search.cuh b/cpp/include/raft/spatial/knn/detail/ivf_flat_search.cuh index 82b7bcf81e..7f70d4b8a5 100644 --- a/cpp/include/raft/spatial/knn/detail/ivf_flat_search.cuh +++ b/cpp/include/raft/spatial/knn/detail/ivf_flat_search.cuh @@ -20,7 +20,7 @@ #include "ann_utils.cuh" #include -#include +#include #include #include #include @@ -1087,7 +1087,7 @@ void ivfflat_interleaved_scan(const ivf_flat::index& index, } template -void search_impl(const handle_t& handle, +void search_impl(raft::device_resources const& handle, const index& index, const T* queries, uint32_t n_queries, @@ -1270,7 +1270,7 @@ inline bool is_min_close(distance::DistanceType metric) /** See raft::spatial::knn::ivf_flat::search docs */ template -inline void search(const handle_t& handle, +inline void search(raft::device_resources const& handle, const search_params& params, const index& index, const T* queries, diff --git a/cpp/include/raft/spatial/knn/detail/ivf_pq_build.cuh b/cpp/include/raft/spatial/knn/detail/ivf_pq_build.cuh index adbedf854f..6922499445 100644 --- a/cpp/include/raft/spatial/knn/detail/ivf_pq_build.cuh +++ b/cpp/include/raft/spatial/knn/detail/ivf_pq_build.cuh @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -182,7 +182,7 @@ void copy_warped(T* out, * @param[out] rotation_matrix device pointer to a row-major matrix of size [n_rows, n_cols]. * @param rng random number generator state */ -inline void make_rotation_matrix(const handle_t& handle, +inline void make_rotation_matrix(raft::device_resources const& handle, bool force_random_rotation, uint32_t n_rows, uint32_t n_cols, @@ -226,7 +226,7 @@ inline void make_rotation_matrix(const handle_t& handle, * */ template -void select_residuals(const handle_t& handle, +void select_residuals(raft::device_resources const& handle, float* residuals, IdxT n_rows, uint32_t dim, @@ -275,7 +275,7 @@ void select_residuals(const handle_t& handle, */ template void flat_compute_residuals( - const handle_t& handle, + raft::device_resources const& handle, float* residuals, // [n_rows, rot_dim] IdxT n_rows, device_mdspan, row_major> rotation_matrix, // [rot_dim, dim] @@ -370,7 +370,7 @@ auto calculate_offsets_and_indices(IdxT n_rows, } template -void transpose_pq_centers(const handle_t& handle, +void transpose_pq_centers(const device_resources& handle, index& index, const float* pq_centers_source) { @@ -395,7 +395,7 @@ void transpose_pq_centers(const handle_t& handle, } template -void train_per_subset(const handle_t& handle, +void train_per_subset(raft::device_resources const& handle, index& index, size_t n_rows, const float* trainset, // [n_rows, dim] @@ -465,7 +465,7 @@ void train_per_subset(const handle_t& handle, } template -void train_per_cluster(const handle_t& handle, +void train_per_cluster(raft::device_resources const& handle, index& index, size_t n_rows, const float* trainset, // [n_rows, dim] @@ -546,7 +546,7 @@ void train_per_cluster(const handle_t& handle, * * @return Number of non-empty clusters */ -inline auto reorder_clusters_by_size_desc(const handle_t& handle, +inline auto reorder_clusters_by_size_desc(raft::device_resources const& handle, uint32_t* ordering, uint32_t* cluster_sizes_out, const uint32_t* cluster_sizes_in, @@ -752,7 +752,7 @@ __launch_bounds__(BlockSize) __global__ void process_and_fill_codes_kernel( * a memory resource to use for device allocations */ template -void process_and_fill_codes(const handle_t& handle, +void process_and_fill_codes(raft::device_resources const& handle, index& index, const T* new_vectors, std::variant src_offset_or_indices, @@ -922,7 +922,7 @@ void copy_index_data(index& target, /** See raft::spatial::knn::ivf_pq::extend docs */ template -auto extend(const handle_t& handle, +auto extend(raft::device_resources const& handle, const index& orig_index, const T* new_vectors, const IdxT* new_indices, @@ -1148,9 +1148,11 @@ auto extend(const handle_t& handle, /** See raft::spatial::knn::ivf_pq::build docs */ template -auto build( - const handle_t& handle, const index_params& params, const T* dataset, IdxT n_rows, uint32_t dim) - -> index +auto build(raft::device_resources const& handle, + const index_params& params, + const T* dataset, + IdxT n_rows, + uint32_t dim) -> index { common::nvtx::range fun_scope( "ivf_pq::build(%zu, %u)", size_t(n_rows), dim); @@ -1376,7 +1378,9 @@ static const int serialization_version = 1; * */ template -void save(const handle_t& handle_, const std::string& filename, const index& index_) +void save(raft::device_resources const& handle_, + const std::string& filename, + const index& index_) { std::ofstream of(filename, std::ios::out | std::ios::binary); if (!of) { RAFT_FAIL("Cannot open file %s", filename.c_str()); } @@ -1423,7 +1427,7 @@ void save(const handle_t& handle_, const std::string& filename, const index -auto load(const handle_t& handle_, const std::string& filename) -> index +auto load(raft::device_resources const& handle_, const std::string& filename) -> index { std::ifstream infile(filename, std::ios::in | std::ios::binary); diff --git a/cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh b/cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh index b47ba32c58..c3326f8fac 100644 --- a/cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh +++ b/cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -136,7 +136,7 @@ struct fp_8bit { * scores here. */ template -void select_clusters(const handle_t& handle, +void select_clusters(raft::device_resources const& handle, uint32_t* clusters_to_probe, // [n_queries, n_probes] float* float_queries, // [n_queries, dim_ext] uint32_t n_queries, @@ -1262,7 +1262,7 @@ inline auto is_local_topk_feasible(uint32_t k, uint32_t n_probes, uint32_t n_que * is guaranteed to fit into GPU memory. */ template -void ivfpq_search_worker(const handle_t& handle, +void ivfpq_search_worker(raft::device_resources const& handle, const index& index, uint32_t max_samples, uint32_t n_probes, @@ -1540,7 +1540,7 @@ inline auto get_max_batch_size(uint32_t k, /** See raft::spatial::knn::ivf_pq::search docs */ template -inline void search(const handle_t& handle, +inline void search(raft::device_resources const& handle, const search_params& params, const index& index, const T* queries, diff --git a/cpp/include/raft/spatial/knn/detail/knn_brute_force_faiss.cuh b/cpp/include/raft/spatial/knn/detail/knn_brute_force_faiss.cuh index b246121958..2b2b5cee0c 100644 --- a/cpp/include/raft/spatial/knn/detail/knn_brute_force_faiss.cuh +++ b/cpp/include/raft/spatial/knn/detail/knn_brute_force_faiss.cuh @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -215,7 +215,7 @@ inline void knn_merge_parts(value_t* inK, */ template void brute_force_knn_impl( - const raft::handle_t& handle, + raft::device_resources const& handle, std::vector& input, std::vector& sizes, IntType D, diff --git a/cpp/include/raft/spatial/knn/knn.cuh b/cpp/include/raft/spatial/knn/knn.cuh index f4b664fa16..ca2c248392 100644 --- a/cpp/include/raft/spatial/knn/knn.cuh +++ b/cpp/include/raft/spatial/knn/knn.cuh @@ -195,7 +195,7 @@ template * as input vector. */ template -void brute_force_knn(raft::handle_t const& handle, +void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, value_int D, diff --git a/cpp/include/raft/spectral/cluster_solvers.cuh b/cpp/include/raft/spectral/cluster_solvers.cuh index 6f9ebcd6af..1cb7aefd13 100644 --- a/cpp/include/raft/spectral/cluster_solvers.cuh +++ b/cpp/include/raft/spectral/cluster_solvers.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ struct kmeans_solver_t { { } - std::pair solve(handle_t const& handle, + std::pair solve(raft::device_resources const& handle, size_type_t n_obs_vecs, size_type_t dim, value_type_t const* __restrict__ obs, diff --git a/cpp/include/raft/spectral/cluster_solvers_deprecated.cuh b/cpp/include/raft/spectral/cluster_solvers_deprecated.cuh index 0beb1e5836..17dcf6b07c 100644 --- a/cpp/include/raft/spectral/cluster_solvers_deprecated.cuh +++ b/cpp/include/raft/spectral/cluster_solvers_deprecated.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ struct kmeans_solver_deprecated_t { { } - std::pair solve(handle_t const& handle, + std::pair solve(raft::device_resources const& handle, size_type_t n_obs_vecs, size_type_t dim, value_type_t const* __restrict__ obs, diff --git a/cpp/include/raft/spectral/detail/matrix_wrappers.hpp b/cpp/include/raft/spectral/detail/matrix_wrappers.hpp index f225438841..e32b718117 100644 --- a/cpp/include/raft/spectral/detail/matrix_wrappers.hpp +++ b/cpp/include/raft/spectral/detail/matrix_wrappers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include #include @@ -89,7 +89,7 @@ struct vector_view_t { template class vector_t { public: - vector_t(handle_t const& raft_handle, size_type sz) + vector_t(device_resources const& raft_handle, size_type sz) : buffer_(sz, raft_handle.get_stream()), thrust_policy(raft_handle.get_thrust_policy()) { } @@ -128,7 +128,7 @@ class vector_t { template struct sparse_matrix_t { - sparse_matrix_t(handle_t const& raft_handle, + sparse_matrix_t(device_resources const& raft_handle, index_type const* row_offsets, index_type const* col_indices, value_type const* values, @@ -145,7 +145,7 @@ struct sparse_matrix_t { { } - sparse_matrix_t(handle_t const& raft_handle, + sparse_matrix_t(device_resources const& raft_handle, index_type const* row_offsets, index_type const* col_indices, value_type const* values, @@ -162,7 +162,7 @@ struct sparse_matrix_t { } template - sparse_matrix_t(handle_t const& raft_handle, CSRView const& csr_view) + sparse_matrix_t(device_resources const& raft_handle, CSRView const& csr_view) : handle_(raft_handle), row_offsets_(csr_view.offsets), col_indices_(csr_view.indices), @@ -276,7 +276,7 @@ struct sparse_matrix_t { #endif } - handle_t const& get_handle(void) const { return handle_; } + device_resources const& get_handle(void) const { return handle_; } #if not defined CUDA_ENFORCE_LOWER and CUDA_VER_10_1_UP cusparseSpMVAlg_t translate_algorithm(sparse_mv_alg_t alg) const @@ -292,7 +292,7 @@ struct sparse_matrix_t { // private: // maybe not, keep this ASAPBNS ("as simple as possible, but not simpler"); hence, // aggregate - handle_t const& handle_; + raft::device_resources const& handle_; index_type const* row_offsets_; index_type const* col_indices_; value_type const* values_; @@ -303,7 +303,7 @@ struct sparse_matrix_t { template struct laplacian_matrix_t : sparse_matrix_t { - laplacian_matrix_t(handle_t const& raft_handle, + laplacian_matrix_t(device_resources const& raft_handle, index_type const* row_offsets, index_type const* col_indices, value_type const* values, @@ -318,7 +318,7 @@ struct laplacian_matrix_t : sparse_matrix_t { sparse_matrix_t::mv(1, ones.raw(), 0, diagonal_.raw()); } - laplacian_matrix_t(handle_t const& raft_handle, + laplacian_matrix_t(device_resources const& raft_handle, sparse_matrix_t const& csr_m) : sparse_matrix_t(raft_handle, csr_m.row_offsets_, @@ -376,7 +376,7 @@ struct laplacian_matrix_t : sparse_matrix_t { template struct modularity_matrix_t : laplacian_matrix_t { - modularity_matrix_t(handle_t const& raft_handle, + modularity_matrix_t(device_resources const& raft_handle, index_type const* row_offsets, index_type const* col_indices, value_type const* values, @@ -388,7 +388,7 @@ struct modularity_matrix_t : laplacian_matrix_t { edge_sum_ = laplacian_matrix_t::diagonal_.nrm1(); } - modularity_matrix_t(handle_t const& raft_handle, + modularity_matrix_t(device_resources const& raft_handle, sparse_matrix_t const& csr_m) : laplacian_matrix_t(raft_handle, csr_m) { diff --git a/cpp/include/raft/spectral/detail/modularity_maximization.hpp b/cpp/include/raft/spectral/detail/modularity_maximization.hpp index b60ca719fb..160664bae8 100644 --- a/cpp/include/raft/spectral/detail/modularity_maximization.hpp +++ b/cpp/include/raft/spectral/detail/modularity_maximization.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ namespace detail { */ template std::tuple modularity_maximization( - handle_t const& handle, + raft::device_resources const& handle, raft::spectral::matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, @@ -140,7 +140,7 @@ std::tuple modularity_maximization( * @param modularity On exit, modularity */ template -void analyzeModularity(handle_t const& handle, +void analyzeModularity(raft::device_resources const& handle, raft::spectral::matrix::sparse_matrix_t const& csr_m, vertex_t nClusters, vertex_t const* __restrict__ clusters, diff --git a/cpp/include/raft/spectral/detail/partition.hpp b/cpp/include/raft/spectral/detail/partition.hpp index 1e0cc78826..6750f5d93f 100644 --- a/cpp/include/raft/spectral/detail/partition.hpp +++ b/cpp/include/raft/spectral/detail/partition.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ namespace detail { */ template std::tuple partition( - handle_t const& handle, + raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, @@ -131,7 +131,7 @@ std::tuple partition( * @return error flag. */ template -void analyzePartition(handle_t const& handle, +void analyzePartition(raft::device_resources const& handle, spectral::matrix::sparse_matrix_t const& csr_m, vertex_t nClusters, const vertex_t* __restrict__ clusters, diff --git a/cpp/include/raft/spectral/detail/spectral_util.cuh b/cpp/include/raft/spectral/detail/spectral_util.cuh index 5991e71ec6..ae75031522 100644 --- a/cpp/include/raft/spectral/detail/spectral_util.cuh +++ b/cpp/include/raft/spectral/detail/spectral_util.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include #include @@ -116,7 +116,10 @@ cudaError_t scale_obs(index_type_t m, index_type_t n, value_type_t* obs) } template -void transform_eigen_matrix(handle_t const& handle, edge_t n, vertex_t nEigVecs, weight_t* eigVecs) +void transform_eigen_matrix(raft::device_resources const& handle, + edge_t n, + vertex_t nEigVecs, + weight_t* eigVecs) { auto stream = handle.get_stream(); auto cublas_h = handle.get_cublas_handle(); @@ -207,7 +210,7 @@ struct equal_to_i_op { // Construct indicator vector for ith partition // template -bool construct_indicator(handle_t const& handle, +bool construct_indicator(raft::device_resources const& handle, edge_t index, edge_t n, weight_t& clustersize, diff --git a/cpp/include/raft/spectral/eigen_solvers.cuh b/cpp/include/raft/spectral/eigen_solvers.cuh index 88e4abe513..3f6959d2e2 100644 --- a/cpp/include/raft/spectral/eigen_solvers.cuh +++ b/cpp/include/raft/spectral/eigen_solvers.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ struct lanczos_solver_t { } index_type_t solve_smallest_eigenvectors( - handle_t const& handle, + raft::device_resources const& handle, matrix::sparse_matrix_t const& A, value_type_t* __restrict__ eigVals, value_type_t* __restrict__ eigVecs) const @@ -73,7 +73,7 @@ struct lanczos_solver_t { } index_type_t solve_largest_eigenvectors( - handle_t const& handle, + raft::device_resources const& handle, matrix::sparse_matrix_t const& A, value_type_t* __restrict__ eigVals, value_type_t* __restrict__ eigVecs) const diff --git a/cpp/include/raft/spectral/modularity_maximization.cuh b/cpp/include/raft/spectral/modularity_maximization.cuh index 61d85aefaa..29d432c042 100644 --- a/cpp/include/raft/spectral/modularity_maximization.cuh +++ b/cpp/include/raft/spectral/modularity_maximization.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ namespace spectral { */ template std::tuple modularity_maximization( - handle_t const& handle, + raft::device_resources const& handle, matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, @@ -70,7 +70,7 @@ std::tuple modularity_maximization( * @param modularity On exit, modularity */ template -void analyzeModularity(handle_t const& handle, +void analyzeModularity(raft::device_resources const& handle, matrix::sparse_matrix_t const& csr_m, vertex_t nClusters, vertex_t const* __restrict__ clusters, diff --git a/cpp/include/raft/spectral/partition.cuh b/cpp/include/raft/spectral/partition.cuh index 2d21f2223c..0dec230752 100644 --- a/cpp/include/raft/spectral/partition.cuh +++ b/cpp/include/raft/spectral/partition.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ namespace spectral { */ template std::tuple partition( - handle_t const& handle, + raft::device_resources const& handle, matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, @@ -78,7 +78,7 @@ std::tuple partition( * @param cost On exit, partition cost function. */ template -void analyzePartition(handle_t const& handle, +void analyzePartition(raft::device_resources const& handle, matrix::sparse_matrix_t const& csr_m, vertex_t nClusters, const vertex_t* __restrict__ clusters, diff --git a/cpp/include/raft/stats/accuracy.cuh b/cpp/include/raft/stats/accuracy.cuh index 3bd0d40091..7a5780fbc9 100644 --- a/cpp/include/raft/stats/accuracy.cuh +++ b/cpp/include/raft/stats/accuracy.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ float accuracy(const math_t* predictions, const math_t* ref_predictions, int n, * @return: Accuracy score in [0, 1]; higher is better. */ template -float accuracy(const raft::handle_t& handle, +float accuracy(raft::device_resources const& handle, raft::device_vector_view predictions, raft::device_vector_view ref_predictions) { diff --git a/cpp/include/raft/stats/adjusted_rand_index.cuh b/cpp/include/raft/stats/adjusted_rand_index.cuh index 402071f498..d2815fe753 100644 --- a/cpp/include/raft/stats/adjusted_rand_index.cuh +++ b/cpp/include/raft/stats/adjusted_rand_index.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ double adjusted_rand_index(const T* firstClusterArray, * @return the Adjusted RandIndex */ template -double adjusted_rand_index(const raft::handle_t& handle, +double adjusted_rand_index(raft::device_resources const& handle, raft::device_vector_view first_cluster_array, raft::device_vector_view second_cluster_array) { diff --git a/cpp/include/raft/stats/completeness_score.cuh b/cpp/include/raft/stats/completeness_score.cuh index a39315dc7a..17ff658ac8 100644 --- a/cpp/include/raft/stats/completeness_score.cuh +++ b/cpp/include/raft/stats/completeness_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ double completeness_score(const T* truthClusterArray, * @return the cluster completeness score */ template -double completeness_score(const raft::handle_t& handle, +double completeness_score(raft::device_resources const& handle, raft::device_vector_view truth_cluster_array, raft::device_vector_view pred_cluster_array, value_t lower_label_range, diff --git a/cpp/include/raft/stats/contingency_matrix.cuh b/cpp/include/raft/stats/contingency_matrix.cuh index ecf9c744ee..e309e8b4b9 100644 --- a/cpp/include/raft/stats/contingency_matrix.cuh +++ b/cpp/include/raft/stats/contingency_matrix.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -120,7 +120,7 @@ void contingencyMatrix(const T* groundTruth, * @param[out] maxLabel: calculated max value in input array */ template -void get_input_class_cardinality(const raft::handle_t& handle, +void get_input_class_cardinality(raft::device_resources const& handle, raft::device_vector_view groundTruth, raft::host_scalar_view minLabel, raft::host_scalar_view maxLabel) @@ -158,7 +158,7 @@ template -void contingency_matrix(const raft::handle_t& handle, +void contingency_matrix(raft::device_resources const& handle, raft::device_vector_view ground_truth, raft::device_vector_view predicted_label, raft::device_matrix_view out_mat, diff --git a/cpp/include/raft/stats/cov.cuh b/cpp/include/raft/stats/cov.cuh index 9829564a5a..c0c387e067 100644 --- a/cpp/include/raft/stats/cov.cuh +++ b/cpp/include/raft/stats/cov.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ namespace stats { * function returns! */ template -void cov(const raft::handle_t& handle, +void cov(raft::device_resources const& handle, Type* covar, Type* data, const Type* mu, @@ -85,7 +85,7 @@ void cov(const raft::handle_t& handle, * function returns! */ template -void cov(const raft::handle_t& handle, +void cov(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, raft::device_matrix_view covar, diff --git a/cpp/include/raft/stats/detail/batched/silhouette_score.cuh b/cpp/include/raft/stats/detail/batched/silhouette_score.cuh index 5bd8c4a7ab..a184fe22ef 100644 --- a/cpp/include/raft/stats/detail/batched/silhouette_score.cuh +++ b/cpp/include/raft/stats/detail/batched/silhouette_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ __global__ void compute_chunked_a_b_kernel(value_t* a, } template -rmm::device_uvector get_cluster_counts(const raft::handle_t& handle, +rmm::device_uvector get_cluster_counts(raft::device_resources const& handle, const label_idx* y, value_idx& n_rows, label_idx& n_labels) @@ -128,7 +128,7 @@ rmm::device_uvector get_cluster_counts(const raft::handle_t& handle, } template -rmm::device_uvector get_pairwise_distance(const raft::handle_t& handle, +rmm::device_uvector get_pairwise_distance(raft::device_resources const& handle, const value_t* left_begin, const value_t* right_begin, value_idx& n_left_rows, @@ -146,7 +146,7 @@ rmm::device_uvector get_pairwise_distance(const raft::handle_t& handle, } template -void compute_chunked_a_b(const raft::handle_t& handle, +void compute_chunked_a_b(raft::device_resources const& handle, value_t* a, value_t* b, value_idx& row_offset, @@ -169,7 +169,7 @@ void compute_chunked_a_b(const raft::handle_t& handle, template value_t silhouette_score( - const raft::handle_t& handle, + raft::device_resources const& handle, const value_t* X, value_idx n_rows, value_idx n_cols, diff --git a/cpp/include/raft/stats/detail/cov.cuh b/cpp/include/raft/stats/detail/cov.cuh index 24de58dd91..0561ac269b 100644 --- a/cpp/include/raft/stats/detail/cov.cuh +++ b/cpp/include/raft/stats/detail/cov.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace detail { * function returns! */ template -void cov(const raft::handle_t& handle, +void cov(raft::device_resources const& handle, Type* covar, Type* data, const Type* mu, diff --git a/cpp/include/raft/stats/detail/silhouette_score.cuh b/cpp/include/raft/stats/detail/silhouette_score.cuh index 3cf95c3941..f3839b99c8 100644 --- a/cpp/include/raft/stats/detail/silhouette_score.cuh +++ b/cpp/include/raft/stats/detail/silhouette_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,7 +191,7 @@ struct SilOp { */ template DataT silhouette_score( - const raft::handle_t& handle, + raft::device_resources const& handle, const DataT* X_in, int nRows, int nCols, diff --git a/cpp/include/raft/stats/detail/trustworthiness_score.cuh b/cpp/include/raft/stats/detail/trustworthiness_score.cuh index feb3fe607d..23f84754da 100644 --- a/cpp/include/raft/stats/detail/trustworthiness_score.cuh +++ b/cpp/include/raft/stats/detail/trustworthiness_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ __global__ void compute_rank(double* rank, * @param[out] distances KNN distances */ template -void run_knn(const raft::handle_t& h, +void run_knn(const raft::device_resources& h, math_t* input, int n, int d, @@ -128,7 +128,7 @@ void run_knn(const raft::handle_t& h, * @return Trustworthiness score */ template -double trustworthiness_score(const raft::handle_t& h, +double trustworthiness_score(const raft::device_resources& h, const math_t* X, math_t* X_embedded, int n, diff --git a/cpp/include/raft/stats/dispersion.cuh b/cpp/include/raft/stats/dispersion.cuh index 3e4b2d7d50..8600305d9e 100644 --- a/cpp/include/raft/stats/dispersion.cuh +++ b/cpp/include/raft/stats/dispersion.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ DataT dispersion(const DataT* centroids, */ template value_t cluster_dispersion( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view centroids, raft::device_vector_view cluster_sizes, std::optional> global_centroid, @@ -117,7 +117,7 @@ value_t cluster_dispersion( */ template value_t cluster_dispersion( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view centroids, raft::device_vector_view cluster_sizes, std::nullopt_t global_centroid, diff --git a/cpp/include/raft/stats/entropy.cuh b/cpp/include/raft/stats/entropy.cuh index 60836c8782..d59dc8e37a 100644 --- a/cpp/include/raft/stats/entropy.cuh +++ b/cpp/include/raft/stats/entropy.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ double entropy(const T* clusterArray, * @return the entropy score */ template -double entropy(const raft::handle_t& handle, +double entropy(raft::device_resources const& handle, raft::device_vector_view cluster_array, const value_t lower_label_range, const value_t upper_label_range) diff --git a/cpp/include/raft/stats/histogram.cuh b/cpp/include/raft/stats/histogram.cuh index 79fa881070..f829b0317e 100644 --- a/cpp/include/raft/stats/histogram.cuh +++ b/cpp/include/raft/stats/histogram.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ void histogram(HistType type, * @note signature of binner_op is `int func(value_t, IdxT);` */ template > -void histogram(const raft::handle_t& handle, +void histogram(raft::device_resources const& handle, HistType type, raft::device_matrix_view data, raft::device_matrix_view bins, diff --git a/cpp/include/raft/stats/homogeneity_score.cuh b/cpp/include/raft/stats/homogeneity_score.cuh index e1b627f8f1..173d63e47e 100644 --- a/cpp/include/raft/stats/homogeneity_score.cuh +++ b/cpp/include/raft/stats/homogeneity_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ double homogeneity_score(const T* truthClusterArray, * @return the homogeneity score */ template -double homogeneity_score(const raft::handle_t& handle, +double homogeneity_score(raft::device_resources const& handle, raft::device_vector_view truth_cluster_array, raft::device_vector_view pred_cluster_array, value_t lower_label_range, diff --git a/cpp/include/raft/stats/information_criterion.cuh b/cpp/include/raft/stats/information_criterion.cuh index bddd603d01..b54f126859 100644 --- a/cpp/include/raft/stats/information_criterion.cuh +++ b/cpp/include/raft/stats/information_criterion.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ #pragma once #include -#include +#include #include #include @@ -91,7 +91,7 @@ void information_criterion_batched(ScalarT* d_ic, * @param[in] n_samples Number of samples in each series */ template -void information_criterion_batched(const raft::handle_t& handle, +void information_criterion_batched(raft::device_resources const& handle, raft::device_vector_view d_loglikelihood, raft::device_vector_view d_ic, IC_Type ic_type, diff --git a/cpp/include/raft/stats/kl_divergence.cuh b/cpp/include/raft/stats/kl_divergence.cuh index e969af7633..d27f736255 100644 --- a/cpp/include/raft/stats/kl_divergence.cuh +++ b/cpp/include/raft/stats/kl_divergence.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ DataT kl_divergence(const DataT* modelPDF, const DataT* candidatePDF, int size, * @return the KL Divergence value */ template -value_t kl_divergence(const raft::handle_t& handle, +value_t kl_divergence(raft::device_resources const& handle, raft::device_vector_view modelPDF, raft::device_vector_view candidatePDF) { diff --git a/cpp/include/raft/stats/mean.cuh b/cpp/include/raft/stats/mean.cuh index c944247b33..a576e63bee 100644 --- a/cpp/include/raft/stats/mean.cuh +++ b/cpp/include/raft/stats/mean.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include namespace raft { @@ -70,7 +70,7 @@ void mean( * to normalize the output using N-1 or N, for true or false, respectively */ template -void mean(const raft::handle_t& handle, +void mean(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, bool sample) diff --git a/cpp/include/raft/stats/mean_center.cuh b/cpp/include/raft/stats/mean_center.cuh index b33b1bf507..b333b3c8da 100644 --- a/cpp/include/raft/stats/mean_center.cuh +++ b/cpp/include/raft/stats/mean_center.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ void meanAdd(Type* out, * @param[in] bcast_along_rows whether to broadcast vector along rows or columns */ template -void mean_center(const raft::handle_t& handle, +void mean_center(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, raft::device_matrix_view out, @@ -133,7 +133,7 @@ void mean_center(const raft::handle_t& handle, * @param[in] bcast_along_rows whether to broadcast vector along rows or columns */ template -void mean_add(const raft::handle_t& handle, +void mean_add(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, raft::device_matrix_view out, diff --git a/cpp/include/raft/stats/meanvar.cuh b/cpp/include/raft/stats/meanvar.cuh index b839ae7b72..0ee21d1325 100644 --- a/cpp/include/raft/stats/meanvar.cuh +++ b/cpp/include/raft/stats/meanvar.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ void meanvar(Type* mean, * normalize the variance using N-1 or N, for true or false respectively. */ template -void meanvar(const raft::handle_t& handle, +void meanvar(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mean, raft::device_vector_view var, diff --git a/cpp/include/raft/stats/minmax.cuh b/cpp/include/raft/stats/minmax.cuh index 24e432e8da..8af4f7a92c 100644 --- a/cpp/include/raft/stats/minmax.cuh +++ b/cpp/include/raft/stats/minmax.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ void minmax(const T* data, * in shared memory */ template -void minmax(const raft::handle_t& handle, +void minmax(raft::device_resources const& handle, raft::device_matrix_view data, std::optional> rowids, std::optional> colids, diff --git a/cpp/include/raft/stats/mutual_info_score.cuh b/cpp/include/raft/stats/mutual_info_score.cuh index 8158c4020a..ca7f33d398 100644 --- a/cpp/include/raft/stats/mutual_info_score.cuh +++ b/cpp/include/raft/stats/mutual_info_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ double mutual_info_score(const T* firstClusterArray, * @return the mutual information score */ template -double mutual_info_score(const raft::handle_t& handle, +double mutual_info_score(raft::device_resources const& handle, raft::device_vector_view first_cluster_array, raft::device_vector_view second_cluster_array, value_t lower_label_range, diff --git a/cpp/include/raft/stats/r2_score.cuh b/cpp/include/raft/stats/r2_score.cuh index 5e867b64a1..1048deb7f3 100644 --- a/cpp/include/raft/stats/r2_score.cuh +++ b/cpp/include/raft/stats/r2_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ math_t r2_score(math_t* y, math_t* y_hat, int n, cudaStream_t stream) * @note The constness of y and y_hat is currently casted away. */ template -value_t r2_score(const raft::handle_t& handle, +value_t r2_score(raft::device_resources const& handle, raft::device_vector_view y, raft::device_vector_view y_hat) { diff --git a/cpp/include/raft/stats/rand_index.cuh b/cpp/include/raft/stats/rand_index.cuh index 09dc874d93..25b92e4e10 100644 --- a/cpp/include/raft/stats/rand_index.cuh +++ b/cpp/include/raft/stats/rand_index.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include namespace raft { @@ -55,7 +55,7 @@ double rand_index(T* firstClusterArray, T* secondClusterArray, uint64_t size, cu * @return: The RandIndex value. */ template -double rand_index(const raft::handle_t& handle, +double rand_index(raft::device_resources const& handle, raft::device_vector_view first_cluster_array, raft::device_vector_view second_cluster_array) { diff --git a/cpp/include/raft/stats/regression_metrics.cuh b/cpp/include/raft/stats/regression_metrics.cuh index c45e3be870..7c3ca7386b 100644 --- a/cpp/include/raft/stats/regression_metrics.cuh +++ b/cpp/include/raft/stats/regression_metrics.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include #include @@ -73,7 +73,7 @@ void regression_metrics(const T* predictions, * ref_predictions[i]| for i in [0, n). */ template -void regression_metrics(const raft::handle_t& handle, +void regression_metrics(raft::device_resources const& handle, raft::device_vector_view predictions, raft::device_vector_view ref_predictions, raft::host_scalar_view mean_abs_error, diff --git a/cpp/include/raft/stats/silhouette_score.cuh b/cpp/include/raft/stats/silhouette_score.cuh index 0763cdfe1c..db9db1f99a 100644 --- a/cpp/include/raft/stats/silhouette_score.cuh +++ b/cpp/include/raft/stats/silhouette_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace stats { */ template DataT silhouette_score( - const raft::handle_t& handle, + raft::device_resources const& handle, DataT* X_in, int nRows, int nCols, @@ -60,7 +60,7 @@ DataT silhouette_score( template value_t silhouette_score_batched( - const raft::handle_t& handle, + raft::device_resources const& handle, value_t* X, value_idx n_rows, value_idx n_cols, @@ -98,7 +98,7 @@ value_t silhouette_score_batched( */ template value_t silhouette_score( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X_in, raft::device_vector_view labels, std::optional> silhouette_score_per_sample, @@ -144,7 +144,7 @@ value_t silhouette_score( */ template value_t silhouette_score_batched( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view labels, std::optional> silhouette_score_per_sample, @@ -187,7 +187,7 @@ value_t silhouette_score_batched( */ template value_t silhouette_score( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X_in, raft::device_vector_view labels, std::nullopt_t silhouette_score_per_sample, @@ -207,7 +207,7 @@ value_t silhouette_score( */ template value_t silhouette_score_batched( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X, raft::device_vector_view labels, std::nullopt_t silhouette_score_per_sample, diff --git a/cpp/include/raft/stats/stddev.cuh b/cpp/include/raft/stats/stddev.cuh index 27bd95f0ad..0b038c85ea 100644 --- a/cpp/include/raft/stats/stddev.cuh +++ b/cpp/include/raft/stats/stddev.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include namespace raft { @@ -109,7 +109,7 @@ void vars(Type* var, * to normalize the output using N-1 or N, for true or false, respectively */ template -void stddev(const raft::handle_t& handle, +void stddev(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, raft::device_vector_view std, @@ -156,7 +156,7 @@ void stddev(const raft::handle_t& handle, * to normalize the output using N-1 or N, for true or false, respectively */ template -void vars(const raft::handle_t& handle, +void vars(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view mu, raft::device_vector_view var, diff --git a/cpp/include/raft/stats/sum.cuh b/cpp/include/raft/stats/sum.cuh index c3aafe286a..5f169b3384 100644 --- a/cpp/include/raft/stats/sum.cuh +++ b/cpp/include/raft/stats/sum.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ void sum(Type* output, const Type* input, IdxType D, IdxType N, bool rowMajor, c * @param[out] output the output mean vector */ template -void sum(const raft::handle_t& handle, +void sum(raft::device_resources const& handle, raft::device_matrix_view input, raft::device_vector_view output) { diff --git a/cpp/include/raft/stats/trustworthiness_score.cuh b/cpp/include/raft/stats/trustworthiness_score.cuh index e8e60871d0..a79cda8dfc 100644 --- a/cpp/include/raft/stats/trustworthiness_score.cuh +++ b/cpp/include/raft/stats/trustworthiness_score.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include namespace raft { @@ -38,7 +38,7 @@ namespace stats { * @return[out] Trustworthiness score */ template -double trustworthiness_score(const raft::handle_t& h, +double trustworthiness_score(const raft::device_resources& h, const math_t* X, math_t* X_embedded, int n, @@ -71,7 +71,7 @@ double trustworthiness_score(const raft::handle_t& h, */ template double trustworthiness_score( - const raft::handle_t& handle, + raft::device_resources const& handle, raft::device_matrix_view X, raft::device_matrix_view X_embedded, int n_neighbors, diff --git a/cpp/include/raft/stats/v_measure.cuh b/cpp/include/raft/stats/v_measure.cuh index a5f5b58365..be1d83d59d 100644 --- a/cpp/include/raft/stats/v_measure.cuh +++ b/cpp/include/raft/stats/v_measure.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include namespace raft { @@ -68,7 +68,7 @@ double v_measure(const T* truthClusterArray, * @return the v-measure between the two clusters */ template -double v_measure(const raft::handle_t& handle, +double v_measure(raft::device_resources const& handle, raft::device_vector_view truth_cluster_array, raft::device_vector_view pred_cluster_array, value_t lower_label_range, diff --git a/cpp/include/raft/stats/weighted_mean.cuh b/cpp/include/raft/stats/weighted_mean.cuh index 8c7f1ca7b5..7f061e0b45 100644 --- a/cpp/include/raft/stats/weighted_mean.cuh +++ b/cpp/include/raft/stats/weighted_mean.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ void colWeightedMean( * @param[in] along_rows whether to reduce along rows or columns */ template -void weighted_mean(const raft::handle_t& handle, +void weighted_mean(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view weights, raft::device_vector_view mu, @@ -154,7 +154,7 @@ void weighted_mean(const raft::handle_t& handle, * @param[out] mu the output mean vector of size nrows */ template -void row_weighted_mean(const raft::handle_t& handle, +void row_weighted_mean(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view weights, raft::device_vector_view mu) @@ -175,7 +175,7 @@ void row_weighted_mean(const raft::handle_t& handle, * @param[out] mu the output mean vector of size ncols */ template -void col_weighted_mean(const raft::handle_t& handle, +void col_weighted_mean(raft::device_resources const& handle, raft::device_matrix_view data, raft::device_vector_view weights, raft::device_vector_view mu) diff --git a/cpp/include/raft/util/cache.cuh b/cpp/include/raft/util/cache.cuh index ccd5d1ab86..77e3ed2d6d 100644 --- a/cpp/include/raft/util/cache.cuh +++ b/cpp/include/raft/util/cache.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ namespace raft::cache { * // We assume that our ML algo repeatedly calls calc, and the set of keys have * // an overlap. We will use the cache to avoid repeated calculations. * - * // Assume we have raft::handle_t& h, and cudaStream_t stream + * // Assume we have raft::device_resources& h, and cudaStream_t stream * Cache cache(h.get_device_allocator(), stream, m); * * // A buffer that we will reuse to store the cache indices. diff --git a/cpp/include/raft_runtime/cluster/kmeans.hpp b/cpp/include/raft_runtime/cluster/kmeans.hpp index 241f5758e8..3386774414 100644 --- a/cpp/include/raft_runtime/cluster/kmeans.hpp +++ b/cpp/include/raft_runtime/cluster/kmeans.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include @@ -28,7 +28,7 @@ namespace raft::runtime::cluster::kmeans { * @{ */ -void update_centroids(raft::handle_t const& handle, +void update_centroids(raft::device_resources const& handle, const float* X, int n_samples, int n_features, @@ -39,7 +39,7 @@ void update_centroids(raft::handle_t const& handle, float* new_centroids, float* weight_per_cluster); -void update_centroids(raft::handle_t const& handle, +void update_centroids(raft::device_resources const& handle, const double* X, int n_samples, int n_features, @@ -50,7 +50,7 @@ void update_centroids(raft::handle_t const& handle, double* new_centroids, double* weight_per_cluster); -void fit(handle_t const& handle, +void fit(raft::device_resources const& handle, const raft::cluster::kmeans::KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -58,7 +58,7 @@ void fit(handle_t const& handle, raft::host_scalar_view inertia, raft::host_scalar_view n_iter); -void fit(handle_t const& handle, +void fit(raft::device_resources const& handle, const raft::cluster::kmeans::KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, @@ -66,7 +66,7 @@ void fit(handle_t const& handle, raft::host_scalar_view inertia, raft::host_scalar_view n_iter); -void cluster_cost(raft::handle_t const& handle, +void cluster_cost(raft::device_resources const& handle, const float* X, int n_samples, int n_features, @@ -74,7 +74,7 @@ void cluster_cost(raft::handle_t const& handle, const float* centroids, float* cost); -void cluster_cost(raft::handle_t const& handle, +void cluster_cost(raft::device_resources const& handle, const double* X, int n_samples, int n_features, diff --git a/cpp/include/raft_runtime/distance/fused_l2_nn.hpp b/cpp/include/raft_runtime/distance/fused_l2_nn.hpp index 46c9aa0b43..bdac3723e2 100644 --- a/cpp/include/raft_runtime/distance/fused_l2_nn.hpp +++ b/cpp/include/raft_runtime/distance/fused_l2_nn.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include namespace raft::runtime::distance { @@ -42,7 +42,7 @@ namespace raft::runtime::distance { * @param[in] k gemm k * @param[in] sqrt Whether the output `minDist` should contain L2-sqrt */ -void fused_l2_nn_min_arg(raft::handle_t const& handle, +void fused_l2_nn_min_arg(raft::device_resources const& handle, int* min, const float* x, const float* y, @@ -51,7 +51,7 @@ void fused_l2_nn_min_arg(raft::handle_t const& handle, int k, bool sqrt); -void fused_l2_nn_min_arg(raft::handle_t const& handle, +void fused_l2_nn_min_arg(raft::device_resources const& handle, int* min, const double* x, const double* y, diff --git a/cpp/include/raft_runtime/distance/pairwise_distance.hpp b/cpp/include/raft_runtime/distance/pairwise_distance.hpp index 02dca87e43..751f821ffb 100644 --- a/cpp/include/raft_runtime/distance/pairwise_distance.hpp +++ b/cpp/include/raft_runtime/distance/pairwise_distance.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace raft::runtime::distance { * @{ */ -void pairwise_distance(raft::handle_t const& handle, +void pairwise_distance(raft::device_resources const& handle, float* x, float* y, float* dists, @@ -34,7 +34,7 @@ void pairwise_distance(raft::handle_t const& handle, bool isRowMajor, float metric_arg); -void pairwise_distance(raft::handle_t const& handle, +void pairwise_distance(raft::device_resources const& handle, double* x, double* y, double* dists, diff --git a/cpp/include/raft_runtime/neighbors/ivf_pq.hpp b/cpp/include/raft_runtime/neighbors/ivf_pq.hpp index 7956e41497..cae32c9530 100644 --- a/cpp/include/raft_runtime/neighbors/ivf_pq.hpp +++ b/cpp/include/raft_runtime/neighbors/ivf_pq.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ namespace raft::runtime::neighbors::ivf_pq { #define RAFT_INST_SEARCH(T, IdxT) \ - void search(const handle_t&, \ + void search(raft::device_resources const&, \ const raft::neighbors::ivf_pq::search_params&, \ const raft::neighbors::ivf_pq::index&, \ const T*, \ @@ -41,28 +41,28 @@ RAFT_INST_SEARCH(uint8_t, uint64_t); // wrappers, where exception handling is not compatible with return type that has nontrivial // constructor. #define RAFT_INST_BUILD_EXTEND(T, IdxT) \ - auto build(const handle_t& handle, \ + auto build(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index_params& params, \ const T* dataset, \ IdxT n_rows, \ uint32_t dim) \ ->raft::neighbors::ivf_pq::index; \ \ - auto extend(const handle_t& handle, \ + auto extend(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index& orig_index, \ const T* new_vectors, \ const IdxT* new_indices, \ IdxT n_rows) \ ->raft::neighbors::ivf_pq::index; \ \ - void build(const handle_t& handle, \ + void build(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index_params& params, \ const T* dataset, \ IdxT n_rows, \ uint32_t dim, \ raft::neighbors::ivf_pq::index* idx); \ \ - void extend(const handle_t& handle, \ + void extend(raft::device_resources const& handle, \ raft::neighbors::ivf_pq::index* idx, \ const T* new_vectors, \ const IdxT* new_indices, \ @@ -84,7 +84,7 @@ RAFT_INST_BUILD_EXTEND(uint8_t, uint64_t) * @param[in] index IVF-PQ index * */ -void save(const handle_t& handle, +void save(raft::device_resources const& handle, const std::string& filename, const raft::neighbors::ivf_pq::index& index); @@ -98,7 +98,7 @@ void save(const handle_t& handle, * @param[in] index IVF-PQ index * */ -void load(const handle_t& handle, +void load(raft::device_resources const& handle, const std::string& filename, raft::neighbors::ivf_pq::index* index); diff --git a/cpp/include/raft_runtime/neighbors/refine.hpp b/cpp/include/raft_runtime/neighbors/refine.hpp index 2e08ae23c0..e779d17ded 100644 --- a/cpp/include/raft_runtime/neighbors/refine.hpp +++ b/cpp/include/raft_runtime/neighbors/refine.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,13 @@ #pragma once #include -#include +#include //#include namespace raft::runtime::neighbors { #define RAFT_INST_REFINE(IDX_T, DATA_T) \ - void refine(raft::handle_t const& handle, \ + void refine(raft::device_resources const& handle, \ raft::device_matrix_view dataset, \ raft::device_matrix_view queries, \ raft::device_matrix_view neighbor_candidates, \ @@ -31,7 +31,7 @@ namespace raft::runtime::neighbors { raft::device_matrix_view distances, \ distance::DistanceType metric); \ \ - void refine(raft::handle_t const& handle, \ + void refine(raft::device_resources const& handle, \ raft::host_matrix_view dataset, \ raft::host_matrix_view queries, \ raft::host_matrix_view neighbor_candidates, \ diff --git a/cpp/include/raft_runtime/random/rmat_rectangular_generator.hpp b/cpp/include/raft_runtime/random/rmat_rectangular_generator.hpp index 1dc1199864..8f18fd1388 100644 --- a/cpp/include/raft_runtime/random/rmat_rectangular_generator.hpp +++ b/cpp/include/raft_runtime/random/rmat_rectangular_generator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include -#include +#include #include namespace raft::runtime::random { @@ -26,15 +26,15 @@ namespace raft::runtime::random { * @{ */ -#define FUNC_DECL(IdxT, ProbT) \ - void rmat_rectangular_gen(raft::handle_t const& handle, \ - IdxT* out, \ - IdxT* out_src, \ - IdxT* out_dst, \ - const ProbT* theta, \ - IdxT r_scale, \ - IdxT c_scale, \ - IdxT n_edges, \ +#define FUNC_DECL(IdxT, ProbT) \ + void rmat_rectangular_gen(raft::device_resources const& handle, \ + IdxT* out, \ + IdxT* out_src, \ + IdxT* out_dst, \ + const ProbT* theta, \ + IdxT r_scale, \ + IdxT c_scale, \ + IdxT n_edges, \ raft::random::RngState& r) FUNC_DECL(int, float); diff --git a/cpp/internal/raft_internal/matrix/select_k.cuh b/cpp/internal/raft_internal/matrix/select_k.cuh index ee79b1ff80..205149b821 100644 --- a/cpp/internal/raft_internal/matrix/select_k.cuh +++ b/cpp/internal/raft_internal/matrix/select_k.cuh @@ -18,7 +18,7 @@ #include #include -#include +#include namespace raft::matrix::select { @@ -67,7 +67,7 @@ inline auto operator<<(std::ostream& os, const Algo& algo) -> std::ostream& } template -void select_k_impl(const handle_t& handle, +void select_k_impl(const device_resources& handle, const Algo& algo, const T* in, const IdxT* in_idx, diff --git a/cpp/internal/raft_internal/neighbors/refine_helper.cuh b/cpp/internal/raft_internal/neighbors/refine_helper.cuh index 1d8c5600bd..5e26222827 100644 --- a/cpp/internal/raft_internal/neighbors/refine_helper.cuh +++ b/cpp/internal/raft_internal/neighbors/refine_helper.cuh @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -45,7 +45,7 @@ struct RefineInputs { template class RefineHelper { public: - RefineHelper(const raft::handle_t& handle, RefineInputs params) + RefineHelper(const raft::device_resources& handle, RefineInputs params) : handle_(handle), stream_(handle.get_stream()), p(params) { raft::random::Rng r(1234ULL); @@ -120,7 +120,7 @@ class RefineHelper { public: RefineInputs p; - const raft::handle_t& handle_; + const raft::device_resources& handle_; rmm::cuda_stream_view stream_; raft::device_matrix dataset; diff --git a/cpp/src/distance/cluster/cluster_cost.cuh b/cpp/src/distance/cluster/cluster_cost.cuh index 4f208ab1cd..be7fa521aa 100644 --- a/cpp/src/distance/cluster/cluster_cost.cuh +++ b/cpp/src/distance/cluster/cluster_cost.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,15 @@ */ #include +#include #include #include #include -#include #include namespace raft::runtime::cluster::kmeans { template -void cluster_cost(const raft::handle_t& handle, +void cluster_cost(raft::device_resources const& handle, const ElementType* X, IndexType n_samples, IndexType n_features, diff --git a/cpp/src/distance/cluster/cluster_cost_double.cu b/cpp/src/distance/cluster/cluster_cost_double.cu index 8fffa4eee0..6feb3076dd 100644 --- a/cpp/src/distance/cluster/cluster_cost_double.cu +++ b/cpp/src/distance/cluster/cluster_cost_double.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ #include "cluster_cost.cuh" +#include #include #include -#include namespace raft::runtime::cluster::kmeans { -void cluster_cost(const raft::handle_t& handle, +void cluster_cost(raft::device_resources const& handle, const double* X, int n_samples, int n_features, diff --git a/cpp/src/distance/cluster/cluster_cost_float.cu b/cpp/src/distance/cluster/cluster_cost_float.cu index 7f2cd9a485..24af5efb25 100644 --- a/cpp/src/distance/cluster/cluster_cost_float.cu +++ b/cpp/src/distance/cluster/cluster_cost_float.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ #include "cluster_cost.cuh" +#include #include #include -#include namespace raft::runtime::cluster::kmeans { -void cluster_cost(const raft::handle_t& handle, +void cluster_cost(raft::device_resources const& handle, const float* X, int n_samples, int n_features, diff --git a/cpp/src/distance/cluster/kmeans_fit_double.cu b/cpp/src/distance/cluster/kmeans_fit_double.cu index 2989941d85..cbc9fa45cb 100644 --- a/cpp/src/distance/cluster/kmeans_fit_double.cu +++ b/cpp/src/distance/cluster/kmeans_fit_double.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,12 @@ */ #include +#include #include -#include namespace raft::runtime::cluster::kmeans { -void fit(handle_t const& handle, +void fit(raft::device_resources const& handle, const raft::cluster::kmeans::KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, diff --git a/cpp/src/distance/cluster/kmeans_fit_float.cu b/cpp/src/distance/cluster/kmeans_fit_float.cu index 0e10ab30a4..6dcbd73b8d 100644 --- a/cpp/src/distance/cluster/kmeans_fit_float.cu +++ b/cpp/src/distance/cluster/kmeans_fit_float.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,12 @@ */ #include +#include #include -#include namespace raft::runtime::cluster::kmeans { -void fit(handle_t const& handle, +void fit(raft::device_resources const& handle, const raft::cluster::kmeans::KMeansParams& params, raft::device_matrix_view X, std::optional> sample_weight, diff --git a/cpp/src/distance/cluster/update_centroids.cuh b/cpp/src/distance/cluster/update_centroids.cuh index 035f597523..e0d3bd8487 100644 --- a/cpp/src/distance/cluster/update_centroids.cuh +++ b/cpp/src/distance/cluster/update_centroids.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,15 @@ */ #include +#include #include #include -#include #include namespace raft::runtime::cluster::kmeans { template -void update_centroids(raft::handle_t const& handle, +void update_centroids(raft::device_resources const& handle, const DataT* X, int n_samples, int n_features, diff --git a/cpp/src/distance/cluster/update_centroids_double.cu b/cpp/src/distance/cluster/update_centroids_double.cu index 85c4953150..cb63de2ca5 100644 --- a/cpp/src/distance/cluster/update_centroids_double.cu +++ b/cpp/src/distance/cluster/update_centroids_double.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ #include "update_centroids.cuh" +#include #include #include -#include namespace raft::runtime::cluster::kmeans { -void update_centroids(raft::handle_t const& handle, +void update_centroids(raft::device_resources const& handle, const double* X, int n_samples, int n_features, diff --git a/cpp/src/distance/cluster/update_centroids_float.cu b/cpp/src/distance/cluster/update_centroids_float.cu index aaad2bc3e4..7ce74b584c 100644 --- a/cpp/src/distance/cluster/update_centroids_float.cu +++ b/cpp/src/distance/cluster/update_centroids_float.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ #include "update_centroids.cuh" +#include #include #include -#include namespace raft::runtime::cluster::kmeans { -void update_centroids(raft::handle_t const& handle, +void update_centroids(raft::device_resources const& handle, const float* X, int n_samples, int n_features, diff --git a/cpp/src/distance/distance/fused_l2_min_arg.cu b/cpp/src/distance/distance/fused_l2_min_arg.cu index f74b7c0e86..b682446cc2 100644 --- a/cpp/src/distance/distance/fused_l2_min_arg.cu +++ b/cpp/src/distance/distance/fused_l2_min_arg.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ struct KeyValueIndexOp { }; template -void compute_fused_l2_nn_min_arg(raft::handle_t const& handle, +void compute_fused_l2_nn_min_arg(raft::device_resources const& handle, idx_t* min, const value_t* x, const value_t* y, @@ -71,7 +71,7 @@ void compute_fused_l2_nn_min_arg(raft::handle_t const& handle, handle.sync_stream(); } -void fused_l2_nn_min_arg(raft::handle_t const& handle, +void fused_l2_nn_min_arg(raft::device_resources const& handle, int* min, const float* x, const float* y, @@ -83,7 +83,7 @@ void fused_l2_nn_min_arg(raft::handle_t const& handle, compute_fused_l2_nn_min_arg(handle, min, x, y, m, n, k, sqrt); } -void fused_l2_nn_min_arg(raft::handle_t const& handle, +void fused_l2_nn_min_arg(raft::device_resources const& handle, int* min, const double* x, const double* y, diff --git a/cpp/src/distance/distance/pairwise_distance.cu b/cpp/src/distance/distance/pairwise_distance.cu index cbdd5cd8f2..dfdfa553e9 100644 --- a/cpp/src/distance/distance/pairwise_distance.cu +++ b/cpp/src/distance/distance/pairwise_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ * limitations under the License. */ +#include #include #include #include -#include namespace raft::runtime::distance { -void pairwise_distance(raft::handle_t const& handle, +void pairwise_distance(raft::device_resources const& handle, float* x, float* y, float* dists, @@ -36,7 +36,7 @@ void pairwise_distance(raft::handle_t const& handle, handle, x, y, dists, m, n, k, metric, isRowMajor, metric_arg); } -void pairwise_distance(raft::handle_t const& handle, +void pairwise_distance(raft::device_resources const& handle, double* x, double* y, double* dists, diff --git a/cpp/src/distance/neighbors/ivfpq_build.cu b/cpp/src/distance/neighbors/ivfpq_build.cu index bbcd0533f8..650767f918 100644 --- a/cpp/src/distance/neighbors/ivfpq_build.cu +++ b/cpp/src/distance/neighbors/ivfpq_build.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ namespace raft::runtime::neighbors::ivf_pq { #define RAFT_INST_BUILD_EXTEND(T, IdxT) \ - auto build(const handle_t& handle, \ + auto build(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index_params& params, \ const T* dataset, \ IdxT n_rows, \ @@ -29,7 +29,7 @@ namespace raft::runtime::neighbors::ivf_pq { { \ return raft::neighbors::ivf_pq::build(handle, params, dataset, n_rows, dim); \ } \ - auto extend(const handle_t& handle, \ + auto extend(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index& orig_index, \ const T* new_vectors, \ const IdxT* new_indices, \ @@ -40,7 +40,7 @@ namespace raft::runtime::neighbors::ivf_pq { handle, orig_index, new_vectors, new_indices, n_rows); \ } \ \ - void build(const handle_t& handle, \ + void build(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::index_params& params, \ const T* dataset, \ IdxT n_rows, \ @@ -49,7 +49,7 @@ namespace raft::runtime::neighbors::ivf_pq { { \ *idx = raft::neighbors::ivf_pq::build(handle, params, dataset, n_rows, dim); \ } \ - void extend(const handle_t& handle, \ + void extend(raft::device_resources const& handle, \ raft::neighbors::ivf_pq::index* idx, \ const T* new_vectors, \ const IdxT* new_indices, \ @@ -64,14 +64,14 @@ RAFT_INST_BUILD_EXTEND(uint8_t, uint64_t); #undef RAFT_INST_BUILD_EXTEND -void save(const handle_t& handle, +void save(raft::device_resources const& handle, const std::string& filename, const raft::neighbors::ivf_pq::index& index) { raft::spatial::knn::ivf_pq::detail::save(handle, filename, index); }; -void load(const handle_t& handle, +void load(raft::device_resources const& handle, const std::string& filename, raft::neighbors::ivf_pq::index* index) { diff --git a/cpp/src/distance/neighbors/ivfpq_search.cu b/cpp/src/distance/neighbors/ivfpq_search.cu index 3bd1f6ed68..05ab890ea5 100644 --- a/cpp/src/distance/neighbors/ivfpq_search.cu +++ b/cpp/src/distance/neighbors/ivfpq_search.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ namespace raft::runtime::neighbors::ivf_pq { #define RAFT_SEARCH_INST(T, IdxT) \ - void search(const handle_t& handle, \ + void search(raft::device_resources const& handle, \ const raft::neighbors::ivf_pq::search_params& params, \ const raft::neighbors::ivf_pq::index& idx, \ const T* queries, \ diff --git a/cpp/src/distance/neighbors/refine.cu b/cpp/src/distance/neighbors/refine.cu index 82e7ebe5ff..83e3383cba 100644 --- a/cpp/src/distance/neighbors/refine.cu +++ b/cpp/src/distance/neighbors/refine.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ namespace raft::runtime::neighbors { #define RAFT_INST_REFINE(IDX_T, DATA_T) \ - void refine(raft::handle_t const& handle, \ + void refine(raft::device_resources const& handle, \ raft::device_matrix_view dataset, \ raft::device_matrix_view queries, \ raft::device_matrix_view neighbor_candidates, \ @@ -31,7 +31,7 @@ namespace raft::runtime::neighbors { handle, dataset, queries, neighbor_candidates, indices, distances, metric); \ } \ \ - void refine(raft::handle_t const& handle, \ + void refine(raft::device_resources const& handle, \ raft::host_matrix_view dataset, \ raft::host_matrix_view queries, \ raft::host_matrix_view neighbor_candidates, \ diff --git a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_int64_t.cu b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_int64_t.cu index a32147b2b1..34825b253b 100644 --- a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_int64_t.cu +++ b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_int64_t.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ namespace raft::spatial::knn::ivf_pq::detail { -template void search(const handle_t&, +template void search(const raft::device_resources&, const search_params&, const index&, const float*, diff --git a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint32_t.cu b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint32_t.cu index f3e80206e4..ec746dc434 100644 --- a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint32_t.cu +++ b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint32_t.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ namespace raft::spatial::knn::ivf_pq::detail { -template void search(const handle_t&, +template void search(const raft::device_resources&, const search_params&, const index&, const float*, diff --git a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint64_t.cu b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint64_t.cu index e732646f99..ea18fac24d 100644 --- a/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint64_t.cu +++ b/cpp/src/distance/neighbors/specializations/detail/ivfpq_search_float_uint64_t.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ namespace raft::spatial::knn::ivf_pq::detail { -template void search(const handle_t&, +template void search(const raft::device_resources&, const search_params&, const index&, const float*, diff --git a/cpp/src/distance/random/common.cuh b/cpp/src/distance/random/common.cuh index 3bd57fc80d..69b507b07b 100644 --- a/cpp/src/distance/random/common.cuh +++ b/cpp/src/distance/random/common.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include #define FUNC_DEF(IdxT, ProbT) \ - void rmat_rectangular_gen(raft::handle_t const& handle, \ + void rmat_rectangular_gen(raft::device_resources const& handle, \ IdxT* out, \ IdxT* out_src, \ IdxT* out_dst, \ diff --git a/cpp/src/nn/specializations/ball_cover.cu b/cpp/src/nn/specializations/ball_cover.cu index b608a1a865..f37fda31af 100644 --- a/cpp/src/nn/specializations/ball_cover.cu +++ b/cpp/src/nn/specializations/ball_cover.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,11 @@ template class BallCoverIndex; template class BallCoverIndex; template void build_index( - const raft::handle_t& handle, + raft::device_resources const& handle, BallCoverIndex& index); template void knn_query( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, std::uint32_t k, const float* query, @@ -48,7 +48,7 @@ template void knn_query( float weight); template void all_knn_query( - const raft::handle_t& handle, + raft::device_resources const& handle, BallCoverIndex& index, std::uint32_t k, std::int64_t* inds, diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu index 961af0b89c..cff83ad3cf 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu +++ b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace knn { namespace detail { template void rbc_low_dim_pass_one( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu index daa509b5b1..a12d6548ed 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu +++ b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace knn { namespace detail { template void rbc_low_dim_pass_one( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, @@ -38,7 +38,7 @@ template void rbc_low_dim_pass_one( std::uint32_t* dists_counter); template void rbc_low_dim_pass_two( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu index 9487641945..7e784cb4d8 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu +++ b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace knn { namespace detail { template void rbc_low_dim_pass_two( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu index c07ed45427..e650c7ed37 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu +++ b/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace knn { namespace detail { template void rbc_low_dim_pass_two( - const raft::handle_t& handle, + raft::device_resources const& handle, const BallCoverIndex& index, const float* query, const std::uint32_t n_query_rows, diff --git a/cpp/src/nn/specializations/knn.cu b/cpp/src/nn/specializations/knn.cu index 4e0a821c24..d135610bfb 100644 --- a/cpp/src/nn/specializations/knn.cu +++ b/cpp/src/nn/specializations/knn.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ namespace raft { namespace spatial { namespace knn { -template void brute_force_knn(raft::handle_t const& handle, +template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, int D, @@ -36,7 +36,7 @@ template void brute_force_knn(raft::handle_t const& handle, distance::DistanceType metric, float metric_arg); -template void brute_force_knn(raft::handle_t const& handle, +template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, unsigned int D, @@ -51,7 +51,7 @@ template void brute_force_knn(raft::handle_t const& h distance::DistanceType metric, float metric_arg); -template void brute_force_knn(raft::handle_t const& handle, +template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, int D, @@ -66,7 +66,7 @@ template void brute_force_knn(raft::handle_t const& handle distance::DistanceType metric, float metric_arg); -template void brute_force_knn(raft::handle_t const& handle, +template void brute_force_knn(raft::device_resources const& handle, std::vector& input, std::vector& sizes, unsigned int D, diff --git a/cpp/test/cluster/cluster_solvers.cu b/cpp/test/cluster/cluster_solvers.cu index 9293c78294..5121cdf139 100644 --- a/cpp/test/cluster/cluster_solvers.cu +++ b/cpp/test/cluster/cluster_solvers.cu @@ -17,7 +17,7 @@ #include #include #include -#include +#include #if defined RAFT_DISTANCE_COMPILED && defined RAFT_NN_COMPILED #include @@ -35,7 +35,7 @@ TEST(Raft, ClusterSolvers) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; index_type maxiter{100}; value_type tol{1.0e-10}; @@ -65,7 +65,7 @@ TEST(Raft, ModularitySolvers) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; ASSERT_EQ(0, h.get_device()); index_type neigvs{10}; diff --git a/cpp/test/cluster/cluster_solvers_deprecated.cu b/cpp/test/cluster/cluster_solvers_deprecated.cu index dbc7722485..dbafbd15d6 100644 --- a/cpp/test/cluster/cluster_solvers_deprecated.cu +++ b/cpp/test/cluster/cluster_solvers_deprecated.cu @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include @@ -30,7 +30,7 @@ TEST(Raft, ClusterSolvers) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; index_type maxiter{100}; value_type tol{1.0e-10}; diff --git a/cpp/test/cluster/kmeans.cu b/cpp/test/cluster/kmeans.cu index abc4cd6e13..87d7665c92 100644 --- a/cpp/test/cluster/kmeans.cu +++ b/cpp/test/cluster/kmeans.cu @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -45,7 +45,7 @@ struct KmeansInputs { }; template -void run_cluster_cost(const raft::handle_t& handle, +void run_cluster_cost(const raft::device_resources& handle, raft::device_vector_view minClusterDistance, rmm::device_uvector& workspace, raft::device_scalar_view clusterCost) @@ -323,7 +323,7 @@ class KmeansTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; KmeansInputs testparams; rmm::device_uvector d_labels; rmm::device_uvector d_labels_ref; diff --git a/cpp/test/cluster/linkage.cu b/cpp/test/cluster/linkage.cu index a36ad4abea..20f2952e7d 100644 --- a/cpp/test/cluster/linkage.cu +++ b/cpp/test/cluster/linkage.cu @@ -49,6 +49,8 @@ struct LinkageInputs { int n_clusters; + bool use_knn; + int c; }; @@ -187,15 +189,28 @@ class LinkageTest : public ::testing::TestWithParam> { raft::make_device_matrix_view(out_children.data(), params.n_row, 2); auto labels_view = raft::make_device_vector_view(labels.data(), params.n_row); - raft::cluster::hierarchy:: - single_linkage( - handle, - data_view, - dendrogram_view, - labels_view, - raft::distance::DistanceType::L2SqrtExpanded, - params.n_clusters, - std::make_optional(params.c)); + if (params.use_knn) { + raft::cluster::hierarchy:: + single_linkage( + handle, + data_view, + dendrogram_view, + labels_view, + raft::distance::DistanceType::L2SqrtExpanded, + params.n_clusters, + std::make_optional(params.c)); + + } else { + raft::cluster::hierarchy:: + single_linkage( + handle, + data_view, + dendrogram_view, + labels_view, + raft::distance::DistanceType::L2SqrtExpanded, + params.n_clusters, + std::make_optional(params.c)); + } handle.sync_stream(stream); @@ -205,7 +220,7 @@ class LinkageTest : public ::testing::TestWithParam> { void SetUp() override { basicTest(); } protected: - raft::handle_t handle; + raft::device_resources handle; LinkageInputs params; rmm::device_uvector labels, labels_ref; @@ -225,6 +240,7 @@ const std::vector> linkage_inputsf2 = { 0.76166195, 0.66613745}, {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, 10, + true, -1}, // // Test outlier points {9, @@ -232,6 +248,7 @@ const std::vector> linkage_inputsf2 = { {-1, -50, 3, 4, 5000, 10000, 1, 3, 4, 5, 0.000005, 0.00002, 2000000, 500000, 10, 50, 30, 5}, {6, 0, 5, 0, 0, 4, 3, 2, 1}, 7, + true, -1}, // Test n_clusters == (n_points / 2) @@ -246,6 +263,7 @@ const std::vector> linkage_inputsf2 = { 0.76166195, 0.66613745}, {1, 0, 4, 0, 0, 3, 2, 0, 2, 1}, 5, + true, -1}, // Test n_points == 100 @@ -425,7 +443,224 @@ const std::vector> linkage_inputsf2 = { 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 10, - -4}}; + true, + -4}, + {10, + 5, + {0.21390334, 0.50261639, 0.91036676, 0.59166485, 0.71162682, 0.10248392, 0.77782677, 0.43772379, + 0.4035871, 0.3282796, 0.47544681, 0.59862974, 0.12319357, 0.06239463, 0.28200272, 0.1345717, + 0.50498218, 0.5113505, 0.16233086, 0.62165332, 0.42281548, 0.933117, 0.41386077, 0.23264562, + 0.73325968, 0.37537541, 0.70719873, 0.14522645, 0.73279625, 0.9126674, 0.84854131, 0.28890216, + 0.85267903, 0.74703138, 0.83842071, 0.34942792, 0.27864171, 0.70911132, 0.21338564, 0.32035554, + 0.73788331, 0.46926692, 0.57570162, 0.42559178, 0.87120209, 0.22734951, 0.01847905, 0.75549396, + 0.76166195, 0.66613745}, + {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, + 10, + false, + 5}, + // Test outlier points + {9, + 2, + {-1, -50, 3, 4, 5000, 10000, 1, 3, 4, 5, 0.000005, 0.00002, 2000000, 500000, 10, 50, 30, 5}, + {6, 0, 5, 0, 0, 4, 3, 2, 1}, + 7, + false, + 5}, + + // Test n_clusters == (n_points / 2) + {10, + 5, + {0.21390334, 0.50261639, 0.91036676, 0.59166485, 0.71162682, 0.10248392, 0.77782677, 0.43772379, + 0.4035871, 0.3282796, 0.47544681, 0.59862974, 0.12319357, 0.06239463, 0.28200272, 0.1345717, + 0.50498218, 0.5113505, 0.16233086, 0.62165332, 0.42281548, 0.933117, 0.41386077, 0.23264562, + 0.73325968, 0.37537541, 0.70719873, 0.14522645, 0.73279625, 0.9126674, 0.84854131, 0.28890216, + 0.85267903, 0.74703138, 0.83842071, 0.34942792, 0.27864171, 0.70911132, 0.21338564, 0.32035554, + 0.73788331, 0.46926692, 0.57570162, 0.42559178, 0.87120209, 0.22734951, 0.01847905, 0.75549396, + 0.76166195, 0.66613745}, + {1, 0, 4, 0, 0, 3, 2, 0, 2, 1}, + 5, + false, + 10}, + + // Test n_points == 100 + {100, + 10, + {6.26168372e-01, 9.30437651e-01, 6.02450208e-01, 2.73025296e-01, 9.53050619e-01, 3.32164396e-01, + 6.88942598e-01, 5.79163537e-01, 6.70341547e-01, 2.70140602e-02, 9.30429671e-01, 7.17721157e-01, + 9.89948537e-01, 7.75253347e-01, 1.34491522e-02, 2.48522428e-02, 3.51413378e-01, 7.64405834e-01, + 7.86373507e-01, 7.18748577e-01, 8.66998621e-01, 6.80316582e-01, 2.51288712e-01, 4.91078420e-01, + 3.76246281e-01, 4.86828710e-01, 5.67464772e-01, 5.30734742e-01, 8.99478296e-01, 7.66699088e-01, + 9.49339111e-01, 3.55248484e-01, 9.06046929e-01, 4.48407772e-01, 6.96395305e-01, 2.44277335e-01, + 7.74840000e-01, 5.21046603e-01, 4.66423971e-02, 5.12019638e-02, 8.95019614e-01, 5.28956953e-01, + 4.31536306e-01, 5.83857744e-01, 4.41787364e-01, 4.68656523e-01, 5.73971433e-01, 6.79989654e-01, + 3.19650588e-01, 6.12579596e-01, 6.49126442e-02, 8.39131142e-01, 2.85252117e-01, 5.84848929e-01, + 9.46507115e-01, 8.58440748e-01, 3.61528940e-01, 2.44215959e-01, 3.80101125e-01, 4.57128957e-02, + 8.82216988e-01, 8.31498633e-01, 7.23474381e-01, 7.75788607e-01, 1.40864146e-01, 6.62092382e-01, + 5.13985168e-01, 3.00686418e-01, 8.70109949e-01, 2.43187753e-01, 2.89391938e-01, 2.84214238e-01, + 8.70985521e-01, 8.77491176e-01, 6.72537226e-01, 3.30929686e-01, 1.85934324e-01, 9.16222614e-01, + 6.18239142e-01, 2.64768597e-01, 5.76145451e-01, 8.62961369e-01, 6.84757925e-01, 7.60549082e-01, + 1.27645356e-01, 4.51004673e-01, 3.92292980e-01, 4.63170803e-01, 4.35449330e-02, 2.17583404e-01, + 5.71832605e-02, 2.06763039e-01, 3.70116249e-01, 2.09750028e-01, 6.17283019e-01, 8.62549231e-01, + 9.84156240e-02, 2.66249156e-01, 3.87635103e-01, 2.85591012e-02, 4.24826068e-01, 4.45795088e-01, + 6.86227676e-01, 1.08848960e-01, 5.96731841e-02, 3.71770228e-01, 1.91548833e-01, 6.95136078e-01, + 9.00700636e-01, 8.76363105e-01, 2.67334632e-01, 1.80619709e-01, 7.94060419e-01, 1.42854171e-02, + 1.09372387e-01, 8.74028108e-01, 6.46403232e-01, 4.86588834e-01, 5.93446175e-02, 6.11886291e-01, + 8.83865057e-01, 3.15879821e-01, 2.27043992e-01, 9.76764951e-01, 6.15620336e-01, 9.76199360e-01, + 2.40548962e-01, 3.21795663e-01, 8.75087904e-02, 8.11234663e-01, 6.96070480e-01, 8.12062321e-01, + 1.21958818e-01, 3.44348628e-02, 8.72630414e-01, 3.06162776e-01, 1.76043529e-02, 9.45894971e-01, + 5.33896401e-01, 6.21642973e-01, 4.93062535e-01, 4.48984262e-01, 2.24560379e-01, 4.24052195e-02, + 4.43447610e-01, 8.95646149e-01, 6.05220676e-01, 1.81840491e-01, 9.70831206e-01, 2.12563586e-02, + 6.92582693e-01, 7.55946922e-01, 7.95086143e-01, 6.05328941e-01, 3.99350764e-01, 4.32846636e-01, + 9.81114529e-01, 4.98266428e-01, 6.37127930e-03, 1.59085889e-01, 6.34682067e-05, 5.59429440e-01, + 7.38827633e-01, 8.93214770e-01, 2.16494306e-01, 9.35430573e-02, 4.75665868e-02, 7.80503518e-01, + 7.86240041e-01, 7.06854594e-01, 2.13725879e-02, 7.68246091e-01, 4.50234808e-01, 5.21231104e-01, + 5.01989826e-03, 4.22081572e-02, 1.65337732e-01, 8.54134740e-01, 4.99430262e-01, 8.94525601e-01, + 1.14028379e-01, 3.69739861e-01, 1.32955599e-01, 2.65563824e-01, 2.52811151e-01, 1.44792843e-01, + 6.88449594e-01, 4.44921417e-01, 8.23296587e-01, 1.93266317e-01, 1.19033309e-01, 1.36368966e-01, + 3.42600285e-01, 5.64505195e-01, 5.57594559e-01, 7.44257892e-01, 8.38231569e-02, 4.11548847e-01, + 3.21010077e-01, 8.55081359e-01, 4.30105779e-01, 1.16229135e-01, 9.87731964e-02, 3.14712335e-01, + 4.50880592e-01, 2.72289598e-01, 6.31615256e-01, 8.97432958e-01, 4.44764250e-01, 8.03776440e-01, + 2.68767748e-02, 2.43374608e-01, 4.02141103e-01, 4.98881209e-01, 5.33173003e-01, 8.82890436e-01, + 7.16149148e-01, 4.19664401e-01, 2.29335357e-01, 2.88637806e-01, 3.44696803e-01, 6.78171906e-01, + 5.69849716e-01, 5.86454477e-01, 3.54474989e-01, 9.03876540e-01, 6.45980000e-01, 6.34887593e-01, + 7.88039746e-02, 2.04814126e-01, 7.82251754e-01, 2.43147074e-01, 7.50951808e-01, 1.72799092e-02, + 2.95349590e-01, 6.57991826e-01, 8.81214312e-01, 5.73970708e-01, 2.77610881e-01, 1.82155097e-01, + 7.69797417e-02, 6.44792402e-01, 9.46950998e-01, 7.73064845e-01, 6.04733624e-01, 5.80094567e-01, + 1.67498426e-01, 2.66514296e-01, 6.50140368e-01, 1.91170299e-01, 2.08752199e-01, 3.01664091e-01, + 9.85033484e-01, 2.92909152e-01, 8.65816607e-01, 1.85222119e-01, 2.28814559e-01, 1.34286382e-02, + 2.89234322e-01, 8.18668708e-01, 4.71706924e-01, 9.23199803e-01, 2.80879188e-01, 1.47319284e-01, + 4.13915748e-01, 9.31274932e-02, 6.66322195e-01, 9.66953974e-01, 3.19405786e-01, 6.69486551e-01, + 5.03096313e-02, 6.95225201e-01, 5.78469859e-01, 6.29481655e-01, 1.39252534e-01, 1.22564968e-01, + 6.80663678e-01, 6.34607157e-01, 6.42765834e-01, 1.57127410e-02, 2.92132086e-01, 5.24423878e-01, + 4.68676824e-01, 2.86003928e-01, 7.18608322e-01, 8.95617933e-01, 5.48844309e-01, 1.74517278e-01, + 5.24379196e-01, 2.13526524e-01, 5.88375435e-01, 9.88560185e-01, 4.17435771e-01, 6.14438688e-01, + 9.53760881e-01, 5.27151288e-01, 7.03017278e-01, 3.44448559e-01, 4.47059676e-01, 2.83414901e-01, + 1.98979011e-01, 4.24917361e-01, 5.73172761e-01, 2.32398853e-02, 1.65887230e-01, 4.05552785e-01, + 9.29665524e-01, 2.26135696e-01, 9.20563384e-01, 7.65259963e-01, 4.54820075e-01, 8.97710267e-01, + 3.78559302e-03, 9.15219382e-01, 3.55705698e-01, 6.94905124e-01, 8.58540202e-01, 3.89790666e-01, + 2.49478206e-01, 7.93679304e-01, 4.75830027e-01, 4.40425353e-01, 3.70579459e-01, 1.40578049e-01, + 1.70386675e-01, 7.04056121e-01, 4.85963102e-01, 9.68450060e-01, 6.77178001e-01, 2.65934654e-01, + 2.58915007e-01, 6.70052890e-01, 2.61945109e-01, 8.46207759e-01, 1.01928951e-01, 2.85611334e-01, + 2.45776933e-01, 2.66658783e-01, 3.71724077e-01, 4.34319025e-01, 4.24407347e-01, 7.15417683e-01, + 8.07997684e-01, 1.64296275e-01, 6.01638065e-01, 8.60606804e-02, 2.68719187e-01, 5.11764101e-01, + 9.75844338e-01, 7.81226782e-01, 2.20925515e-01, 7.18135040e-01, 9.82395577e-01, 8.39160243e-01, + 9.08058083e-01, 6.88010677e-01, 8.14271847e-01, 5.12460821e-01, 1.17311345e-01, 5.96075228e-01, + 9.17455497e-01, 2.12052706e-01, 7.04074603e-01, 8.72872565e-02, 8.76047818e-01, 6.96235046e-01, + 8.54801557e-01, 2.49729159e-01, 9.76594604e-01, 2.87386363e-01, 2.36461559e-02, 9.94075254e-01, + 4.25193986e-01, 7.61869994e-01, 5.13334255e-01, 6.44711165e-02, 8.92156689e-01, 3.55235167e-01, + 1.08154647e-01, 8.78446825e-01, 2.43833016e-01, 9.23071293e-01, 2.72724115e-01, 9.46631338e-01, + 3.74510294e-01, 4.08451278e-02, 9.78392777e-01, 3.65079221e-01, 6.37199516e-01, 5.51144906e-01, + 5.25978080e-01, 1.42803678e-01, 4.05451674e-01, 7.79788219e-01, 6.26009784e-01, 3.35249497e-01, + 1.43159543e-02, 1.80363779e-01, 5.05096904e-01, 2.82619947e-01, 5.83561392e-01, 3.10951324e-01, + 8.73223968e-01, 4.38545619e-01, 4.81348800e-01, 6.68497085e-01, 3.79345401e-01, 9.58832501e-01, + 1.89869550e-01, 2.34083070e-01, 2.94066207e-01, 5.74892667e-02, 6.92106828e-02, 9.61127686e-02, + 6.72650672e-02, 8.47345378e-01, 2.80916761e-01, 7.32177357e-03, 9.80785961e-01, 5.73192225e-02, + 8.48781331e-01, 8.83225408e-01, 7.34398275e-01, 7.70381941e-01, 6.20778343e-01, 8.96822048e-01, + 5.40732486e-01, 3.69704071e-01, 5.77305837e-01, 2.08221827e-01, 7.34275341e-01, 1.06110900e-01, + 3.49496706e-01, 8.34948910e-01, 1.56403291e-02, 6.78576376e-01, 8.96141268e-01, 5.94835119e-01, + 1.43943153e-01, 3.49618530e-01, 2.10440392e-01, 3.46585620e-01, 1.05153093e-01, 3.45446174e-01, + 2.72177079e-01, 7.07946300e-01, 4.33717726e-02, 3.31232203e-01, 3.91874320e-01, 4.76338141e-01, + 6.22777789e-01, 2.95989228e-02, 4.32855769e-01, 7.61049310e-01, 3.63279149e-01, 9.47210350e-01, + 6.43721247e-01, 6.58025802e-01, 1.05247633e-02, 5.29974442e-01, 7.30675767e-01, 4.30041079e-01, + 6.62634841e-01, 8.25936616e-01, 9.91253704e-01, 6.79399281e-01, 5.44177006e-01, 7.52876048e-01, + 3.32139049e-01, 7.98732398e-01, 7.38865223e-01, 9.16055132e-01, 6.11736493e-01, 9.63672879e-01, + 1.83778839e-01, 7.27558919e-02, 5.91602822e-01, 3.25235484e-01, 2.34741217e-01, 9.52346277e-01, + 9.18556407e-01, 9.35373324e-01, 6.89209070e-01, 2.56049054e-01, 6.17975395e-01, 7.82285691e-01, + 9.84983432e-01, 6.62322741e-01, 2.04144457e-01, 3.98446577e-01, 1.38918297e-01, 3.05919921e-01, + 3.14043787e-01, 5.91072666e-01, 7.44703771e-01, 8.92272567e-01, 9.78017873e-01, 9.01203161e-01, + 1.41526372e-01, 4.14878484e-01, 6.80683651e-01, 5.01733152e-02, 8.14635389e-01, 2.27926375e-01, + 9.03269815e-01, 8.68443745e-01, 9.86939190e-01, 7.40779486e-01, 2.61005311e-01, 3.19276232e-01, + 9.69509248e-01, 1.11908818e-01, 4.49198556e-01, 1.27056715e-01, 3.84064823e-01, 5.14591811e-01, + 2.10747488e-01, 9.53884090e-01, 8.43167950e-01, 4.51187972e-01, 3.75331782e-01, 6.23566461e-01, + 3.55290379e-01, 2.95705968e-01, 1.69622690e-01, 1.42981830e-01, 2.72180991e-01, 9.46468040e-01, + 3.70932500e-01, 9.94292830e-01, 4.62587505e-01, 7.14817405e-01, 2.45370540e-02, 3.00906377e-01, + 5.75768304e-01, 9.71448393e-01, 6.95574827e-02, 3.93693854e-01, 5.29306116e-01, 5.04694554e-01, + 6.73797120e-02, 6.76596969e-01, 5.50948898e-01, 3.24909641e-01, 7.70337719e-01, 6.51842631e-03, + 3.03264879e-01, 7.61037886e-03, 2.72289601e-01, 1.50502041e-01, 6.71103888e-02, 7.41503703e-01, + 1.92088941e-01, 2.19043977e-01, 9.09320161e-01, 2.37993569e-01, 6.18107973e-02, 8.31447852e-01, + 2.23355609e-01, 1.84789435e-01, 4.16104518e-01, 4.21573859e-01, 8.72446305e-02, 2.97294197e-01, + 4.50328256e-01, 8.72199917e-01, 2.51279916e-01, 4.86219272e-01, 7.57071329e-01, 4.85655942e-01, + 1.06187277e-01, 4.92341327e-01, 1.46017513e-01, 5.25421017e-01, 4.22637906e-01, 2.24685018e-01, + 8.72648431e-01, 5.54051490e-01, 1.80745062e-01, 2.12756336e-01, 5.20883169e-01, 7.60363654e-01, + 8.30254678e-01, 5.00003328e-01, 4.69017439e-01, 6.38105527e-01, 3.50638261e-02, 5.22217353e-02, + 9.06516882e-02, 8.52975842e-01, 1.19985883e-01, 3.74926753e-01, 6.50302066e-01, 1.98875727e-01, + 6.28362507e-02, 4.32693501e-01, 3.10500685e-01, 6.20732833e-01, 4.58503272e-01, 3.20790034e-01, + 7.91284868e-01, 7.93054570e-01, 2.93406765e-01, 8.95399023e-01, 1.06441034e-01, 7.53085241e-02, + 8.67523104e-01, 1.47963482e-01, 1.25584706e-01, 3.81545040e-02, 6.34338619e-01, 1.76368938e-02, + 5.75553531e-02, 5.31607516e-01, 2.63869588e-01, 9.41945823e-01, 9.24028838e-02, 5.21496463e-01, + 7.74866558e-01, 5.65210610e-01, 7.28015327e-02, 6.51963790e-01, 8.94727453e-01, 4.49571590e-01, + 1.29932405e-01, 8.64026259e-01, 9.92599934e-01, 7.43721560e-01, 8.87300215e-01, 1.06369925e-01, + 8.11335531e-01, 7.87734900e-01, 9.87344678e-01, 5.32502820e-01, 4.42612382e-01, 9.64041183e-01, + 1.66085871e-01, 1.12937664e-01, 5.24423470e-01, 6.54689333e-01, 4.59119726e-01, 5.22774091e-01, + 3.08722276e-02, 6.26979315e-01, 4.49754105e-01, 8.07495757e-01, 2.34199499e-01, 1.67765675e-01, + 9.22168418e-01, 3.73210378e-01, 8.04432575e-01, 5.61890354e-01, 4.47025593e-01, 6.43155678e-01, + 2.40407640e-01, 5.91631279e-01, 1.59369206e-01, 7.75799090e-01, 8.32067212e-01, 5.59791576e-02, + 6.39105224e-01, 4.85274738e-01, 2.12630838e-01, 2.81431312e-02, 7.16205363e-01, 6.83885011e-01, + 5.23869697e-01, 9.99418314e-01, 8.35331599e-01, 4.69877463e-02, 6.74712562e-01, 7.99273684e-01, + 2.77001890e-02, 5.75809742e-01, 2.78513031e-01, 8.36209905e-01, 7.25472379e-01, 4.87173943e-01, + 7.88311357e-01, 9.64676177e-01, 1.75752651e-01, 4.98112580e-01, 8.08850418e-02, 6.40981131e-01, + 4.06647450e-01, 8.46539387e-01, 2.12620694e-01, 9.11012851e-01, 8.25041445e-01, 8.90065575e-01, + 9.63626055e-01, 5.96689242e-01, 1.63372670e-01, 4.51640148e-01, 3.43026542e-01, 5.80658851e-01, + 2.82327625e-01, 4.75535418e-01, 6.27760926e-01, 8.46314115e-01, 9.61961932e-01, 3.19806094e-01, + 5.05508062e-01, 5.28102944e-01, 6.13045057e-01, 7.44714938e-01, 1.50586073e-01, 7.91878033e-01, + 4.89839179e-01, 3.10496849e-01, 8.82309038e-01, 2.86922314e-01, 4.84687559e-01, 5.20838630e-01, + 4.62955493e-01, 2.38185305e-01, 5.47259907e-02, 7.10916137e-01, 7.31887202e-01, 6.25602317e-01, + 8.77741168e-01, 4.19881322e-01, 4.81222328e-01, 1.28224501e-01, 2.46034010e-01, 3.34971854e-01, + 7.37216484e-01, 5.62134821e-02, 7.14089724e-01, 9.85549393e-01, 4.66295827e-01, 3.08722434e-03, + 4.70237690e-01, 2.66524167e-01, 7.93875484e-01, 4.54795911e-02, 8.09702944e-01, 1.47709735e-02, + 1.70082405e-01, 6.35905179e-01, 3.75379109e-01, 4.30315011e-01, 3.15788760e-01, 5.58065230e-01, + 2.24643800e-01, 2.42142981e-01, 6.57283636e-01, 3.34921891e-01, 1.26588975e-01, 7.68064155e-01, + 9.43856291e-01, 4.47518596e-01, 5.44453573e-01, 9.95764932e-01, 7.16444391e-01, 8.51019765e-01, + 1.01179183e-01, 4.45473958e-01, 4.60327322e-01, 4.96895844e-02, 4.72907738e-01, 5.58987444e-01, + 3.41027487e-01, 1.56175026e-01, 7.58283148e-01, 6.83600909e-01, 2.14623396e-01, 3.27348880e-01, + 3.92517893e-01, 6.70418431e-01, 5.16440832e-01, 8.63140348e-01, 5.73277464e-01, 3.46608058e-01, + 7.39396341e-01, 7.20852434e-01, 2.35653246e-02, 3.89935659e-01, 7.53783745e-01, 6.34563528e-01, + 8.79339335e-01, 7.41599159e-02, 5.62433904e-01, 6.15553852e-01, 4.56956324e-01, 5.20047447e-01, + 5.26845015e-02, 5.58471266e-01, 1.63632233e-01, 5.38936665e-02, 6.49593683e-01, 2.56838748e-01, + 8.99035326e-01, 7.20847756e-01, 5.68954684e-01, 7.43684755e-01, 5.70924238e-01, 3.82318724e-01, + 4.89328290e-01, 5.62208561e-01, 4.97540804e-02, 4.18011085e-01, 6.88041565e-01, 2.16234653e-01, + 7.89548214e-01, 8.46136387e-01, 8.46816189e-01, 1.73842353e-01, 6.11627842e-02, 8.44440559e-01, + 4.50646654e-01, 3.74785037e-01, 4.87196697e-01, 4.56276448e-01, 9.13284391e-01, 4.15715464e-01, + 7.13597697e-01, 1.23641270e-02, 5.10031271e-01, 4.74601930e-02, 2.55731159e-01, 3.22090006e-01, + 1.91165703e-01, 4.51170940e-01, 7.50843157e-01, 4.42420576e-01, 4.25380660e-01, 4.50667257e-01, + 6.55689206e-01, 9.68257670e-02, 1.96528793e-01, 8.97343028e-01, 4.99940904e-01, 6.65504083e-01, + 9.41828079e-01, 4.54397338e-01, 5.61893331e-01, 5.09839880e-01, 4.53117514e-01, 8.96804127e-02, + 1.74888861e-01, 6.65641378e-01, 2.81668336e-01, 1.89532742e-01, 5.61668382e-01, 8.68330157e-02, + 8.25092797e-01, 5.18106324e-01, 1.71904024e-01, 3.68385523e-01, 1.62005436e-01, 7.48507399e-01, + 9.30274827e-01, 2.38198517e-01, 9.52222901e-01, 5.23587800e-01, 6.94384557e-01, 1.09338652e-01, + 4.83356794e-01, 2.73050402e-01, 3.68027050e-01, 5.92366466e-01, 1.83192289e-01, 8.60376029e-01, + 7.13926203e-01, 8.16750052e-01, 1.57890291e-01, 6.25691951e-01, 5.24831646e-01, 1.73873797e-01, + 1.02429784e-01, 9.17488471e-01, 4.03584434e-01, 9.31170884e-01, 2.79386137e-01, 8.77745206e-01, + 2.45200576e-01, 1.28896951e-01, 3.15713052e-01, 5.27874291e-01, 2.16444335e-01, 7.03883817e-01, + 7.74738919e-02, 8.42422142e-01, 3.75598924e-01, 3.51002411e-01, 6.22752776e-01, 4.82407943e-01, + 7.43107867e-01, 9.46182666e-01, 9.44344819e-01, 3.28124763e-01, 1.06147431e-01, 1.65102684e-01, + 3.84060507e-01, 2.91057722e-01, 7.68173662e-02, 1.03543651e-01, 6.76698940e-01, 1.43141994e-01, + 7.21342202e-01, 6.69471294e-03, 9.07298311e-01, 5.57080171e-01, 8.10954489e-01, 4.11120526e-01, + 2.06407453e-01, 2.59590556e-01, 7.58512718e-01, 5.79873897e-01, 2.92875650e-01, 2.83686529e-01, + 2.42829343e-01, 9.19323719e-01, 3.46832864e-01, 3.58238858e-01, 7.42827585e-01, 2.05760059e-01, + 9.58438860e-01, 5.66326411e-01, 6.60292846e-01, 5.61095078e-02, 6.79465531e-01, 7.05118513e-01, + 4.44713264e-01, 2.09732933e-01, 5.22732436e-01, 1.74396512e-01, 5.29356748e-01, 4.38475687e-01, + 4.94036404e-01, 4.09785794e-01, 6.40025507e-01, 5.79371821e-01, 1.57726118e-01, 6.04572263e-01, + 5.41072639e-01, 5.18847173e-01, 1.97093284e-01, 8.91767002e-01, 4.29050835e-01, 8.25490570e-01, + 3.87699807e-01, 4.50705808e-01, 2.49371643e-01, 3.36074898e-01, 9.29925118e-01, 6.65393649e-01, + 9.07275994e-01, 3.73075859e-01, 4.14044139e-03, 2.37463702e-01, 2.25893784e-01, 2.46900245e-01, + 4.50350196e-01, 3.48618117e-01, 5.07193932e-01, 5.23435142e-01, 8.13611417e-01, 8.92715622e-01, + 1.02623450e-01, 3.06088345e-01, 7.80461650e-01, 2.21453645e-01, 2.01419652e-01, 2.84254457e-01, + 3.68286735e-01, 7.39358243e-01, 8.97879394e-01, 9.81599566e-01, 7.56526442e-01, 7.37645545e-01, + 4.23976657e-02, 8.25922012e-01, 2.60956996e-01, 2.90702065e-01, 8.98388344e-01, 3.03733299e-01, + 8.49071471e-01, 3.45835425e-01, 7.65458276e-01, 5.68094872e-01, 8.93770930e-01, 9.93161641e-01, + 5.63368667e-02, 4.26548945e-01, 5.46745780e-01, 5.75674571e-01, 7.94599487e-01, 7.18935553e-02, + 4.46492976e-01, 6.40240123e-01, 2.73246969e-01, 2.00465968e-01, 1.30718835e-01, 1.92492005e-01, + 1.96617189e-01, 6.61271644e-01, 8.12687657e-01, 8.66342445e-01 + + }, + {0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + 10, + false, + 5}}; typedef LinkageTest LinkageTestF_Int; TEST_P(LinkageTestF_Int, Result) { EXPECT_TRUE(score == 1.0); } diff --git a/cpp/test/core/handle.cpp b/cpp/test/core/handle.cpp index 8357c27f38..9f416d3ae8 100644 --- a/cpp/test/core/handle.cpp +++ b/cpp/test/core/handle.cpp @@ -183,7 +183,7 @@ void assert_handles_equal(raft::handle_t& handle_one, raft::handle_t& handle_two TEST(Raft, HandleDefault) { - handle_t h; + raft::handle_t h; ASSERT_EQ(0, h.get_device()); ASSERT_EQ(rmm::cuda_stream_per_thread, h.get_stream()); ASSERT_NE(nullptr, h.get_cublas_handle()); @@ -197,14 +197,14 @@ TEST(Raft, Handle) // test stream pool creation constexpr std::size_t n_streams = 4; auto stream_pool = std::make_shared(n_streams); - handle_t h(rmm::cuda_stream_default, stream_pool); + raft::handle_t h(rmm::cuda_stream_default, stream_pool); ASSERT_EQ(n_streams, h.get_stream_pool_size()); // test non default stream handle cudaStream_t stream; RAFT_CUDA_TRY(cudaStreamCreate(&stream)); rmm::cuda_stream_view stream_view(stream); - handle_t handle(stream_view); + raft::handle_t handle(stream_view); ASSERT_EQ(stream_view, handle.get_stream()); handle.sync_stream(stream); RAFT_CUDA_TRY(cudaStreamDestroy(stream)); @@ -212,7 +212,7 @@ TEST(Raft, Handle) TEST(Raft, DefaultConstructor) { - handle_t handle; + raft::handle_t handle; // Make sure waiting on the default stream pool // does not fail. @@ -232,11 +232,11 @@ TEST(Raft, GetHandleFromPool) { constexpr std::size_t n_streams = 4; auto stream_pool = std::make_shared(n_streams); - handle_t parent(rmm::cuda_stream_default, stream_pool); + raft::handle_t parent(rmm::cuda_stream_default, stream_pool); for (std::size_t i = 0; i < n_streams; i++) { auto worker_stream = parent.get_stream_from_stream_pool(i); - handle_t child(worker_stream); + raft::handle_t child(worker_stream); ASSERT_EQ(parent.get_stream_from_stream_pool(i), child.get_stream()); } @@ -245,7 +245,7 @@ TEST(Raft, GetHandleFromPool) TEST(Raft, Comms) { - handle_t handle; + raft::handle_t handle; auto comm1 = std::make_shared(std::unique_ptr(new mock_comms(2))); handle.set_comms(comm1); @@ -254,7 +254,7 @@ TEST(Raft, Comms) TEST(Raft, SubComms) { - handle_t handle; + raft::handle_t handle; auto comm1 = std::make_shared(std::unique_ptr(new mock_comms(1))); handle.set_subcomm("key1", comm1); @@ -267,7 +267,7 @@ TEST(Raft, SubComms) TEST(Raft, WorkspaceResource) { - handle_t handle; + raft::handle_t handle; ASSERT_TRUE(dynamic_cast*>( handle.get_workspace_resource()) == nullptr); @@ -275,7 +275,7 @@ TEST(Raft, WorkspaceResource) auto pool_mr = new rmm::mr::pool_memory_resource(rmm::mr::get_current_device_resource()); std::shared_ptr pool = {nullptr}; - handle_t handle2(rmm::cuda_stream_per_thread, pool, pool_mr); + raft::handle_t handle2(rmm::cuda_stream_per_thread, pool, pool_mr); ASSERT_TRUE(dynamic_cast*>( handle2.get_workspace_resource()) != nullptr); diff --git a/cpp/test/core/mdarray.cu b/cpp/test/core/mdarray.cu index 8e455bebfe..018b8a4e5a 100644 --- a/cpp/test/core/mdarray.cu +++ b/cpp/test/core/mdarray.cu @@ -340,7 +340,7 @@ void test_factory_methods() ASSERT_EQ(h_vec.extent(0), n); } { - raft::handle_t handle{}; + raft::device_resources handle{}; // device mdarray auto d_matrix = make_device_matrix(handle, n, n); ASSERT_EQ(d_matrix.extent(0), n); @@ -353,7 +353,7 @@ void test_factory_methods() } { - raft::handle_t handle{}; + raft::device_resources handle{}; // device scalar auto d_scalar = make_device_scalar(handle, 17.0); static_assert(d_scalar.rank() == 1); @@ -385,7 +385,7 @@ void test_factory_methods() // managed { - raft::handle_t handle{}; + raft::device_resources handle{}; auto mda = make_device_vector(handle, 10); auto mdv = make_managed_mdspan(mda.data_handle(), raft::vector_extent{10}); @@ -416,7 +416,7 @@ void check_matrix_layout(device_matrix_view in) TEST(MDArray, FuncArg) { - raft::handle_t handle{}; + raft::device_resources handle{}; { auto d_matrix = make_device_matrix(handle, 10, 10); check_matrix_layout(d_matrix.view()); @@ -918,7 +918,7 @@ void test_mdarray_unravel() } { - handle_t handle; + raft::device_resources handle; auto m = make_device_matrix(handle, 7, 6); auto m_v = m.view(); thrust::for_each_n(handle.get_thrust_policy(), diff --git a/cpp/test/core/mdspan_utils.cu b/cpp/test/core/mdspan_utils.cu index 6eaecf78b4..f428da4b31 100644 --- a/cpp/test/core/mdspan_utils.cu +++ b/cpp/test/core/mdspan_utils.cu @@ -118,7 +118,7 @@ TEST(MDArray, HostFlatten) { test_host_flatten(); } void test_device_flatten() { - raft::handle_t handle{}; + raft::device_resources handle{}; // flatten 3d device mdspan { using three_d_extents = extents; @@ -179,7 +179,7 @@ void test_reshape() // reshape 4d device array to 2d { - raft::handle_t handle{}; + raft::device_resources handle{}; using four_d_extents = extents; using four_d_mdarray = device_mdarray; diff --git a/cpp/test/distance/dist_adj.cu b/cpp/test/distance/dist_adj.cu index 4f6dfaac24..bbd06042c3 100644 --- a/cpp/test/distance/dist_adj.cu +++ b/cpp/test/distance/dist_adj.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,7 +156,7 @@ class DistanceAdjTest : public ::testing::TestWithParam dist_ref; rmm::device_uvector dist; - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; }; diff --git a/cpp/test/distance/distance_base.cuh b/cpp/test/distance/distance_base.cuh index fedbee919d..be7b2b1de8 100644 --- a/cpp/test/distance/distance_base.cuh +++ b/cpp/test/distance/distance_base.cuh @@ -397,7 +397,7 @@ void distanceLauncher(DataType* x, cudaStream_t stream, DataType metric_arg = 2.0f) { - raft::handle_t handle(stream); + raft::device_resources handle(stream); auto x_v = make_device_matrix_view(x, m, k); auto y_v = make_device_matrix_view(y, n, k); @@ -483,7 +483,7 @@ class DistanceTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; DistanceInputs params; @@ -519,7 +519,7 @@ class BigMatrixDistanceTest : public ::testing::Test { } protected: - raft::handle_t handle; + raft::device_resources handle; int m = 48000; int n = 48000; int k = 1; diff --git a/cpp/test/distance/fused_l2_nn.cu b/cpp/test/distance/fused_l2_nn.cu index 54de12307a..8b9681b9d3 100644 --- a/cpp/test/distance/fused_l2_nn.cu +++ b/cpp/test/distance/fused_l2_nn.cu @@ -158,7 +158,7 @@ class FusedL2NNTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; Inputs params; rmm::device_uvector x; @@ -380,7 +380,7 @@ class FusedL2NNDetTest : public FusedL2NNTest { void TearDown() override { FusedL2NNTest::TearDown(); } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector> min1; diff --git a/cpp/test/distance/gram.cu b/cpp/test/distance/gram.cu index 4366e023a0..a2f0e2385c 100644 --- a/cpp/test/distance/gram.cu +++ b/cpp/test/distance/gram.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ class GramMatrixTest : public ::testing::TestWithParam { gram_host.data(), gram.data(), gram.size(), raft::CompareApprox(1e-6f))); } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; GramMatrixInputs params; diff --git a/cpp/test/label/merge_labels.cu b/cpp/test/label/merge_labels.cu index c3d2f82a84..5107015652 100644 --- a/cpp/test/label/merge_labels.cu +++ b/cpp/test/label/merge_labels.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include #include "../test_utils.cuh" -#include +#include #include #include #include @@ -69,7 +69,7 @@ class MergeLabelsTest : public ::testing::TestWithParam params; diff --git a/cpp/test/lap/lap.cu b/cpp/test/lap/lap.cu index 58fd94f343..f26e41456f 100644 --- a/cpp/test/lap/lap.cu +++ b/cpp/test/lap/lap.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * Copyright 2020 KETAN DATE & RAKESH NAGI * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,7 +66,7 @@ void hungarian_test(int problemsize, weight_t epsilon, bool verbose = false) { - raft::handle_t handle; + raft::device_resources handle; weight_t* h_cost = new weight_t[batchsize * problemsize * problemsize]; diff --git a/cpp/test/linalg/add.cu b/cpp/test/linalg/add.cu index 0e5fc40232..3836f714cb 100644 --- a/cpp/test/linalg/add.cu +++ b/cpp/test/linalg/add.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class AddTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; AddInputs params; diff --git a/cpp/test/linalg/axpy.cu b/cpp/test/linalg/axpy.cu index 2eb11f314d..5fd7676792 100644 --- a/cpp/test/linalg/axpy.cu +++ b/cpp/test/linalg/axpy.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ struct AxpyInputs { template class AxpyTest : public ::testing::TestWithParam> { protected: - raft::handle_t handle; + raft::device_resources handle; AxpyInputs params; rmm::device_uvector refy; rmm::device_uvector y_device_alpha; diff --git a/cpp/test/linalg/binary_op.cu b/cpp/test/linalg/binary_op.cu index ac143842cb..9936e665ba 100644 --- a/cpp/test/linalg/binary_op.cu +++ b/cpp/test/linalg/binary_op.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,11 @@ namespace linalg { // for an extended __device__ lambda cannot have private or protected access // within its class template -void binaryOpLaunch( - const raft::handle_t& handle, OutType* out, const InType* in1, const InType* in2, IdxType len) +void binaryOpLaunch(const raft::device_resources& handle, + OutType* out, + const InType* in1, + const InType* in2, + IdxType len) { auto out_view = raft::make_device_vector_view(out, len); auto in1_view = raft::make_device_vector_view(in1, len); @@ -66,7 +69,7 @@ class BinaryOpTest : public ::testing::TestWithParam params; @@ -142,7 +145,7 @@ class BinaryOpAlignment : public ::testing::Test { z.data() + 9, x.data() + 137, y.data() + 19, 256, raft::add_op{}, handle.get_stream()); } - raft::handle_t handle; + raft::device_resources handle; }; typedef ::testing::Types FloatTypes; TYPED_TEST_CASE(BinaryOpAlignment, FloatTypes); diff --git a/cpp/test/linalg/cholesky_r1.cu b/cpp/test/linalg/cholesky_r1.cu index 9d90b03a6e..fba885957f 100644 --- a/cpp/test/linalg/cholesky_r1.cu +++ b/cpp/test/linalg/cholesky_r1.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ class CholeskyR1Test : public ::testing::Test { } } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; cusolverDnHandle_t solver_handle; diff --git a/cpp/test/linalg/coalesced_reduction.cu b/cpp/test/linalg/coalesced_reduction.cu index dc82ab9511..1309d4c9c1 100644 --- a/cpp/test/linalg/coalesced_reduction.cu +++ b/cpp/test/linalg/coalesced_reduction.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,8 +43,12 @@ template // for an extended __device__ lambda cannot have private or protected access // within its class template -void coalescedReductionLaunch( - const raft::handle_t& handle, T* dots, const T* data, int cols, int rows, bool inplace = false) +void coalescedReductionLaunch(const raft::device_resources& handle, + T* dots, + const T* data, + int cols, + int rows, + bool inplace = false) { auto dots_view = raft::make_device_vector_view(dots, rows); auto data_view = raft::make_device_matrix_view(data, rows, cols); @@ -101,7 +105,7 @@ class coalescedReductionTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/divide.cu b/cpp/test/linalg/divide.cu index 4b5ea0a2dc..6188e891d5 100644 --- a/cpp/test/linalg/divide.cu +++ b/cpp/test/linalg/divide.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ class DivideTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/dot.cu b/cpp/test/linalg/dot.cu index 80a9f24aba..8b8ca374d7 100644 --- a/cpp/test/linalg/dot.cu +++ b/cpp/test/linalg/dot.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ class DotTest : public ::testing::TestWithParam> { { params = ::testing::TestWithParam>::GetParam(); - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = handle.get_stream(); raft::random::RngState r(params.seed); diff --git a/cpp/test/linalg/eig.cu b/cpp/test/linalg/eig.cu index 4b834c1aa8..5229e99d20 100644 --- a/cpp/test/linalg/eig.cu +++ b/cpp/test/linalg/eig.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ class EigTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; EigInputs params; diff --git a/cpp/test/linalg/eig_sel.cu b/cpp/test/linalg/eig_sel.cu index c2b12e5d4a..24e8e83832 100644 --- a/cpp/test/linalg/eig_sel.cu +++ b/cpp/test/linalg/eig_sel.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +99,7 @@ class EigSelTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; EigSelInputs params; diff --git a/cpp/test/linalg/eigen_solvers.cu b/cpp/test/linalg/eigen_solvers.cu index 3e7d923e2d..1f29d7e275 100644 --- a/cpp/test/linalg/eigen_solvers.cu +++ b/cpp/test/linalg/eigen_solvers.cu @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include @@ -35,7 +35,7 @@ TEST(Raft, EigenSolvers) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; ASSERT_EQ(0, h. @@ -81,7 +81,7 @@ TEST(Raft, SpectralSolvers) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; ASSERT_EQ(0, h. diff --git a/cpp/test/linalg/eltwise.cu b/cpp/test/linalg/eltwise.cu index d9ab7e0984..d8c72991c3 100644 --- a/cpp/test/linalg/eltwise.cu +++ b/cpp/test/linalg/eltwise.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class ScalarMultiplyTest : public ::testing::TestWithParam params; @@ -168,7 +168,7 @@ class EltwiseAddTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; EltwiseAddInputs params; diff --git a/cpp/test/linalg/gemm_layout.cu b/cpp/test/linalg/gemm_layout.cu index a992a32304..47b7e22d5d 100644 --- a/cpp/test/linalg/gemm_layout.cu +++ b/cpp/test/linalg/gemm_layout.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ class GemmLayoutTest : public ::testing::TestWithParam> { { params = ::testing::TestWithParam>::GetParam(); - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = handle.get_stream(); raft::random::RngState r(params.seed); diff --git a/cpp/test/linalg/gemv.cu b/cpp/test/linalg/gemv.cu index 594810bab2..b4f338fdd1 100644 --- a/cpp/test/linalg/gemv.cu +++ b/cpp/test/linalg/gemv.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ class GemvTest : public ::testing::TestWithParam> { { params = ::testing::TestWithParam>::GetParam(); - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = handle.get_stream(); raft::random::RngState r(params.seed); diff --git a/cpp/test/linalg/map.cu b/cpp/test/linalg/map.cu index 1add9f7828..5b52374789 100644 --- a/cpp/test/linalg/map.cu +++ b/cpp/test/linalg/map.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ void mapLaunch(OutType* out, IdxType len, cudaStream_t stream) { - raft::handle_t handle{stream}; + raft::device_resources handle{stream}; auto out_view = raft::make_device_vector_view(out, len); auto in1_view = raft::make_device_vector_view(in1, len); map( @@ -100,7 +100,7 @@ class MapTest : public ::testing::TestWithParam params; @@ -134,7 +134,7 @@ class MapOffsetTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/map_then_reduce.cu b/cpp/test/linalg/map_then_reduce.cu index 1e7f58ec38..ae5058ef3e 100644 --- a/cpp/test/linalg/map_then_reduce.cu +++ b/cpp/test/linalg/map_then_reduce.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ class MapReduceTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MapReduceInputs params; @@ -171,7 +171,7 @@ class MapGenericReduceTest : public ::testing::Test { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; int n = 1237; diff --git a/cpp/test/linalg/matrix_vector.cu b/cpp/test/linalg/matrix_vector.cu index fb1e2235f9..602d01f60c 100644 --- a/cpp/test/linalg/matrix_vector.cu +++ b/cpp/test/linalg/matrix_vector.cu @@ -46,7 +46,7 @@ template // for an extended __device__ lambda cannot have private or protected access // within its class template -void matrix_vector_op_launch(const raft::handle_t& handle, +void matrix_vector_op_launch(const raft::device_resources& handle, T* in, const T* vec1, IdxType D, @@ -98,7 +98,7 @@ void matrix_vector_op_launch(const raft::handle_t& handle, } template -void naive_matrix_vector_op_launch(const raft::handle_t& handle, +void naive_matrix_vector_op_launch(const raft::device_resources& handle, T* in, const T* vec1, IdxType D, @@ -183,7 +183,7 @@ class MatrixVectorTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/matrix_vector_op.cu b/cpp/test/linalg/matrix_vector_op.cu index e2775c168d..5ba178e212 100644 --- a/cpp/test/linalg/matrix_vector_op.cu +++ b/cpp/test/linalg/matrix_vector_op.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,10 @@ template } template -inline void gen_uniform(const raft::handle_t& handle, raft::random::RngState& rng, T* ptr, LenT len) +inline void gen_uniform(const raft::device_resources& handle, + raft::random::RngState& rng, + T* ptr, + LenT len) { if constexpr (std::is_integral_v) { raft::random::uniformInt(handle, rng, ptr, len, (T)0, (T)100); @@ -54,7 +57,7 @@ inline void gen_uniform(const raft::handle_t& handle, raft::random::RngState& rn // for an extended __device__ lambda cannot have private or protected access // within its class template -void matrixVectorOpLaunch(const raft::handle_t& handle, +void matrixVectorOpLaunch(const raft::device_resources& handle, MatT* out, const MatT* in, const Vec1T* vec1, @@ -156,7 +159,7 @@ class MatVecOpTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MatVecOpInputs params; diff --git a/cpp/test/linalg/mean_squared_error.cu b/cpp/test/linalg/mean_squared_error.cu index 18e7debcb1..aa1c314e68 100644 --- a/cpp/test/linalg/mean_squared_error.cu +++ b/cpp/test/linalg/mean_squared_error.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ class MeanSquaredErrorTest : public ::testing::TestWithParam params; - raft::handle_t handle; + raft::device_resources handle; rmm::device_scalar output; rmm::device_scalar refoutput; diff --git a/cpp/test/linalg/multiply.cu b/cpp/test/linalg/multiply.cu index c90fb93fd0..b8af7515e0 100644 --- a/cpp/test/linalg/multiply.cu +++ b/cpp/test/linalg/multiply.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ class MultiplyTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; UnaryOpInputs params; diff --git a/cpp/test/linalg/norm.cu b/cpp/test/linalg/norm.cu index 90cfbd8f89..6dfeced6e0 100644 --- a/cpp/test/linalg/norm.cu +++ b/cpp/test/linalg/norm.cu @@ -113,7 +113,7 @@ class RowNormTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; NormInputs params; @@ -190,7 +190,7 @@ class ColNormTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; NormInputs params; diff --git a/cpp/test/linalg/normalize.cu b/cpp/test/linalg/normalize.cu index 0a6786b1ee..24f83a0d0a 100644 --- a/cpp/test/linalg/normalize.cu +++ b/cpp/test/linalg/normalize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ class RowNormalizeTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/power.cu b/cpp/test/linalg/power.cu index 5cb63a5697..20b1fa0e45 100644 --- a/cpp/test/linalg/power.cu +++ b/cpp/test/linalg/power.cu @@ -113,7 +113,7 @@ class PowerTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; PowerInputs params; rmm::device_uvector in1, in2, out_ref, out; int device_count = 0; diff --git a/cpp/test/linalg/reduce.cu b/cpp/test/linalg/reduce.cu index 4ad382c4f7..8cdeab5a94 100644 --- a/cpp/test/linalg/reduce.cu +++ b/cpp/test/linalg/reduce.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ void reduceLaunch(OutType* dots, auto input_view_col_major = raft::make_device_matrix_view(data, rows, cols); - raft::handle_t handle{stream}; + raft::device_resources handle{stream}; if (rowMajor) { reduce(handle, @@ -184,7 +184,7 @@ class ReduceTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/reduce_cols_by_key.cu b/cpp/test/linalg/reduce_cols_by_key.cu index 3870bfb830..037a6a86e0 100644 --- a/cpp/test/linalg/reduce_cols_by_key.cu +++ b/cpp/test/linalg/reduce_cols_by_key.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ class ReduceColsTest : public ::testing::TestWithParam { params = ::testing::TestWithParam>::GetParam(); raft::random::RngState r(params.seed); - raft::handle_t handle; + raft::device_resources handle; auto stream = handle.get_stream(); auto nrows = params.rows; auto ncols = params.cols; diff --git a/cpp/test/linalg/reduce_rows_by_key.cu b/cpp/test/linalg/reduce_rows_by_key.cu index 81f1817f74..69bacb0631 100644 --- a/cpp/test/linalg/reduce_rows_by_key.cu +++ b/cpp/test/linalg/reduce_rows_by_key.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ class ReduceRowTest : public ::testing::TestWithParam> { protected: ReduceRowsInputs params; - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; int device_count = 0; diff --git a/cpp/test/linalg/rsvd.cu b/cpp/test/linalg/rsvd.cu index 04e17468c3..ba2572b5a9 100644 --- a/cpp/test/linalg/rsvd.cu +++ b/cpp/test/linalg/rsvd.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include "../test_utils.cuh" #include -#include +#include #include #include #include @@ -64,7 +64,7 @@ class RsvdTest : public ::testing::TestWithParam> { void SetUp() override { - raft::handle_t handle; + raft::device_resources handle; stream = handle.get_stream(); params = ::testing::TestWithParam>::GetParam(); @@ -272,7 +272,7 @@ TEST_P(RsvdSanityCheckRightVecD, Result) typedef RsvdTest RsvdTestSquareMatrixNormF; TEST_P(RsvdTestSquareMatrixNormF, Result) { - raft::handle_t handle; + raft::device_resources handle; ASSERT_TRUE(raft::linalg::evaluateSVDByL2Norm(handle, A.data(), @@ -289,7 +289,7 @@ TEST_P(RsvdTestSquareMatrixNormF, Result) typedef RsvdTest RsvdTestSquareMatrixNormD; TEST_P(RsvdTestSquareMatrixNormD, Result) { - raft::handle_t handle; + raft::device_resources handle; ASSERT_TRUE(raft::linalg::evaluateSVDByL2Norm(handle, A.data(), diff --git a/cpp/test/linalg/sqrt.cu b/cpp/test/linalg/sqrt.cu index 93150ca77d..7ee31da874 100644 --- a/cpp/test/linalg/sqrt.cu +++ b/cpp/test/linalg/sqrt.cu @@ -82,7 +82,7 @@ class SqrtTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; SqrtInputs params; rmm::device_uvector in1, out_ref, out; int device_count = 0; diff --git a/cpp/test/linalg/strided_reduction.cu b/cpp/test/linalg/strided_reduction.cu index 6a8c43ad52..c9b32c3585 100644 --- a/cpp/test/linalg/strided_reduction.cu +++ b/cpp/test/linalg/strided_reduction.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ template void stridedReductionLaunch( T* dots, const T* data, int cols, int rows, bool inplace, cudaStream_t stream) { - raft::handle_t handle{stream}; + raft::device_resources handle{stream}; auto dots_view = raft::make_device_vector_view(dots, cols); auto data_view = raft::make_device_matrix_view(data, rows, cols); strided_reduction(handle, data_view, dots_view, (T)0, inplace, raft::sq_op{}); @@ -91,7 +91,7 @@ class stridedReductionTest : public ::testing::TestWithParam params; diff --git a/cpp/test/linalg/subtract.cu b/cpp/test/linalg/subtract.cu index 426fc98f9f..222e64fc3c 100644 --- a/cpp/test/linalg/subtract.cu +++ b/cpp/test/linalg/subtract.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,7 +108,7 @@ class SubtractTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SubtractInputs params; diff --git a/cpp/test/linalg/svd.cu b/cpp/test/linalg/svd.cu index 7918d481db..9eee0f538e 100644 --- a/cpp/test/linalg/svd.cu +++ b/cpp/test/linalg/svd.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ class SvdTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SvdInputs params; diff --git a/cpp/test/linalg/ternary_op.cu b/cpp/test/linalg/ternary_op.cu index c78df08820..3eadae95ae 100644 --- a/cpp/test/linalg/ternary_op.cu +++ b/cpp/test/linalg/ternary_op.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ class ternaryOpTest : public ::testing::TestWithParam> { protected: BinaryOpInputs params; - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; rmm::device_uvector out_add_ref, out_add, out_mul_ref, out_mul; diff --git a/cpp/test/linalg/transpose.cu b/cpp/test/linalg/transpose.cu index 110dc527d3..9644ee53db 100644 --- a/cpp/test/linalg/transpose.cu +++ b/cpp/test/linalg/transpose.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ class TransposeTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; TranposeInputs params; @@ -133,7 +133,7 @@ namespace { * @return The transposed matrix. */ template -[[nodiscard]] auto transpose(handle_t const& handle, +[[nodiscard]] auto transpose(raft::device_resources const& handle, device_matrix_view in) -> std::enable_if_t && (std::is_same_v || @@ -158,7 +158,7 @@ template * @return The transposed matrix. */ template -[[nodiscard]] auto transpose(handle_t const& handle, +[[nodiscard]] auto transpose(raft::device_resources const& handle, device_matrix_view in) -> std::enable_if_t, device_matrix> { @@ -188,7 +188,7 @@ template template void test_transpose_with_mdspan() { - handle_t handle; + raft::device_resources handle; auto v = make_device_matrix(handle, 32, 3); T k{0}; for (size_t i = 0; i < v.extent(0); ++i) { @@ -223,7 +223,7 @@ namespace { template void test_transpose_submatrix() { - handle_t handle; + raft::device_resources handle; auto v = make_device_matrix(handle, 32, 33); T k{0}; size_t row_beg{3}, row_end{13}, col_beg{2}, col_end{11}; diff --git a/cpp/test/linalg/unary_op.cu b/cpp/test/linalg/unary_op.cu index 341ae1a855..278eac348b 100644 --- a/cpp/test/linalg/unary_op.cu +++ b/cpp/test/linalg/unary_op.cu @@ -17,6 +17,7 @@ #include "../test_utils.cuh" #include "unary_op.cuh" #include +#include #include #include #include @@ -61,7 +62,7 @@ class UnaryOpTest : public ::testing::TestWithParam params; @@ -73,7 +74,10 @@ class UnaryOpTest : public ::testing::TestWithParam -void launchWriteOnlyUnaryOp(const raft::handle_t& handle, OutType* out, InType scalar, IdxType len) +void launchWriteOnlyUnaryOp(const raft::device_resources& handle, + OutType* out, + InType scalar, + IdxType len) { auto out_view = raft::make_device_vector_view(out, len); auto op = [scalar] __device__(OutType * ptr, IdxType idx) { diff --git a/cpp/test/matrix/argmax.cu b/cpp/test/matrix/argmax.cu index 33af0ce5a4..ec27b530d7 100644 --- a/cpp/test/matrix/argmax.cu +++ b/cpp/test/matrix/argmax.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ class ArgMaxTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; ArgMaxInputs params; raft::device_matrix input; diff --git a/cpp/test/matrix/argmin.cu b/cpp/test/matrix/argmin.cu index 22f0a6cac0..73f6123167 100644 --- a/cpp/test/matrix/argmin.cu +++ b/cpp/test/matrix/argmin.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ class ArgMinTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; ArgMinInputs params; raft::device_matrix input; diff --git a/cpp/test/matrix/columnSort.cu b/cpp/test/matrix/columnSort.cu index 00205830c4..2292772b1a 100644 --- a/cpp/test/matrix/columnSort.cu +++ b/cpp/test/matrix/columnSort.cu @@ -116,7 +116,7 @@ class ColumnSort : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; columnSort params; rmm::device_uvector keyIn, keySorted, keySortGolden; rmm::device_uvector valueOut, goldenValOut; // valueOut are indexes diff --git a/cpp/test/matrix/diagonal.cu b/cpp/test/matrix/diagonal.cu index f6cd178b23..118aa7988f 100644 --- a/cpp/test/matrix/diagonal.cu +++ b/cpp/test/matrix/diagonal.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ class DiagonalTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; DiagonalInputs params; int diag_size; diff --git a/cpp/test/matrix/gather.cu b/cpp/test/matrix/gather.cu index 3659265e84..bba9046812 100644 --- a/cpp/test/matrix/gather.cu +++ b/cpp/test/matrix/gather.cu @@ -163,7 +163,7 @@ class GatherTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; GatherInputs params; std::vector h_in, h_out, h_stencil; diff --git a/cpp/test/matrix/linewise_op.cu b/cpp/test/matrix/linewise_op.cu index a791cbc0f0..04a8a91b01 100644 --- a/cpp/test/matrix/linewise_op.cu +++ b/cpp/test/matrix/linewise_op.cu @@ -43,7 +43,7 @@ struct LinewiseTestParams { template struct LinewiseTest : public ::testing::TestWithParam { - const raft::handle_t handle; + const raft::device_resources handle; const LinewiseTestParams params; rmm::cuda_stream_view stream; diff --git a/cpp/test/matrix/math.cu b/cpp/test/matrix/math.cu index 9dcbfc8899..cd3d865d80 100644 --- a/cpp/test/matrix/math.cu +++ b/cpp/test/matrix/math.cu @@ -207,7 +207,7 @@ class MathTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MathInputs params; diff --git a/cpp/test/matrix/matrix.cu b/cpp/test/matrix/matrix.cu index 8cfbdac32b..10105203f7 100644 --- a/cpp/test/matrix/matrix.cu +++ b/cpp/test/matrix/matrix.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class MatrixTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MatrixInputs params; @@ -161,7 +161,7 @@ class MatrixCopyRowsTest : public ::testing::Test { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; int n_rows = 10; diff --git a/cpp/test/matrix/norm.cu b/cpp/test/matrix/norm.cu index b1e10c9047..ed1c393c4f 100644 --- a/cpp/test/matrix/norm.cu +++ b/cpp/test/matrix/norm.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ class NormTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; NormInputs params; diff --git a/cpp/test/matrix/reverse.cu b/cpp/test/matrix/reverse.cu index 49d501b6d0..f3929c582b 100644 --- a/cpp/test/matrix/reverse.cu +++ b/cpp/test/matrix/reverse.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,7 +118,7 @@ class ReverseTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; ReverseInputs params; diff --git a/cpp/test/matrix/select_k.cu b/cpp/test/matrix/select_k.cu index a8b5d60bb8..344e5b5748 100644 --- a/cpp/test/matrix/select_k.cu +++ b/cpp/test/matrix/select_k.cu @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include @@ -102,7 +102,7 @@ struct io_computed { default: break; } - handle_t handle{}; + device_resources handle{}; auto stream = handle.get_stream(); rmm::device_uvector in_dists_d(in_dists_.size(), stream); @@ -345,7 +345,7 @@ struct with_ref { auto algo = std::get<1>(ps); std::vector dists(spec.len * spec.batch_size); - raft::handle_t handle; + raft::device_resources handle; { auto s = handle.get_stream(); rmm::device_uvector dists_d(spec.len * spec.batch_size, s); diff --git a/cpp/test/matrix/slice.cu b/cpp/test/matrix/slice.cu index 9060357b3f..58f849a87c 100644 --- a/cpp/test/matrix/slice.cu +++ b/cpp/test/matrix/slice.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,7 @@ class SliceTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SliceInputs params; diff --git a/cpp/test/matrix/triangular.cu b/cpp/test/matrix/triangular.cu index 9c6c49066b..82b01181f5 100644 --- a/cpp/test/matrix/triangular.cu +++ b/cpp/test/matrix/triangular.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ class TriangularTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; TriangularInputs params; diff --git a/cpp/test/neighbors/ann_ivf_flat.cu b/cpp/test/neighbors/ann_ivf_flat.cu index 232759a948..8ccbe39889 100644 --- a/cpp/test/neighbors/ann_ivf_flat.cu +++ b/cpp/test/neighbors/ann_ivf_flat.cu @@ -279,7 +279,7 @@ class AnnIVFFlatTest : public ::testing::TestWithParam> { } private: - raft::handle_t handle_; + raft::device_resources handle_; rmm::cuda_stream_view stream_; AnnIvfFlatInputs ps; rmm::device_uvector database; diff --git a/cpp/test/neighbors/ann_ivf_pq.cuh b/cpp/test/neighbors/ann_ivf_pq.cuh index 178078b297..488041f527 100644 --- a/cpp/test/neighbors/ann_ivf_pq.cuh +++ b/cpp/test/neighbors/ann_ivf_pq.cuh @@ -116,8 +116,9 @@ inline auto operator<<(std::ostream& os, const ivf_pq_inputs& p) -> std::ostream } template -auto min_output_size(const handle_t& handle, const ivf_pq::index& index, uint32_t n_probes) - -> IdxT +auto min_output_size(const raft::device_resources& handle, + const ivf_pq::index& index, + uint32_t n_probes) -> IdxT { uint32_t skip = index.n_nonempty_lists() > n_probes ? index.n_nonempty_lists() - n_probes : 0; auto map_type = [] __device__(uint32_t x) { return IdxT(x); }; @@ -308,7 +309,7 @@ class ivf_pq_test : public ::testing::TestWithParam { } private: - raft::handle_t handle_; + raft::device_resources handle_; rmm::cuda_stream_view stream_; ivf_pq_inputs ps; // NOLINT rmm::device_uvector database; // NOLINT diff --git a/cpp/test/neighbors/ball_cover.cu b/cpp/test/neighbors/ball_cover.cu index 7405863b9f..a97df7df75 100644 --- a/cpp/test/neighbors/ball_cover.cu +++ b/cpp/test/neighbors/ball_cover.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ uint32_t count_discrepancies(value_idx* actual_idx, } template -void compute_bfknn(const raft::handle_t& handle, +void compute_bfknn(const raft::device_resources& handle, const value_t* X1, const value_t* X2, uint32_t n_rows, @@ -152,7 +152,7 @@ class BallCoverKNNQueryTest : public ::testing::TestWithParam>::GetParam(); - raft::handle_t handle; + raft::device_resources handle; uint32_t k = params.k; uint32_t n_centers = 25; @@ -252,7 +252,7 @@ class BallCoverAllKNNTest : public ::testing::TestWithParam>::GetParam(); - raft::handle_t handle; + raft::device_resources handle; uint32_t k = params.k; uint32_t n_centers = 25; diff --git a/cpp/test/neighbors/epsilon_neighborhood.cu b/cpp/test/neighbors/epsilon_neighborhood.cu index 36d7cb25ff..c78a15dd2d 100644 --- a/cpp/test/neighbors/epsilon_neighborhood.cu +++ b/cpp/test/neighbors/epsilon_neighborhood.cu @@ -72,7 +72,7 @@ class EpsNeighTest : public ::testing::TestWithParam> { false); } - const raft::handle_t handle; + const raft::device_resources handle; EpsInputs param; cudaStream_t stream = 0; rmm::device_uvector data; diff --git a/cpp/test/neighbors/faiss_mr.cu b/cpp/test/neighbors/faiss_mr.cu index 38e793d120..5f0bcae933 100644 --- a/cpp/test/neighbors/faiss_mr.cu +++ b/cpp/test/neighbors/faiss_mr.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ class FAISS_MR_Test : public ::testing::TestWithParam { ASSERT_TRUE(free_after_alloc <= free_before - params_.size); } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; AllocInputs params_; }; diff --git a/cpp/test/neighbors/fused_l2_knn.cu b/cpp/test/neighbors/fused_l2_knn.cu index ca20bebaf6..6ab0671229 100644 --- a/cpp/test/neighbors/fused_l2_knn.cu +++ b/cpp/test/neighbors/fused_l2_knn.cu @@ -183,7 +183,7 @@ class FusedL2KNNTest : public ::testing::TestWithParam { } private: - raft::handle_t handle_; + raft::device_resources handle_; cudaStream_t stream_ = 0; FusedL2KNNInputs params_; int num_queries; diff --git a/cpp/test/neighbors/haversine.cu b/cpp/test/neighbors/haversine.cu index 91a2ca07df..dc5c8afe18 100644 --- a/cpp/test/neighbors/haversine.cu +++ b/cpp/test/neighbors/haversine.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ class HaversineKNNTest : public ::testing::Test { void SetUp() override { basicTest(); } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector d_train_inputs; diff --git a/cpp/test/neighbors/knn.cu b/cpp/test/neighbors/knn.cu index ff3a6a80b4..6814d47dcb 100644 --- a/cpp/test/neighbors/knn.cu +++ b/cpp/test/neighbors/knn.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,7 +154,7 @@ class KNNTest : public ::testing::TestWithParam { } private: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; KNNInputs params_; diff --git a/cpp/test/neighbors/refine.cu b/cpp/test/neighbors/refine.cu index e2575f0f4e..98933046b9 100644 --- a/cpp/test/neighbors/refine.cu +++ b/cpp/test/neighbors/refine.cu @@ -19,7 +19,7 @@ #include -#include +#include #include #include #include @@ -102,7 +102,7 @@ class RefineTest : public ::testing::TestWithParam> { } public: - raft::handle_t handle_; + raft::device_resources handle_; rmm::cuda_stream_view stream_; RefineHelper data; }; diff --git a/cpp/test/neighbors/selection.cu b/cpp/test/neighbors/selection.cu index 4b84c9b840..61a6345e5e 100644 --- a/cpp/test/neighbors/selection.cu +++ b/cpp/test/neighbors/selection.cu @@ -49,7 +49,8 @@ std::ostream& operator<<(std::ostream& os, const SelectTestSpec& ss) } template -auto gen_simple_ids(int n_inputs, int input_len, const raft::handle_t& handle) -> std::vector +auto gen_simple_ids(int n_inputs, int input_len, const raft::device_resources& handle) + -> std::vector { std::vector out(n_inputs * input_len); auto s = handle.get_stream(); @@ -65,7 +66,7 @@ struct SelectInOutSimple { public: bool not_supported = false; - SelectInOutSimple(std::shared_ptr handle, + SelectInOutSimple(std::shared_ptr handle, const SelectTestSpec& spec, const std::vector& in_dists, const std::vector& out_dists, @@ -84,7 +85,7 @@ struct SelectInOutSimple { auto get_out_ids() -> std::vector& { return out_ids_; } private: - std::shared_ptr handle_; + std::shared_ptr handle_; std::vector in_dists_; std::vector in_ids_; std::vector out_dists_; @@ -96,7 +97,7 @@ struct SelectInOutComputed { public: bool not_supported = false; - SelectInOutComputed(std::shared_ptr handle, + SelectInOutComputed(std::shared_ptr handle, const SelectTestSpec& spec, knn::SelectKAlgo algo, const std::vector& in_dists, @@ -162,7 +163,7 @@ struct SelectInOutComputed { auto get_out_ids() -> std::vector& { return out_ids_; } private: - std::shared_ptr handle_; + std::shared_ptr handle_; std::vector in_dists_; std::vector in_ids_; std::vector out_dists_; @@ -212,12 +213,13 @@ struct SelectInOutComputed { }; template -using Params = std::tuple>; +using Params = + std::tuple>; template typename ParamsReader> class SelectionTest : public testing::TestWithParam::ParamsIn> { protected: - std::shared_ptr handle_; + std::shared_ptr handle_; const SelectTestSpec spec; const knn::SelectKAlgo algo; @@ -275,7 +277,7 @@ struct params_simple { using InOut = SelectInOutSimple; using Inputs = std::tuple, std::vector, std::vector>; - using Handle = std::shared_ptr; + using Handle = std::shared_ptr; using ParamsIn = std::tuple; static auto read(ParamsIn ps) -> Params @@ -352,21 +354,22 @@ auto inputs_simple_f = testing::Values( typedef SelectionTest SimpleFloatInt; TEST_P(SimpleFloatInt, Run) { run(); } -INSTANTIATE_TEST_CASE_P(SelectionTest, - SimpleFloatInt, - testing::Combine(inputs_simple_f, - testing::Values(knn::SelectKAlgo::FAISS, - knn::SelectKAlgo::RADIX_8_BITS, - knn::SelectKAlgo::RADIX_11_BITS, - knn::SelectKAlgo::WARP_SORT), - testing::Values(std::make_shared()))); +INSTANTIATE_TEST_CASE_P( + SelectionTest, + SimpleFloatInt, + testing::Combine(inputs_simple_f, + testing::Values(knn::SelectKAlgo::FAISS, + knn::SelectKAlgo::RADIX_8_BITS, + knn::SelectKAlgo::RADIX_11_BITS, + knn::SelectKAlgo::WARP_SORT), + testing::Values(std::make_shared()))); template struct with_ref { template struct params_random { using InOut = SelectInOutComputed; - using Handle = std::shared_ptr; + using Handle = std::shared_ptr; using ParamsIn = std::tuple; static auto read(ParamsIn ps) -> Params @@ -448,33 +451,36 @@ auto inputs_random_largek = testing::Values(SelectTestSpec{100, 100000, 1000, tr typedef SelectionTest::params_random> ReferencedRandomFloatInt; TEST_P(ReferencedRandomFloatInt, Run) { run(); } -INSTANTIATE_TEST_CASE_P(SelectionTest, - ReferencedRandomFloatInt, - testing::Combine(inputs_random_longlist, - testing::Values(knn::SelectKAlgo::RADIX_8_BITS, - knn::SelectKAlgo::RADIX_11_BITS, - knn::SelectKAlgo::WARP_SORT), - testing::Values(std::make_shared()))); +INSTANTIATE_TEST_CASE_P( + SelectionTest, + ReferencedRandomFloatInt, + testing::Combine(inputs_random_longlist, + testing::Values(knn::SelectKAlgo::RADIX_8_BITS, + knn::SelectKAlgo::RADIX_11_BITS, + knn::SelectKAlgo::WARP_SORT), + testing::Values(std::make_shared()))); typedef SelectionTest::params_random> ReferencedRandomDoubleSizeT; TEST_P(ReferencedRandomDoubleSizeT, Run) { run(); } -INSTANTIATE_TEST_CASE_P(SelectionTest, - ReferencedRandomDoubleSizeT, - testing::Combine(inputs_random_longlist, - testing::Values(knn::SelectKAlgo::RADIX_8_BITS, - knn::SelectKAlgo::RADIX_11_BITS, - knn::SelectKAlgo::WARP_SORT), - testing::Values(std::make_shared()))); +INSTANTIATE_TEST_CASE_P( + SelectionTest, + ReferencedRandomDoubleSizeT, + testing::Combine(inputs_random_longlist, + testing::Values(knn::SelectKAlgo::RADIX_8_BITS, + knn::SelectKAlgo::RADIX_11_BITS, + knn::SelectKAlgo::WARP_SORT), + testing::Values(std::make_shared()))); typedef SelectionTest::params_random> ReferencedRandomDoubleInt; TEST_P(ReferencedRandomDoubleInt, LargeSize) { run(); } -INSTANTIATE_TEST_CASE_P(SelectionTest, - ReferencedRandomDoubleInt, - testing::Combine(inputs_random_largesize, - testing::Values(knn::SelectKAlgo::WARP_SORT), - testing::Values(std::make_shared()))); +INSTANTIATE_TEST_CASE_P( + SelectionTest, + ReferencedRandomDoubleInt, + testing::Combine(inputs_random_largesize, + testing::Values(knn::SelectKAlgo::WARP_SORT), + testing::Values(std::make_shared()))); /** TODO: Fix test failure in RAFT CI * diff --git a/cpp/test/random/make_blobs.cu b/cpp/test/random/make_blobs.cu index ea7283977c..c2dbc5dc1c 100644 --- a/cpp/test/random/make_blobs.cu +++ b/cpp/test/random/make_blobs.cu @@ -147,7 +147,7 @@ class MakeBlobsTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; MakeBlobsInputs params; cudaStream_t stream = 0; diff --git a/cpp/test/random/make_regression.cu b/cpp/test/random/make_regression.cu index 960ecc11d9..7508b57bdd 100644 --- a/cpp/test/random/make_regression.cu +++ b/cpp/test/random/make_regression.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ class MakeRegressionTest : public ::testing::TestWithParam params; @@ -251,7 +251,7 @@ class MakeRegressionMdspanTest : public ::testing::TestWithParam params{::testing::TestWithParam>::GetParam()}; - raft::handle_t handle; + raft::device_resources handle; rmm::device_uvector values_ret{params.n_samples * params.n_targets, handle.get_stream()}; rmm::device_uvector values_prod{params.n_samples * params.n_targets, handle.get_stream()}; int zero_count = -1; diff --git a/cpp/test/random/multi_variable_gaussian.cu b/cpp/test/random/multi_variable_gaussian.cu index b2b99027d6..1aa8b6a555 100644 --- a/cpp/test/random/multi_variable_gaussian.cu +++ b/cpp/test/random/multi_variable_gaussian.cu @@ -197,7 +197,7 @@ class MVGTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; MVGInputs params; rmm::device_uvector workspace_d, P_d, x_d, X_d, Rand_cov, Rand_mean; std::vector P, x, X; @@ -325,7 +325,7 @@ class MVGMdspanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; MVGInputs params; std::vector P, x, X; diff --git a/cpp/test/random/permute.cu b/cpp/test/random/permute.cu index be4f2a005f..d5fcca270e 100644 --- a/cpp/test/random/permute.cu +++ b/cpp/test/random/permute.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ class PermTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; PermInputs params; rmm::device_uvector in, out; T* in_ptr = nullptr; @@ -158,7 +158,7 @@ class PermMdspanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; PermInputs params; rmm::device_uvector in, out; T* in_ptr = nullptr; diff --git a/cpp/test/random/rmat_rectangular_generator.cu b/cpp/test/random/rmat_rectangular_generator.cu index c1c4752453..aae3898389 100644 --- a/cpp/test/random/rmat_rectangular_generator.cu +++ b/cpp/test/random/rmat_rectangular_generator.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,7 +242,7 @@ class RmatGenTest : public ::testing::TestWithParam { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RmatInputs params; @@ -347,7 +347,7 @@ class RmatGenMdspanTest : public ::testing::TestWithParam { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RmatInputs params; diff --git a/cpp/test/random/rng.cu b/cpp/test/random/rng.cu index 0bf494b624..d3b8e44b05 100644 --- a/cpp/test/random/rng.cu +++ b/cpp/test/random/rng.cu @@ -180,7 +180,7 @@ class RngTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RngInputs params; @@ -274,7 +274,7 @@ class RngMdspanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RngInputs params; @@ -391,7 +391,7 @@ TEST(Rng, MeanError) int num_experiments = 1024; int len = num_samples * num_experiments; - raft::handle_t handle; + raft::device_resources handle; auto stream = handle.get_stream(); rmm::device_uvector data(len, stream); @@ -458,7 +458,7 @@ class ScaledBernoulliTest : public ::testing::Test { h_data.get(), h_data.get() + len, [](const T& a) { return a < -scale || a > scale; })); } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector data; @@ -487,7 +487,7 @@ class ScaledBernoulliMdspanTest : public ::testing::Test { h_data.get(), h_data.get() + len, [](const T& a) { return a < -scale || a > scale; })); } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector data; @@ -528,7 +528,7 @@ class BernoulliTest : public ::testing::Test { delete[] h_data; } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector data; @@ -559,7 +559,7 @@ class BernoulliMdspanTest : public ::testing::Test { ASSERT_TRUE(std::any_of(h_data.get(), h_data.get() + len, [](bool a) { return !a; })); } - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; rmm::device_uvector data; @@ -635,7 +635,7 @@ class RngNormalTableTest : public ::testing::TestWithParam params; @@ -691,7 +691,7 @@ class RngNormalTableMdspanTest : public ::testing::TestWithParam params; diff --git a/cpp/test/random/rng_discrete.cu b/cpp/test/random/rng_discrete.cu index 2704bac885..741f7c65e0 100644 --- a/cpp/test/random/rng_discrete.cu +++ b/cpp/test/random/rng_discrete.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,7 +166,7 @@ class RngDiscreteTest : public ::testing::TestWithParam> } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RngDiscreteInputs params; diff --git a/cpp/test/random/rng_int.cu b/cpp/test/random/rng_int.cu index 89d6d208a5..83300b3ecc 100644 --- a/cpp/test/random/rng_int.cu +++ b/cpp/test/random/rng_int.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ class RngTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RngInputs params; @@ -165,7 +165,7 @@ class RngMdspanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; RngInputs params; diff --git a/cpp/test/random/sample_without_replacement.cu b/cpp/test/random/sample_without_replacement.cu index c9b4dd0879..ae5a58da3d 100644 --- a/cpp/test/random/sample_without_replacement.cu +++ b/cpp/test/random/sample_without_replacement.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ class SWoRTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SWoRInputs params; @@ -145,7 +145,7 @@ class SWoRMdspanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SWoRInputs params; diff --git a/cpp/test/sparse/add.cu b/cpp/test/sparse/add.cu index 692094a861..eb10432f3d 100644 --- a/cpp/test/sparse/add.cu +++ b/cpp/test/sparse/add.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -126,7 +126,7 @@ class CSRAddTest : public ::testing::TestWithParam> } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; CSRAddInputs params; diff --git a/cpp/test/sparse/convert_coo.cu b/cpp/test/sparse/convert_coo.cu index 21f81bfa6a..ad91d0d284 100644 --- a/cpp/test/sparse/convert_coo.cu +++ b/cpp/test/sparse/convert_coo.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -66,7 +66,7 @@ class CSRtoCOOTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; CSRtoCOOInputs params; diff --git a/cpp/test/sparse/convert_csr.cu b/cpp/test/sparse/convert_csr.cu index bc81dcaba5..71d296f665 100644 --- a/cpp/test/sparse/convert_csr.cu +++ b/cpp/test/sparse/convert_csr.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -181,7 +181,7 @@ class CSRAdjGraphTest : public ::testing::TestWithParam params; diff --git a/cpp/test/sparse/csr_row_slice.cu b/cpp/test/sparse/csr_row_slice.cu index 6b10f8d798..73b8691774 100644 --- a/cpp/test/sparse/csr_row_slice.cu +++ b/cpp/test/sparse/csr_row_slice.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include @@ -142,7 +142,7 @@ class CSRRowSliceTest : public ::testing::TestWithParam -#include +#include #include #include @@ -116,7 +116,7 @@ class CSRToDenseTest : public ::testing::TestWithParam -#include +#include #include #include #include @@ -101,7 +101,7 @@ class CSRTransposeTest : public ::testing::TestWithParam indptr, indices; diff --git a/cpp/test/sparse/distance.cu b/cpp/test/sparse/distance.cu index 367bfddad1..2a973d675c 100644 --- a/cpp/test/sparse/distance.cu +++ b/cpp/test/sparse/distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ class SparseDistanceTest dist_config.handle.get_stream()); } - raft::handle_t handle; + raft::device_resources handle; // input data rmm::device_uvector indptr, indices; diff --git a/cpp/test/sparse/filter.cu b/cpp/test/sparse/filter.cu index 6ada5ddcad..8c106f8868 100644 --- a/cpp/test/sparse/filter.cu +++ b/cpp/test/sparse/filter.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ const std::vector> inputsf = {{5, 10, 5, 1234ULL}}; typedef SparseFilterTests COORemoveZeros; TEST_P(COORemoveZeros, Result) { - raft::handle_t h; + raft::device_resources h; auto stream = h.get_stream(); params = ::testing::TestWithParam>::GetParam(); diff --git a/cpp/test/sparse/mst.cu b/cpp/test/sparse/mst.cu index 7c7d264f3f..0a80846440 100644 --- a/cpp/test/sparse/mst.cu +++ b/cpp/test/sparse/mst.cu @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -241,7 +241,7 @@ class MSTTest : public ::testing::TestWithParam +#include #include #include #include @@ -81,7 +81,7 @@ class CSRRowNormalizeTest : public ::testing::TestWithParam params; diff --git a/cpp/test/sparse/reduce.cu b/cpp/test/sparse/reduce.cu index 5752624435..6dc67dbbd8 100644 --- a/cpp/test/sparse/reduce.cu +++ b/cpp/test/sparse/reduce.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include "../test_utils.cuh" #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ class SparseReduceTest : public ::testing::TestWithParam params; diff --git a/cpp/test/sparse/sort.cu b/cpp/test/sparse/sort.cu index 23c2f5b67a..319c96bc02 100644 --- a/cpp/test/sparse/sort.cu +++ b/cpp/test/sparse/sort.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ TEST_P(COOSort, Result) { params = ::testing::TestWithParam>::GetParam(); raft::random::RngState r(params.seed); - raft::handle_t h; + raft::device_resources h; auto stream = h.get_stream(); rmm::device_uvector in_rows(params.nnz, stream); diff --git a/cpp/test/sparse/spectral_matrix.cu b/cpp/test/sparse/spectral_matrix.cu index 02856cb378..3b044e3974 100644 --- a/cpp/test/sparse/spectral_matrix.cu +++ b/cpp/test/sparse/spectral_matrix.cu @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include @@ -39,7 +39,7 @@ TEST(Raft, SpectralMatrices) using index_type = int; using value_type = double; - handle_t h; + raft::device_resources h; ASSERT_EQ(0, h.get_device()); csr_view_t csr_v{nullptr, nullptr, nullptr, 0, 0}; diff --git a/cpp/test/sparse/spgemmi.cu b/cpp/test/sparse/spgemmi.cu index 653c2fa29b..ec77b8e88b 100644 --- a/cpp/test/sparse/spgemmi.cu +++ b/cpp/test/sparse/spgemmi.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include "../test_utils.cuh" -#include +#include #include #include #include @@ -120,7 +120,7 @@ class SPGemmiTest : public ::testing::TestWithParam { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SPGemmiInputs params; diff --git a/cpp/test/sparse/symmetrize.cu b/cpp/test/sparse/symmetrize.cu index 6f2f877304..80a512a019 100644 --- a/cpp/test/sparse/symmetrize.cu +++ b/cpp/test/sparse/symmetrize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ class SparseSymmetrizeTest } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; // input data diff --git a/cpp/test/stats/accuracy.cu b/cpp/test/stats/accuracy.cu index eaccdecab4..543b99bda0 100644 --- a/cpp/test/stats/accuracy.cu +++ b/cpp/test/stats/accuracy.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ class AccuracyTest : public ::testing::TestWithParam> { protected: AccuracyInputs params; - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; T expectedVal, actualVal; }; diff --git a/cpp/test/stats/adjusted_rand_index.cu b/cpp/test/stats/adjusted_rand_index.cu index 52bc72174a..4506a6730a 100644 --- a/cpp/test/stats/adjusted_rand_index.cu +++ b/cpp/test/stats/adjusted_rand_index.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,7 @@ class adjustedRandIndexTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; completenessParam params; T lowerLabelRange, upperLabelRange; int nElements = 0; diff --git a/cpp/test/stats/contingencyMatrix.cu b/cpp/test/stats/contingencyMatrix.cu index d27114388e..f344b9ae71 100644 --- a/cpp/test/stats/contingencyMatrix.cu +++ b/cpp/test/stats/contingencyMatrix.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,7 +135,7 @@ class ContingencyMatrixTest : public ::testing::TestWithParam())); } - raft::handle_t handle; + raft::device_resources handle; ContingencyMatrixParam params; int numUniqueClasses = -1; T minLabel, maxLabel; diff --git a/cpp/test/stats/cov.cu b/cpp/test/stats/cov.cu index 287bb85886..c8a90b2f7d 100644 --- a/cpp/test/stats/cov.cu +++ b/cpp/test/stats/cov.cu @@ -53,7 +53,7 @@ class CovTest : public ::testing::TestWithParam> { void SetUp() override { - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = handle.get_stream(); params = ::testing::TestWithParam>::GetParam(); diff --git a/cpp/test/stats/dispersion.cu b/cpp/test/stats/dispersion.cu index e414fcf5f4..261e66af52 100644 --- a/cpp/test/stats/dispersion.cu +++ b/cpp/test/stats/dispersion.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ class DispersionTest : public ::testing::TestWithParam> { protected: DispersionInputs params; - raft::handle_t handle; + raft::device_resources handle; rmm::device_uvector exp_mean, act_mean; cudaStream_t stream = 0; int npoints; diff --git a/cpp/test/stats/entropy.cu b/cpp/test/stats/entropy.cu index 96b2b9f590..f19da32bb0 100644 --- a/cpp/test/stats/entropy.cu +++ b/cpp/test/stats/entropy.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ class entropyTest : public ::testing::TestWithParam { upperLabelRange); } - raft::handle_t handle; + raft::device_resources handle; // declaring the data values entropyParam params; T lowerLabelRange, upperLabelRange; diff --git a/cpp/test/stats/histogram.cu b/cpp/test/stats/histogram.cu index 76677ac27c..b3f9fe6782 100644 --- a/cpp/test/stats/histogram.cu +++ b/cpp/test/stats/histogram.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,7 @@ class HistTest : public ::testing::TestWithParam { } protected: - raft::handle_t handle; + raft::device_resources handle; HistInputs params; rmm::device_uvector in, bins, ref_bins; }; @@ -131,7 +131,7 @@ class HistMdspanTest : public ::testing::TestWithParam { } protected: - raft::handle_t handle; + raft::device_resources handle; HistInputs params; rmm::device_uvector in, bins, ref_bins; }; diff --git a/cpp/test/stats/homogeneity_score.cu b/cpp/test/stats/homogeneity_score.cu index ecbf160770..1b48bb1823 100644 --- a/cpp/test/stats/homogeneity_score.cu +++ b/cpp/test/stats/homogeneity_score.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ class homogeneityTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; homogeneityParam params; T lowerLabelRange, upperLabelRange; int nElements = 0; diff --git a/cpp/test/stats/information_criterion.cu b/cpp/test/stats/information_criterion.cu index 2cfbd787c6..45804c6724 100644 --- a/cpp/test/stats/information_criterion.cu +++ b/cpp/test/stats/information_criterion.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -109,7 +109,7 @@ class BatchedICTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; BatchedICInputs params; rmm::device_uvector res_d; diff --git a/cpp/test/stats/kl_divergence.cu b/cpp/test/stats/kl_divergence.cu index b5a6c393f3..15eac6428a 100644 --- a/cpp/test/stats/kl_divergence.cu +++ b/cpp/test/stats/kl_divergence.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class klDivergenceTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; klDivergenceParam params; int nElements = 0; DataT truthklDivergence = 0; diff --git a/cpp/test/stats/mean.cu b/cpp/test/stats/mean.cu index 19398d6d8e..4d011a2425 100644 --- a/cpp/test/stats/mean.cu +++ b/cpp/test/stats/mean.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ class MeanTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MeanInputs params; diff --git a/cpp/test/stats/mean_center.cu b/cpp/test/stats/mean_center.cu index 31947ef527..e5e01a2b10 100644 --- a/cpp/test/stats/mean_center.cu +++ b/cpp/test/stats/mean_center.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ class MeanCenterTest : public ::testing::TestWithParam params; diff --git a/cpp/test/stats/meanvar.cu b/cpp/test/stats/meanvar.cu index fb9fc13dec..d21ec43bba 100644 --- a/cpp/test/stats/meanvar.cu +++ b/cpp/test/stats/meanvar.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ class MeanVarTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; MeanVarInputs params; diff --git a/cpp/test/stats/minmax.cu b/cpp/test/stats/minmax.cu index 1171995d5c..8b58f9692a 100644 --- a/cpp/test/stats/minmax.cu +++ b/cpp/test/stats/minmax.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ class MinMaxTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; MinMaxInputs params; rmm::device_uvector minmax_act; rmm::device_uvector minmax_ref; diff --git a/cpp/test/stats/mutual_info_score.cu b/cpp/test/stats/mutual_info_score.cu index 8b6e7b2095..1b4ce26746 100644 --- a/cpp/test/stats/mutual_info_score.cu +++ b/cpp/test/stats/mutual_info_score.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -126,7 +126,7 @@ class mutualInfoTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; mutualInfoParam params; T lowerLabelRange, upperLabelRange; int nElements = 0; diff --git a/cpp/test/stats/r2_score.cu b/cpp/test/stats/r2_score.cu index 7fb15505ab..26a1920aae 100644 --- a/cpp/test/stats/r2_score.cu +++ b/cpp/test/stats/r2_score.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ class R2_scoreTest : public ::testing::TestWithParam> { protected: R2_scoreInputs params; - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream = 0; T expectedVal, actualVal; }; diff --git a/cpp/test/stats/rand_index.cu b/cpp/test/stats/rand_index.cu index 0010f3cbcd..10a31a27ca 100644 --- a/cpp/test/stats/rand_index.cu +++ b/cpp/test/stats/rand_index.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -98,7 +98,7 @@ class randIndexTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; randIndexParam params; int lowerLabelRange = 0, upperLabelRange = 2; uint64_t size = 0; diff --git a/cpp/test/stats/regression_metrics.cu b/cpp/test/stats/regression_metrics.cu index b3e0df32f8..9a8e4af6a4 100644 --- a/cpp/test/stats/regression_metrics.cu +++ b/cpp/test/stats/regression_metrics.cu @@ -106,7 +106,7 @@ class RegressionTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; RegressionInputs params; cudaStream_t stream = 0; double mean_abs_error = 0; diff --git a/cpp/test/stats/silhouette_score.cu b/cpp/test/stats/silhouette_score.cu index 354a9c29cc..80e60a4884 100644 --- a/cpp/test/stats/silhouette_score.cu +++ b/cpp/test/stats/silhouette_score.cu @@ -192,7 +192,7 @@ class silhouetteScoreTest : public ::testing::TestWithParam d_X; diff --git a/cpp/test/stats/stddev.cu b/cpp/test/stats/stddev.cu index 7f54eee2ab..dfc31f31d2 100644 --- a/cpp/test/stats/stddev.cu +++ b/cpp/test/stats/stddev.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ class StdDevTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; StdDevInputs params; diff --git a/cpp/test/stats/sum.cu b/cpp/test/stats/sum.cu index c69bd04c6e..f6b6ffcc45 100644 --- a/cpp/test/stats/sum.cu +++ b/cpp/test/stats/sum.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. + * Copyright (c) 2018-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include "../test_utils.cuh" -#include +#include #include #include #include @@ -72,7 +72,7 @@ class SumTest : public ::testing::TestWithParam> { } protected: - raft::handle_t handle; + raft::device_resources handle; cudaStream_t stream; SumInputs params; diff --git a/cpp/test/stats/trustworthiness.cu b/cpp/test/stats/trustworthiness.cu index e264f92db9..a2f72516eb 100644 --- a/cpp/test/stats/trustworthiness.cu +++ b/cpp/test/stats/trustworthiness.cu @@ -338,7 +338,7 @@ class TrustworthinessScoreTest : public ::testing::Test { void TearDown() override {} protected: - raft::handle_t handle; + raft::device_resources handle; rmm::device_uvector d_X; rmm::device_uvector d_X_embedded; diff --git a/cpp/test/stats/v_measure.cu b/cpp/test/stats/v_measure.cu index 79899c1d75..9d1522a5c8 100644 --- a/cpp/test/stats/v_measure.cu +++ b/cpp/test/stats/v_measure.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,7 @@ class vMeasureTest : public ::testing::TestWithParam { } // declaring the data values - raft::handle_t handle; + raft::device_resources handle; vMeasureParam params; T lowerLabelRange, upperLabelRange; int nElements = 0; diff --git a/cpp/test/stats/weighted_mean.cu b/cpp/test/stats/weighted_mean.cu index 8b4af07898..7e28ca9aa3 100644 --- a/cpp/test/stats/weighted_mean.cu +++ b/cpp/test/stats/weighted_mean.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ class RowWeightedMeanTest : public ::testing::TestWithParam params; thrust::host_vector hin, hweights; thrust::device_vector din, dweights, dexp, dact; @@ -186,7 +186,7 @@ class ColWeightedMeanTest : public ::testing::TestWithParam params; thrust::host_vector hin, hweights; thrust::device_vector din, dweights, dexp, dact; @@ -244,7 +244,7 @@ class WeightedMeanTest : public ::testing::TestWithParam> } protected: - raft::handle_t handle; + raft::device_resources handle; WeightedMeanInputs params; thrust::host_vector hin, hweights; thrust::device_vector din, dweights, dexp, dact; diff --git a/docs/source/cpp_api/core.rst b/docs/source/cpp_api/core.rst index 98365d6485..c4728337a0 100644 --- a/docs/source/cpp_api/core.rst +++ b/docs/source/cpp_api/core.rst @@ -14,7 +14,7 @@ expose in public APIs. :maxdepth: 2 :caption: Contents: - core_handle.rst + core_resources.rst core_logger.rst core_kvp.rst core_nvtx.rst diff --git a/docs/source/cpp_api/core_handle.rst b/docs/source/cpp_api/core_handle.rst deleted file mode 100644 index 58fc80681e..0000000000 --- a/docs/source/cpp_api/core_handle.rst +++ /dev/null @@ -1,15 +0,0 @@ -handle_t -======== - -.. role:: py(code) - :language: c++ - :class: highlight - - -``#include `` - -namespace *raft::core* - -.. doxygenclass:: raft::handle_t - :project: RAFT - :members: diff --git a/docs/source/cpp_api/core_resources.rst b/docs/source/cpp_api/core_resources.rst new file mode 100644 index 0000000000..b148e38e44 --- /dev/null +++ b/docs/source/cpp_api/core_resources.rst @@ -0,0 +1,183 @@ +Resources +========= + +.. role:: py(code) + :language: c++ + :class: highlight + +All resources which are specific to a computing environment like host or device are contained within, and managed by, +raft::resources. This design simplifies the APIs and eases user burden by making them opaque by default but allowing customization based on user preference. + + +Vocabulary +---------- + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_types + :project: RAFT + :members: + :content-only: + + +Device Resources +---------------- + +``#include `` + +namespace *raft::core* + +.. doxygenclass:: raft::device_resources + :project: RAFT + :members: + + +Resource Functions +------------------ + +Comms +~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_comms + :project: RAFT + :members: + :content-only: + +cuBLAS Handle +~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_cublas + :project: RAFT + :members: + :content-only: + +CUDA Stream +~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_cuda_stream + :project: RAFT + :members: + :content-only: + + +CUDA Stream Pool +~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + +.. doxygengroup:: resource_cuda_stream_pool + :project: RAFT + :members: + :content-only: + +cuSolverDn Handle +~~~~~~~~~~~~~~~~~ + +``#include `` +namespace *raft::resource* + + .. doxygengroup:: resource_cusolver_dn + :project: RAFT + :members: + :content-only: + +cuSolverSp Handle +~~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_cusolver_sp + :project: RAFT + :members: + :content-only: + +cuSparse Handle +~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_cusparse + :project: RAFT + :members: + :content-only: + +Device ID +~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_device_id + :project: RAFT + :members: + :content-only: + + +Device Memory Resource +~~~~~~~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_memory_resource + :project: RAFT + :members: + :content-only: + +Device Properties +~~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_device_props + :project: RAFT + :members: + :content-only: + +Sub Communicators +~~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_sub_comms + :project: RAFT + :members: + :content-only: + +Thrust Exec Policy +~~~~~~~~~~~~~~~~~~ + +``#include `` + +namespace *raft::resource* + + .. doxygengroup:: resource_thrust_policy + :project: RAFT + :members: + :content-only: diff --git a/docs/source/pylibraft_api/common.rst b/docs/source/pylibraft_api/common.rst index 812543f868..527309aa69 100644 --- a/docs/source/pylibraft_api/common.rst +++ b/docs/source/pylibraft_api/common.rst @@ -12,7 +12,7 @@ This page provides `pylibraft` class references for the publicly-exposed element Basic Vocabulary ################ -.. autoclass:: pylibraft.common.Handle +.. autoclass:: pylibraft.common.DeviceResources :members: .. autoclass:: pylibraft.common.Stream diff --git a/python/pylibraft/pylibraft/cluster/cpp/kmeans.pxd b/python/pylibraft/pylibraft/cluster/cpp/kmeans.pxd index 059512990e..c43f18ac3f 100644 --- a/python/pylibraft/pylibraft/cluster/cpp/kmeans.pxd +++ b/python/pylibraft/pylibraft/cluster/cpp/kmeans.pxd @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,14 +27,14 @@ from libcpp cimport bool, nullptr from pylibraft.cluster.cpp.kmeans_types cimport KMeansParams from pylibraft.common.cpp.mdspan cimport * from pylibraft.common.cpp.optional cimport optional -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources cdef extern from "raft_runtime/cluster/kmeans.hpp" \ namespace "raft::runtime::cluster::kmeans" nogil: cdef void update_centroids( - const handle_t& handle, + const device_resources& handle, const double *X, int n_samples, int n_features, @@ -46,7 +46,7 @@ cdef extern from "raft_runtime/cluster/kmeans.hpp" \ double *weight_per_cluster) except + cdef void update_centroids( - const handle_t& handle, + const device_resources& handle, const float *X, int n_samples, int n_features, @@ -58,7 +58,7 @@ cdef extern from "raft_runtime/cluster/kmeans.hpp" \ float *weight_per_cluster) except + cdef void cluster_cost( - const handle_t& handle, + const device_resources& handle, const float* X, int n_samples, int n_features, @@ -67,7 +67,7 @@ cdef extern from "raft_runtime/cluster/kmeans.hpp" \ float * cost) except + cdef void cluster_cost( - const handle_t& handle, + const device_resources& handle, const double* X, int n_samples, int n_features, @@ -76,7 +76,7 @@ cdef extern from "raft_runtime/cluster/kmeans.hpp" \ double * cost) except + cdef void fit( - const handle_t & handle, + const device_resources & handle, const KMeansParams& params, device_matrix_view[float, int, row_major] X, optional[device_vector_view[float, int]] sample_weight, @@ -85,7 +85,7 @@ cdef extern from "raft_runtime/cluster/kmeans.hpp" \ host_scalar_view[int, int] n_iter) except + cdef void fit( - const handle_t & handle, + const device_resources & handle, const KMeansParams& params, device_matrix_view[double, int, row_major] X, optional[device_vector_view[double, int]] sample_weight, diff --git a/python/pylibraft/pylibraft/cluster/kmeans.pyx b/python/pylibraft/pylibraft/cluster/kmeans.pyx index f2e010f6a5..1d0b9ad241 100644 --- a/python/pylibraft/pylibraft/cluster/kmeans.pyx +++ b/python/pylibraft/pylibraft/cluster/kmeans.pyx @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ from enum import IntEnum from pylibraft.common import Handle, cai_wrapper, device_ndarray from pylibraft.common.handle import auto_sync_handle -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.random.cpp.rng_state cimport RngState from pylibraft.common.input_validation import * @@ -43,7 +43,7 @@ from pylibraft.cluster.cpp.kmeans cimport ( ) from pylibraft.common.cpp.mdspan cimport * from pylibraft.common.cpp.optional cimport optional -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.common import auto_convert_output @@ -159,7 +159,7 @@ def compute_new_centroids(X, weight_per_cluster_ptr = nullptr handle = handle if handle is not None else Handle() - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() x_c_contiguous = is_c_contiguous(x_cai) centroids_c_contiguous = is_c_contiguous(centroids_cai) @@ -250,7 +250,7 @@ def cluster_cost(X, centroids, handle=None): centroids_ptr = centroids_cai["data"][0] handle = handle if handle is not None else Handle() - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() x_c_contiguous = is_c_contiguous(x_cai) centroids_c_contiguous = is_c_contiguous(centroids_cai) @@ -452,7 +452,7 @@ def fit( >>> params = KMeansParams(n_clusters=n_clusters) >>> centroids, inertia, n_iter = fit(params, X) """ - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() cdef float f_inertia = 0.0 cdef double d_inertia = 0.0 diff --git a/python/pylibraft/pylibraft/common/__init__.py b/python/pylibraft/pylibraft/common/__init__.py index f8f9b58426..0385ae0899 100644 --- a/python/pylibraft/pylibraft/common/__init__.py +++ b/python/pylibraft/pylibraft/common/__init__.py @@ -17,7 +17,7 @@ from .cai_wrapper import cai_wrapper from .cuda import Stream from .device_ndarray import device_ndarray -from .handle import Handle +from .handle import DeviceResources, Handle from .outputs import auto_convert_output -__all__ = ["Handle", "Stream"] +__all__ = ["DeviceResources", "Handle", "Stream"] diff --git a/python/pylibraft/pylibraft/common/handle.pxd b/python/pylibraft/pylibraft/common/handle.pxd index e763768eac..c090663547 100644 --- a/python/pylibraft/pylibraft/common/handle.pxd +++ b/python/pylibraft/pylibraft/common/handle.pxd @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ from rmm._lib.cuda_stream_pool cimport cuda_stream_pool from rmm._lib.cuda_stream_view cimport cuda_stream_view +# Keeping `handle_t` around for backwards compatibility at the +# cython layer but users are encourage to switch to device_resources cdef extern from "raft/core/handle.hpp" namespace "raft" nogil: cdef cppclass handle_t: handle_t() except + @@ -35,7 +37,17 @@ cdef extern from "raft/core/handle.hpp" namespace "raft" nogil: cuda_stream_view get_stream() except + void sync_stream() except + -cdef class Handle: - cdef unique_ptr[handle_t] c_obj + +cdef extern from "raft/core/device_resources.hpp" namespace "raft" nogil: + cdef cppclass device_resources: + device_resources() except + + device_resources(cuda_stream_view stream_view) except + + device_resources(cuda_stream_view stream_view, + shared_ptr[cuda_stream_pool] stream_pool) except + + cuda_stream_view get_stream() except + + void sync_stream() except + + +cdef class DeviceResources: + cdef unique_ptr[device_resources] c_obj cdef shared_ptr[cuda_stream_pool] stream_pool cdef int n_streams diff --git a/python/pylibraft/pylibraft/common/handle.pyx b/python/pylibraft/pylibraft/common/handle.pyx index 2821cb7f8a..b4cdb9b0c1 100644 --- a/python/pylibraft/pylibraft/common/handle.pyx +++ b/python/pylibraft/pylibraft/common/handle.pyx @@ -31,11 +31,12 @@ from .cuda cimport Stream from .cuda import CudaRuntimeError -cdef class Handle: +cdef class DeviceResources: """ - Handle is a lightweight python wrapper around the corresponding C++ class - of handle_t exposed by RAFT's C++ interface. Refer to the header file - raft/handle.hpp for interface level details of this struct + DeviceResources is a lightweight python wrapper around the corresponding + C++ class of device_resources exposed by RAFT's C++ interface. Refer to + the header file raft/core/device_resources.hpp for interface level + details of this struct Parameters ---------- @@ -46,26 +47,29 @@ cdef class Handle: -------- Basic usage: - >>> from pylibraft.common import Stream, Handle + + >>> from pylibraft.common import Stream, DeviceResources >>> stream = Stream() - >>> handle = Handle(stream) + >>> handle = DeviceResources(stream) >>> >>> # call algos here >>> >>> # final sync of all work launched in the stream of this handle >>> # this is same as `raft.cuda.Stream.sync()` call, but safer in case - >>> # the default stream inside the `handle_t` is being used + >>> # the default stream inside the `device_resources` is being used >>> handle.sync() >>> del handle # optional! - Using a cuPy stream with RAFT handle: + Using a cuPy stream with RAFT device_resources: + >>> import cupy - >>> from pylibraft.common import Stream, Handle + >>> from pylibraft.common import Stream, DeviceResources >>> >>> cupy_stream = cupy.cuda.Stream() - >>> handle = Handle(stream=cupy_stream.ptr) + >>> handle = DeviceResources(stream=cupy_stream.ptr) Using a RAFT stream with CuPy ExternalStream: + >>> import cupy >>> from pylibraft.common import Stream >>> @@ -108,16 +112,81 @@ cdef class Handle: def sync(self): """ - Issues a sync on the stream set for this handle. + Issues a sync on the stream set for this instance. """ self.c_obj.get()[0].sync_stream() def getHandle(self): + """ + Return the pointer to the underlying raft::device_resources + instance as a size_t + """ return self.c_obj.get() def __getstate__(self): return self.n_streams + def __setstate__(self, state): + self.n_streams = state + if self.n_streams > 0: + self.stream_pool.reset(new cuda_stream_pool(self.n_streams)) + + self.c_obj.reset(new device_resources(cuda_stream_per_thread, + self.stream_pool)) + + +cdef class Handle(DeviceResources): + """ + Handle is a lightweight python wrapper around the corresponding + C++ class of handle_t exposed by RAFT's C++ interface. Refer to + the header file raft/core/handle.hpp for interface level + details of this struct + + Note: This API is officially deprecated in favor of DeviceResources + and will be removed in a future release. + + Parameters + ---------- + stream : Optional stream to use for ordering CUDA instructions + Accepts pylibraft.common.Stream() or uintptr_t (cudaStream_t) + + Examples + -------- + + Basic usage: + + >>> from pylibraft.common import Stream, Handle + >>> stream = Stream() + >>> handle = Handle(stream) + >>> + >>> # call algos here + >>> + >>> # final sync of all work launched in the stream of this handle + >>> # this is same as `raft.cuda.Stream.sync()` call, but safer in case + >>> # the default stream inside the `handle_t` is being used + >>> handle.sync() + >>> del handle # optional! + + Using a cuPy stream with RAFT device_resources: + + >>> import cupy + >>> from pylibraft.common import Stream, Handle + >>> + >>> cupy_stream = cupy.cuda.Stream() + >>> handle = Handle(stream=cupy_stream.ptr) + + Using a RAFT stream with CuPy ExternalStream: + + >>> import cupy + >>> from pylibraft.common import Stream + >>> + >>> raft_stream = Stream() + >>> cupy_stream = cupy.cuda.ExternalStream(raft_stream.get_ptr()) + + """ + def __getstate__(self): + return self.n_streams + def __setstate__(self, state): self.n_streams = state if self.n_streams > 0: @@ -128,11 +197,12 @@ cdef class Handle: _HANDLE_PARAM_DOCSTRING = """ - handle : Optional RAFT handle for reusing expensive CUDA resources - If a handle isn't supplied, CUDA resources will be allocated - inside this function and synchronized before the function exits. - If a handle is supplied, you will need to explicitly synchronize - yourself by calling `handle.sync()` before accessing the output. + handle : Optional RAFT resource handle for reusing expensive CUDA + resources. If a handle isn't supplied, CUDA resources will be + allocated inside this function and synchronized before the + function exits. If a handle is supplied, you will need to + explicitly synchronize yourself by calling `handle.sync()` + before accessing the output. """.strip() @@ -150,7 +220,7 @@ def auto_sync_handle(f): @functools.wraps(f) def wrapper(*args, handle=None, **kwargs): sync_handle = handle is None - handle = handle if handle is not None else Handle() + handle = handle if handle is not None else DeviceResources() ret_value = f(*args, handle=handle, **kwargs) diff --git a/python/pylibraft/pylibraft/distance/fused_l2_nn.pyx b/python/pylibraft/pylibraft/distance/fused_l2_nn.pyx index ce8e656822..c8e7101ee0 100644 --- a/python/pylibraft/pylibraft/distance/fused_l2_nn.pyx +++ b/python/pylibraft/pylibraft/distance/fused_l2_nn.pyx @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,14 +34,14 @@ from pylibraft.common import ( ) from pylibraft.common.handle import auto_sync_handle -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources cdef extern from "raft_runtime/distance/fused_l2_nn.hpp" \ namespace "raft::runtime::distance" nogil: void fused_l2_nn_min_arg( - const handle_t &handle, + const device_resources &handle, int* min, const float* x, const float* y, @@ -51,7 +51,7 @@ cdef extern from "raft_runtime/distance/fused_l2_nn.hpp" \ bool sqrt) except + void fused_l2_nn_min_arg( - const handle_t &handle, + const device_resources &handle, int* min, const double* x, const double* y, @@ -154,7 +154,7 @@ def fused_l2_nn_argmin(X, Y, out=None, sqrt=True, handle=None): d_ptr = output_cai.data handle = handle if handle is not None else Handle() - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() d_dt = output_cai.dtype diff --git a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx index 2ed2b8ed57..9649531b61 100644 --- a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx +++ b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ from .distance_type cimport DistanceType from pylibraft.common import Handle from pylibraft.common.handle import auto_sync_handle -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.common import auto_convert_output, cai_wrapper, device_ndarray @@ -37,7 +37,7 @@ from pylibraft.common import auto_convert_output, cai_wrapper, device_ndarray cdef extern from "raft_runtime/distance/pairwise_distance.hpp" \ namespace "raft::runtime::distance" nogil: - cdef void pairwise_distance(const handle_t &handle, + cdef void pairwise_distance(const device_resources &handle, float *x, float *y, float *dists, @@ -48,7 +48,7 @@ cdef extern from "raft_runtime/distance/pairwise_distance.hpp" \ bool isRowMajor, float metric_arg) except + - cdef void pairwise_distance(const handle_t &handle, + cdef void pairwise_distance(const device_resources &handle, double *x, double *y, double *dists, @@ -196,7 +196,7 @@ def distance(X, Y, out=None, metric="euclidean", p=2.0, handle=None): d_ptr = dists_cai.data handle = handle if handle is not None else Handle() - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() d_dt = dists_cai.dtype diff --git a/python/pylibraft/pylibraft/neighbors/ivf_pq/cpp/c_ivf_pq.pxd b/python/pylibraft/pylibraft/neighbors/ivf_pq/cpp/c_ivf_pq.pxd index 1b8076487d..3a286868bf 100644 --- a/python/pylibraft/pylibraft/neighbors/ivf_pq/cpp/c_ivf_pq.pxd +++ b/python/pylibraft/pylibraft/neighbors/ivf_pq/cpp/c_ivf_pq.pxd @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ from libcpp.string cimport string from rmm._lib.memory_resource cimport device_memory_resource -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.distance.distance_type cimport DistanceType @@ -80,7 +80,7 @@ cdef extern from "raft/neighbors/ivf_pq_types.hpp" \ bool force_random_rotation cdef cppclass index[IdxT](ann_index): - index(const handle_t& handle, + index(const device_resources& handle, DistanceType metric, codebook_gen codebook_kind, uint32_t n_lists, @@ -108,46 +108,46 @@ cdef extern from "raft/neighbors/ivf_pq_types.hpp" \ cdef extern from "raft_runtime/neighbors/ivf_pq.hpp" \ namespace "raft::runtime::neighbors::ivf_pq" nogil: - cdef void build(const handle_t& handle, + cdef void build(const device_resources& handle, const index_params& params, const float* dataset, uint64_t n_rows, uint32_t dim, index[uint64_t]* index) except + - cdef void build(const handle_t& handle, + cdef void build(const device_resources& handle, const index_params& params, const int8_t* dataset, uint64_t n_rows, uint32_t dim, index[uint64_t]* index) except + - cdef void build(const handle_t& handle, + cdef void build(const device_resources& handle, const index_params& params, const uint8_t* dataset, uint64_t n_rows, uint32_t dim, index[uint64_t]* index) except + - cdef void extend(const handle_t& handle, + cdef void extend(const device_resources& handle, index[uint64_t]* index, const float* new_vectors, const uint64_t* new_indices, uint64_t n_rows) except + - cdef void extend(const handle_t& handle, + cdef void extend(const device_resources& handle, index[uint64_t]* index, const int8_t* new_vectors, const uint64_t* new_indices, uint64_t n_rows) except + - cdef void extend(const handle_t& handle, + cdef void extend(const device_resources& handle, index[uint64_t]* index, const uint8_t* new_vectors, const uint64_t* new_indices, uint64_t n_rows) except + - cdef void search(const handle_t& handle, + cdef void search(const device_resources& handle, const search_params& params, const index[uint64_t]& index, const float* queries, @@ -157,7 +157,7 @@ cdef extern from "raft_runtime/neighbors/ivf_pq.hpp" \ float* distances, device_memory_resource* mr) except + - cdef void search(const handle_t& handle, + cdef void search(const device_resources& handle, const search_params& params, const index[uint64_t]& index, const int8_t* queries, @@ -167,7 +167,7 @@ cdef extern from "raft_runtime/neighbors/ivf_pq.hpp" \ float* distances, device_memory_resource* mr) except + - cdef void search(const handle_t& handle, + cdef void search(const device_resources& handle, const search_params& params, const index[uint64_t]& index, const uint8_t* queries, @@ -177,10 +177,10 @@ cdef extern from "raft_runtime/neighbors/ivf_pq.hpp" \ float* distances, device_memory_resource* mr) except + - cdef void save(const handle_t& handle, + cdef void save(const device_resources& handle, const string& filename, const index[uint64_t]& index) except + - cdef void load(const handle_t& handle, + cdef void load(const device_resources& handle, const string& filename, index[uint64_t]* index) except + diff --git a/python/pylibraft/pylibraft/neighbors/ivf_pq/ivf_pq.pyx b/python/pylibraft/pylibraft/neighbors/ivf_pq/ivf_pq.pyx index 8f8a49fb63..42f508c969 100644 --- a/python/pylibraft/pylibraft/neighbors/ivf_pq/ivf_pq.pyx +++ b/python/pylibraft/pylibraft/neighbors/ivf_pq/ivf_pq.pyx @@ -37,7 +37,7 @@ from libcpp.string cimport string from pylibraft.distance.distance_type cimport DistanceType from pylibraft.common import ( - Handle, + DeviceResources, ai_wrapper, auto_convert_output, cai_wrapper, @@ -46,7 +46,7 @@ from pylibraft.common import ( from pylibraft.common.cai_wrapper import wrap_array from pylibraft.common.interruptible import cuda_interruptible -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.common.handle import auto_sync_handle from pylibraft.common.input_validation import is_c_contiguous @@ -252,8 +252,9 @@ cdef class Index: self.trained = False self.index = NULL if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() # We create a placeholder object. The actual parameter values do # not matter, it will be replaced with a built index object later. @@ -342,7 +343,7 @@ def build(IndexParams index_params, dataset, handle=None): >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq >>> n_samples = 50000 @@ -351,7 +352,7 @@ def build(IndexParams index_params, dataset, handle=None): >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) - >>> handle = Handle() + >>> handle = DeviceResources() >>> index_params = ivf_pq.IndexParams( ... n_lists=1024, ... metric="sqeuclidean", @@ -382,8 +383,9 @@ def build(IndexParams index_params, dataset, handle=None): cdef uint32_t dim = dataset_cai.shape[1] if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() idx = Index() @@ -448,7 +450,7 @@ def extend(Index index, new_vectors, new_indices, handle=None): >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq >>> n_samples = 50000 @@ -457,7 +459,7 @@ def extend(Index index, new_vectors, new_indices, handle=None): >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) - >>> handle = Handle() + >>> handle = DeviceResources() >>> index = ivf_pq.build(ivf_pq.IndexParams(), dataset, handle=handle) >>> n_rows = 100 @@ -485,8 +487,9 @@ def extend(Index index, new_vectors, new_indices, handle=None): raise ValueError("Index need to be built before calling extend.") if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() vecs_cai = wrap_array(new_vectors) vecs_dt = vecs_cai.dtype @@ -626,7 +629,7 @@ def search(SearchParams search_params, -------- >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq >>> n_samples = 50000 @@ -636,7 +639,7 @@ def search(SearchParams search_params, ... dtype=cp.float32) >>> # Build index - >>> handle = Handle() + >>> handle = DeviceResources() >>> index = ivf_pq.build(ivf_pq.IndexParams(), dataset, handle=handle) >>> # Search using the built index @@ -674,8 +677,9 @@ def search(SearchParams search_params, raise ValueError("Index need to be built before calling search.") if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() queries_cai = cai_wrapper(queries) queries_dt = queries_cai.dtype @@ -768,7 +772,7 @@ def save(filename, Index index, handle=None): -------- >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq >>> n_samples = 50000 @@ -777,7 +781,7 @@ def save(filename, Index index, handle=None): ... dtype=cp.float32) >>> # Build index - >>> handle = Handle() + >>> handle = DeviceResources() >>> index = ivf_pq.build(ivf_pq.IndexParams(), dataset, handle=handle) >>> ivf_pq.save("my_index.bin", index, handle=handle) """ @@ -785,8 +789,9 @@ def save(filename, Index index, handle=None): raise ValueError("Index need to be built before saving it.") if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() cdef string c_filename = filename.encode('utf-8') @@ -816,7 +821,7 @@ def load(filename, handle=None): -------- >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq >>> n_samples = 50000 @@ -825,7 +830,7 @@ def load(filename, handle=None): ... dtype=cp.float32) >>> # Build and save index - >>> handle = Handle() + >>> handle = DeviceResources() >>> index = ivf_pq.build(ivf_pq.IndexParams(), dataset, handle=handle) >>> ivf_pq.save("my_index.bin", index, handle=handle) >>> del index @@ -833,15 +838,16 @@ def load(filename, handle=None): >>> n_queries = 100 >>> queries = cp.random.random_sample((n_queries, n_features), ... dtype=cp.float32) - >>> handle = Handle() + >>> handle = DeviceResources() >>> index = ivf_pq.load("my_index.bin", handle=handle) >>> distances, neighbors = ivf_pq.search(ivf_pq.SearchParams(), index, ... queries, k=10, handle=handle) """ if handle is None: - handle = Handle() - cdef handle_t* handle_ = handle.getHandle() + handle = DeviceResources() + cdef device_resources* handle_ = \ + handle.getHandle() cdef string c_filename = filename.encode('utf-8') index = Index() diff --git a/python/pylibraft/pylibraft/neighbors/refine.pyx b/python/pylibraft/pylibraft/neighbors/refine.pyx index b8f1bd0caa..5c652f7c73 100644 --- a/python/pylibraft/pylibraft/neighbors/refine.pyx +++ b/python/pylibraft/pylibraft/neighbors/refine.pyx @@ -34,13 +34,13 @@ from libcpp cimport bool, nullptr from pylibraft.distance.distance_type cimport DistanceType from pylibraft.common import ( - Handle, + DeviceResources, auto_convert_output, cai_wrapper, device_ndarray, ) -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.common.handle import auto_sync_handle from pylibraft.common.input_validation import is_c_contiguous @@ -71,7 +71,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ namespace "raft::runtime::neighbors" nogil: cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, device_matrix_view[float, uint64_t, row_major] dataset, device_matrix_view[float, uint64_t, row_major] queries, device_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -80,7 +80,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ DistanceType metric) except + cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, device_matrix_view[uint8_t, uint64_t, row_major] dataset, device_matrix_view[uint8_t, uint64_t, row_major] queries, device_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -89,7 +89,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ DistanceType metric) except + cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, device_matrix_view[int8_t, uint64_t, row_major] dataset, device_matrix_view[int8_t, uint64_t, row_major] queries, device_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -98,7 +98,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ DistanceType metric) except + cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, host_matrix_view[float, uint64_t, row_major] dataset, host_matrix_view[float, uint64_t, row_major] queries, host_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -107,7 +107,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ DistanceType metric) except + cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, host_matrix_view[uint8_t, uint64_t, row_major] dataset, host_matrix_view[uint8_t, uint64_t, row_major] queries, host_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -116,7 +116,7 @@ cdef extern from "raft_runtime/neighbors/refine.hpp" \ DistanceType metric) except + cdef void c_refine "raft::runtime::neighbors::refine" ( - const handle_t& handle, + const device_resources& handle, host_matrix_view[int8_t, uint64_t, row_major] dataset, host_matrix_view[int8_t, uint64_t, row_major] queries, host_matrix_view[uint64_t, uint64_t, row_major] candidates, @@ -261,7 +261,7 @@ def refine(dataset, queries, candidates, k=None, indices=None, distances=None, >>> import cupy as cp - >>> from pylibraft.common import Handle + >>> from pylibraft.common import DeviceResources >>> from pylibraft.neighbors import ivf_pq, refine >>> n_samples = 50000 @@ -270,7 +270,7 @@ def refine(dataset, queries, candidates, k=None, indices=None, distances=None, >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) - >>> handle = Handle() + >>> handle = DeviceResources() >>> index_params = ivf_pq.IndexParams(n_lists=1024, metric="sqeuclidean", ... pq_dim=10) >>> index = ivf_pq.build(index_params, dataset, handle=handle) @@ -294,7 +294,7 @@ def refine(dataset, queries, candidates, k=None, indices=None, distances=None, """ if handle is None: - handle = Handle() + handle = DeviceResources() if hasattr(dataset, "__cuda_array_interface__"): return _refine_device(dataset, queries, candidates, k, indices, @@ -306,7 +306,8 @@ def refine(dataset, queries, candidates, k=None, indices=None, distances=None, def _refine_device(dataset, queries, candidates, k, indices, distances, metric, handle): - cdef handle_t* handle_ = handle.getHandle() + cdef device_resources* handle_ = \ + handle.getHandle() cdef device_matrix_view[uint64_t, uint64_t, row_major] candidates_view = \ get_device_matrix_view_uint64(candidates) @@ -367,7 +368,8 @@ def _refine_device(dataset, queries, candidates, k, indices, distances, def _refine_host(dataset, queries, candidates, k, indices, distances, metric, handle): - cdef handle_t* handle_ = handle.getHandle() + cdef device_resources* handle_ = \ + handle.getHandle() if k is None: if indices is not None: diff --git a/python/pylibraft/pylibraft/random/rmat_rectangular_generator.pyx b/python/pylibraft/pylibraft/random/rmat_rectangular_generator.pyx index 56d6ced468..2c7e0430b4 100644 --- a/python/pylibraft/pylibraft/random/rmat_rectangular_generator.pyx +++ b/python/pylibraft/pylibraft/random/rmat_rectangular_generator.pyx @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,14 +28,14 @@ from pylibraft.common.handle import auto_sync_handle from libcpp cimport bool -from pylibraft.common.handle cimport handle_t +from pylibraft.common.handle cimport device_resources from pylibraft.random.cpp.rng_state cimport RngState cdef extern from "raft_runtime/random/rmat_rectangular_generator.hpp" \ namespace "raft::runtime::random" nogil: - cdef void rmat_rectangular_gen(const handle_t &handle, + cdef void rmat_rectangular_gen(const device_resources &handle, int* out, int* out_src, int* out_dst, @@ -45,7 +45,7 @@ cdef extern from "raft_runtime/random/rmat_rectangular_generator.hpp" \ int n_edges, RngState& r) except + - cdef void rmat_rectangular_gen(const handle_t &handle, + cdef void rmat_rectangular_gen(const device_resources &handle, int64_t* out, int64_t* out_src, int64_t* out_dst, @@ -55,7 +55,7 @@ cdef extern from "raft_runtime/random/rmat_rectangular_generator.hpp" \ int64_t n_edges, RngState& r) except + - cdef void rmat_rectangular_gen(const handle_t &handle, + cdef void rmat_rectangular_gen(const device_resources &handle, int* out, int* out_src, int* out_dst, @@ -65,7 +65,7 @@ cdef extern from "raft_runtime/random/rmat_rectangular_generator.hpp" \ int n_edges, RngState& r) except + - cdef void rmat_rectangular_gen(const handle_t &handle, + cdef void rmat_rectangular_gen(const device_resources &handle, int64_t* out, int64_t* out_src, int64_t* out_dst, @@ -138,7 +138,7 @@ def rmat(out, theta, r_scale, c_scale, seed=12345, handle=None): cdef RngState *rng = new RngState(seed) handle = handle if handle is not None else Handle() - cdef handle_t *h = handle.getHandle() + cdef device_resources *h = handle.getHandle() if out_dt == np.int32 and theta_dt == np.float32: rmat_rectangular_gen(deref(h), diff --git a/python/pylibraft/pylibraft/test/test_distance.py b/python/pylibraft/pylibraft/test/test_distance.py index 9c8a608f6e..dd6050a098 100644 --- a/python/pylibraft/pylibraft/test/test_distance.py +++ b/python/pylibraft/pylibraft/test/test_distance.py @@ -17,7 +17,7 @@ import pytest from scipy.spatial.distance import cdist -from pylibraft.common import Handle, Stream, device_ndarray +from pylibraft.common import DeviceResources, Stream, device_ndarray from pylibraft.distance import pairwise_distance @@ -65,7 +65,7 @@ def test_distance(n_rows, n_cols, inplace, metric, order, dtype): output_device = device_ndarray(output) if inplace else None s2 = Stream() - handle = Handle(stream=s2) + handle = DeviceResources(stream=s2) ret_output = pairwise_distance( input1_device, input1_device, output_device, metric, handle=handle ) diff --git a/python/pylibraft/pylibraft/test/test_fused_l2_argmin.py b/python/pylibraft/pylibraft/test/test_fused_l2_argmin.py index b05ad3d530..086bb26f17 100644 --- a/python/pylibraft/pylibraft/test/test_fused_l2_argmin.py +++ b/python/pylibraft/pylibraft/test/test_fused_l2_argmin.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import pytest from scipy.spatial.distance import cdist -from pylibraft.common import Handle, device_ndarray +from pylibraft.common import DeviceResources, device_ndarray from pylibraft.distance import fused_l2_nn_argmin @@ -42,7 +42,7 @@ def test_fused_l2_nn_minarg(n_rows, n_cols, n_clusters, dtype, inplace): input2_device = device_ndarray(input2) output_device = device_ndarray(output) if inplace else None - handle = Handle() + handle = DeviceResources() ret_output = fused_l2_nn_argmin( input1_device, input2_device, output_device, True, handle=handle ) diff --git a/python/pylibraft/pylibraft/test/test_handle.py b/python/pylibraft/pylibraft/test/test_handle.py index 877bf442f8..ae519ea965 100644 --- a/python/pylibraft/pylibraft/test/test_handle.py +++ b/python/pylibraft/pylibraft/test/test_handle.py @@ -16,7 +16,7 @@ import numpy as np import pytest -from pylibraft.common import Handle, Stream, device_ndarray +from pylibraft.common import DeviceResources, Stream, device_ndarray from pylibraft.distance import pairwise_distance try: @@ -37,11 +37,11 @@ def test_handle_external_stream(stream): output_device = device_ndarray(output) # We are just testing that this doesn't segfault - handle = Handle(stream) + handle = DeviceResources(stream) pairwise_distance( input1_device, input1_device, output_device, "euclidean", handle=handle ) handle.sync() with pytest.raises(ValueError): - handle = Handle(stream=1.0) + handle = DeviceResources(stream=1.0) diff --git a/python/pylibraft/pylibraft/test/test_kmeans.py b/python/pylibraft/pylibraft/test/test_kmeans.py index e5e544d565..4c2388de62 100644 --- a/python/pylibraft/pylibraft/test/test_kmeans.py +++ b/python/pylibraft/pylibraft/test/test_kmeans.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ compute_new_centroids, fit, ) -from pylibraft.common import Handle, device_ndarray +from pylibraft.common import DeviceResources, device_ndarray from pylibraft.distance import pairwise_distance @@ -64,7 +64,7 @@ def test_compute_new_centroids( # A single RAFT handle can optionally be reused across # pylibraft functions. - handle = Handle() + handle = DeviceResources() X = np.random.random_sample((n_rows, n_cols)).astype(dtype) X_device = device_ndarray(X) diff --git a/python/pylibraft/pylibraft/test/test_random.py b/python/pylibraft/pylibraft/test/test_random.py index 229baffff5..76c0f53d3e 100644 --- a/python/pylibraft/pylibraft/test/test_random.py +++ b/python/pylibraft/pylibraft/test/test_random.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ import numpy as np import pytest -from pylibraft.common import Handle, device_ndarray +from pylibraft.common import DeviceResources, device_ndarray from pylibraft.random import rmat @@ -46,7 +46,7 @@ def test_rmat(n_edges, r_scale, c_scale, dtype): out_buff = np.empty((n_edges, 2), dtype=dtype) output_device = device_ndarray(out_buff) - handle = Handle() + handle = DeviceResources() rmat(output_device, theta_device, r_scale, c_scale, 12345, handle=handle) handle.sync() output = output_device.copy_to_host() diff --git a/python/raft-dask/raft_dask/common/comms_utils.pyx b/python/raft-dask/raft_dask/common/comms_utils.pyx index 7db04ef455..768ba0e422 100644 --- a/python/raft-dask/raft_dask/common/comms_utils.pyx +++ b/python/raft-dask/raft_dask/common/comms_utils.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2022, NVIDIA CORPORATION. +# Copyright (c) 2019-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,41 +30,49 @@ cdef extern from "nccl.h": ctypedef ncclComm *ncclComm_t cdef extern from "raft/core/handle.hpp" namespace "raft": - cdef cppclass handle_t: - handle_t() except + + cdef cppclass device_resources: + device_resources() except + + +cdef extern from "raft/core/device_resources.hpp" namespace "raft": + cdef cppclass device_resources: + device_resources() except + cdef extern from "raft/comms/std_comms.hpp" namespace "raft::comms": - void build_comms_nccl_ucx(handle_t *handle, + void build_comms_nccl_ucx(device_resources *handle, ncclComm_t comm, void *ucp_worker, void *eps, int size, int rank) except + - void build_comms_nccl_only(handle_t *handle, + void build_comms_nccl_only(device_resources *handle, ncclComm_t comm, int size, int rank) except + cdef extern from "raft/comms/comms_test.hpp" namespace "raft::comms": - bool test_collective_allreduce(const handle_t &h, int root) except + - bool test_collective_broadcast(const handle_t &h, int root) except + - bool test_collective_reduce(const handle_t &h, int root) except + - bool test_collective_allgather(const handle_t &h, int root) except + - bool test_collective_gather(const handle_t &h, int root) except + - bool test_collective_gatherv(const handle_t &h, int root) except + - bool test_collective_reducescatter(const handle_t &h, int root) except + - bool test_pointToPoint_simple_send_recv(const handle_t &h, + bool test_collective_allreduce(const device_resources &h, int root) \ + except + + bool test_collective_broadcast(const device_resources &h, int root) \ + except + + bool test_collective_reduce(const device_resources &h, int root) except + + bool test_collective_allgather(const device_resources &h, int root) \ + except + + bool test_collective_gather(const device_resources &h, int root) except + + bool test_collective_gatherv(const device_resources &h, int root) except + + bool test_collective_reducescatter(const device_resources &h, int root) \ + except + + bool test_pointToPoint_simple_send_recv(const device_resources &h, int numTrials) except + - bool test_pointToPoint_device_send_or_recv(const handle_t &h, + bool test_pointToPoint_device_send_or_recv(const device_resources &h, int numTrials) except + - bool test_pointToPoint_device_sendrecv(const handle_t &h, + bool test_pointToPoint_device_sendrecv(const device_resources &h, int numTrials) except + - bool test_pointToPoint_device_multicast_sendrecv(const handle_t &h, + bool test_pointToPoint_device_multicast_sendrecv(const device_resources &h, int numTrials) except + - bool test_commsplit(const handle_t &h, int n_colors) except + + bool test_commsplit(const device_resources &h, int n_colors) except + def perform_test_comms_allreduce(handle, root): @@ -76,7 +84,8 @@ def perform_test_comms_allreduce(handle, root): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_allreduce(deref(h), root) @@ -89,7 +98,8 @@ def perform_test_comms_reduce(handle, root): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_reduce(deref(h), root) @@ -102,7 +112,8 @@ def perform_test_comms_reducescatter(handle, root): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_reducescatter(deref(h), root) @@ -115,7 +126,8 @@ def perform_test_comms_bcast(handle, root): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_broadcast(deref(h), root) @@ -128,7 +140,8 @@ def perform_test_comms_allgather(handle, root): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_allgather(deref(h), root) @@ -143,7 +156,8 @@ def perform_test_comms_gather(handle, root): root : int Rank of the root worker """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_gather(deref(h), root) @@ -158,7 +172,8 @@ def perform_test_comms_gatherv(handle, root): root : int Rank of the root worker """ - cdef const handle_t* h = handle.getHandle() + cdef const device_resources* h = \ + handle.getHandle() return test_collective_gatherv(deref(h), root) @@ -173,7 +188,8 @@ def perform_test_comms_send_recv(handle, n_trials): n_trilas : int Number of test trials """ - cdef const handle_t *h = handle.getHandle() + cdef const device_resources *h = \ + handle.getHandle() return test_pointToPoint_simple_send_recv(deref(h), n_trials) @@ -188,7 +204,8 @@ def perform_test_comms_device_send_or_recv(handle, n_trials): n_trilas : int Number of test trials """ - cdef const handle_t *h = handle.getHandle() + cdef const device_resources *h = \ + handle.getHandle() return test_pointToPoint_device_send_or_recv(deref(h), n_trials) @@ -203,7 +220,8 @@ def perform_test_comms_device_sendrecv(handle, n_trials): n_trilas : int Number of test trials """ - cdef const handle_t *h = handle.getHandle() + cdef const device_resources *h = \ + handle.getHandle() return test_pointToPoint_device_sendrecv(deref(h), n_trials) @@ -218,7 +236,8 @@ def perform_test_comms_device_multicast_sendrecv(handle, n_trials): n_trilas : int Number of test trials """ - cdef const handle_t *h = handle.getHandle() + cdef const device_resources *h = \ + handle.getHandle() return test_pointToPoint_device_multicast_sendrecv(deref(h), n_trials) @@ -231,7 +250,8 @@ def perform_test_comm_split(handle, n_colors): handle : raft.common.Handle handle containing comms_t to use """ - cdef const handle_t * h = < handle_t * > < size_t > handle.getHandle() + cdef const device_resources * h = \ + < device_resources * > < size_t > handle.getHandle() return test_commsplit(deref(h), < int > n_colors) @@ -254,7 +274,7 @@ def inject_comms_on_handle_coll_only(handle, nccl_inst, size, rank, verbose): """ cdef size_t handle_size_t = handle.getHandle() - handle_ = handle_size_t + handle_ = handle_size_t cdef size_t nccl_comm_size_t = nccl_inst.get_comm() nccl_comm_ = nccl_comm_size_t @@ -296,7 +316,7 @@ def inject_comms_on_handle(handle, nccl_inst, ucp_worker, eps, size, cdef void* ucp_worker_st = ucp_worker cdef size_t handle_size_t = handle.getHandle() - handle_ = handle_size_t + handle_ = handle_size_t cdef size_t nccl_comm_size_t = nccl_inst.get_comm() nccl_comm_ = nccl_comm_size_t diff --git a/python/raft-dask/setup.cfg b/python/raft-dask/setup.cfg index 3f563289c4..e218f00c3e 100644 --- a/python/raft-dask/setup.cfg +++ b/python/raft-dask/setup.cfg @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. [versioneer] VCS = git