diff --git a/cpp/src/neighbors/detail/knn_brute_force.cuh b/cpp/src/neighbors/detail/knn_brute_force.cuh index f1976e002..b450afcd2 100644 --- a/cpp/src/neighbors/detail/knn_brute_force.cuh +++ b/cpp/src/neighbors/detail/knn_brute_force.cuh @@ -266,11 +266,13 @@ void tiled_brute_force_knn(const raft::resources& handle, }); } + std::optional> + null_optional = std::nullopt; cuvs::selection::select_k( handle, raft::make_device_matrix_view( temp_distances.data(), current_query_size, current_centroid_size), - std::nullopt, + null_optional, raft::make_device_matrix_view( distances + i * k, current_query_size, current_k), raft::make_device_matrix_view( diff --git a/cpp/src/neighbors/detail/reachability.cuh b/cpp/src/neighbors/detail/reachability.cuh index 903c6f1da..ead63ac86 100644 --- a/cpp/src/neighbors/detail/reachability.cuh +++ b/cpp/src/neighbors/detail/reachability.cuh @@ -186,17 +186,17 @@ void mutual_reachability_knn_l2(const raft::resources& handle, epilogue); } -template +template void mutual_reachability_graph(const raft::resources& handle, const value_t* X, - size_t m, - size_t n, + value_idx m, + value_idx n, cuvs::distance::DistanceType metric, int min_samples, value_t alpha, value_idx* indptr, value_t* core_dists, - raft::sparse::COO& out) + raft::sparse::COO& out) { RAFT_EXPECTS(metric == cuvs::distance::DistanceType::L2SqrtExpanded, "Currently only L2 expanded distance is supported"); @@ -228,8 +228,14 @@ void mutual_reachability_graph(const raft::resources& handle, coo_rows.data(), [min_samples] __device__(value_idx c) -> value_idx { return c / min_samples; }); - raft::sparse::linalg::symmetrize( - handle, coo_rows.data(), inds.data(), dists.data(), m, m, min_samples * m, out); + raft::sparse::linalg::symmetrize(handle, + coo_rows.data(), + inds.data(), + dists.data(), + m, + m, + static_cast(min_samples * m), + out); raft::sparse::convert::sorted_coo_to_csr(out.rows(), out.nnz, indptr, m + 1, stream); diff --git a/cpp/src/neighbors/reachability.cu b/cpp/src/neighbors/reachability.cu index 2e366106c..c90009ab2 100644 --- a/cpp/src/neighbors/reachability.cu +++ b/cpp/src/neighbors/reachability.cu @@ -25,7 +25,7 @@ void mutual_reachability_graph(const raft::resources& handle, int min_samples, raft::device_vector_view indptr, raft::device_vector_view core_dists, - raft::sparse::COO& out, + raft::sparse::COO& out, cuvs::distance::DistanceType metric, float alpha) { @@ -34,7 +34,7 @@ void mutual_reachability_graph(const raft::resources& handle, RAFT_EXPECTS(indptr.extent(0) == static_cast(X.extent(0) + 1), "indptr doesn't have expected size"); - cuvs::neighbors::detail::reachability::mutual_reachability_graph( + cuvs::neighbors::detail::reachability::mutual_reachability_graph( handle, X.data_handle(), X.extent(0), diff --git a/cpp/src/sparse/cluster/detail/spectral.cuh b/cpp/src/sparse/cluster/detail/spectral.cuh index 3d44bd4a2..b5aa5139e 100644 --- a/cpp/src/sparse/cluster/detail/spectral.cuh +++ b/cpp/src/sparse/cluster/detail/spectral.cuh @@ -56,12 +56,13 @@ void fit_embedding(raft::resources const& handle, */ using index_type = int; using value_type = T; + using nnz_type = int; index_type* ro = src_offsets.data(); index_type* ci = dst_cols.data(); value_type* vs = dst_vals.data(); - raft::spectral::matrix::sparse_matrix_t const r_csr_m{ + raft::spectral::matrix::sparse_matrix_t const r_csr_m{ handle, ro, ci, vs, n, nnz}; index_type neigvs = n_components + 1; diff --git a/cpp/src/sparse/cluster/detail/spectral/partition.hpp b/cpp/src/sparse/cluster/detail/spectral/partition.hpp index 77e83c17d..d0ea793f5 100644 --- a/cpp/src/sparse/cluster/detail/spectral/partition.hpp +++ b/cpp/src/sparse/cluster/detail/spectral/partition.hpp @@ -66,10 +66,14 @@ namespace detail { * performed. * @return statistics: number of eigensolver iterations, . */ -template +template std::tuple partition( raft::resources const& handle, - raft::spectral::matrix::sparse_matrix_t const& csr_m, + raft::spectral::matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, vertex_t* __restrict__ clusters, @@ -97,7 +101,7 @@ std::tuple partition( // Initialize Laplacian /// sparse_matrix_t A{handle, graph}; - raft::spectral::matrix::laplacian_matrix_t L{handle, csr_m}; + raft::spectral::matrix::laplacian_matrix_t L{handle, csr_m}; auto eigen_config = eigen_solver.get_config(); auto nEigVecs = eigen_config.n_eigVecs; @@ -135,13 +139,14 @@ std::tuple partition( * @param cost On exit, partition cost function. * @return error flag. */ -template -void analyzePartition(raft::resources const& handle, - raft::spectral::matrix::sparse_matrix_t const& csr_m, - vertex_t nClusters, - const vertex_t* __restrict__ clusters, - weight_t& edgeCut, - weight_t& cost) +template +void analyzePartition( + raft::resources const& handle, + raft::spectral::matrix::sparse_matrix_t const& csr_m, + vertex_t nClusters, + const vertex_t* __restrict__ clusters, + weight_t& edgeCut, + weight_t& cost) { RAFT_EXPECTS(clusters != nullptr, "Null clusters buffer."); @@ -163,7 +168,7 @@ void analyzePartition(raft::resources const& handle, // Initialize Laplacian /// sparse_matrix_t A{handle, graph}; - raft::spectral::matrix::laplacian_matrix_t L{handle, csr_m}; + raft::spectral::matrix::laplacian_matrix_t L{handle, csr_m}; // Initialize output cost = 0; diff --git a/cpp/src/sparse/cluster/eigen_solvers.cuh b/cpp/src/sparse/cluster/eigen_solvers.cuh index 1b2501d68..6df1e86a8 100644 --- a/cpp/src/sparse/cluster/eigen_solvers.cuh +++ b/cpp/src/sparse/cluster/eigen_solvers.cuh @@ -51,7 +51,7 @@ struct lanczos_solver_t { index_type_t solve_smallest_eigenvectors( raft::resources const& handle, - raft::spectral::matrix::sparse_matrix_t const& A, + raft::spectral::matrix::sparse_matrix_t const& A, value_type_t* __restrict__ eigVals, value_type_t* __restrict__ eigVecs) const { @@ -74,7 +74,7 @@ struct lanczos_solver_t { index_type_t solve_largest_eigenvectors( raft::resources const& handle, - raft::spectral::matrix::sparse_matrix_t const& A, + raft::spectral::matrix::sparse_matrix_t const& A, value_type_t* __restrict__ eigVals, value_type_t* __restrict__ eigVecs) const { diff --git a/cpp/src/sparse/cluster/partition.cuh b/cpp/src/sparse/cluster/partition.cuh index 111decadf..a4cddd84c 100644 --- a/cpp/src/sparse/cluster/partition.cuh +++ b/cpp/src/sparse/cluster/partition.cuh @@ -45,17 +45,21 @@ namespace spectral { * @param eigVecs Output eigenvector array pointer on device * @return statistics: number of eigensolver iterations, . */ -template +template std::tuple partition( raft::resources const& handle, - raft::spectral::matrix::sparse_matrix_t const& csr_m, + raft::spectral::matrix::sparse_matrix_t const& csr_m, EigenSolver const& eigen_solver, ClusterSolver const& cluster_solver, vertex_t* __restrict__ clusters, weight_t* eigVals, weight_t* eigVecs) { - return cuvs::spectral::detail::partition( + return cuvs::spectral::detail::partition( handle, csr_m, eigen_solver, cluster_solver, clusters, eigVals, eigVecs); } diff --git a/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh b/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh index 43bb6d8a8..1ab51ab59 100644 --- a/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh +++ b/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh @@ -449,10 +449,10 @@ void min_components_by_color(raft::sparse::COO& coo, * is done * @param[in] metric distance metric */ -template +template void cross_component_nn( raft::resources const& handle, - raft::sparse::COO& out, + raft::sparse::COO& out, const value_t* X, const value_idx* orig_colors, size_t n_rows, @@ -510,7 +510,7 @@ void cross_component_nn( * Take the min for any duplicate colors */ // Compute mask of duplicates - rmm::device_uvector out_index(n_rows + 1, stream); + rmm::device_uvector out_index(n_rows + 1, stream); raft::sparse::op::compute_duplicates_mask( out_index.data(), colors.data(), nn_colors.data(), n_rows, stream); @@ -520,13 +520,13 @@ void cross_component_nn( out_index.data()); // compute final size - value_idx size = 0; + nnz_t size = 0; raft::update_host(&size, out_index.data() + (out_index.size() - 1), 1, stream); raft::resource::sync_stream(handle, stream); size++; - raft::sparse::COO min_edges(stream); + raft::sparse::COO min_edges(stream); min_edges.allocate(size, n_rows, n_rows, true, stream); min_components_by_color( diff --git a/cpp/tests/sparse/cluster/eigen_solvers.cu b/cpp/tests/sparse/cluster/eigen_solvers.cu index 8de0b49e7..d5ab3da40 100644 --- a/cpp/tests/sparse/cluster/eigen_solvers.cu +++ b/cpp/tests/sparse/cluster/eigen_solvers.cu @@ -36,6 +36,7 @@ TEST(Raft, EigenSolvers) using namespace raft::spectral::matrix; using index_type = int; using value_type = double; + using nnz_type = int; raft::resources h; ASSERT_EQ(0, raft::resource::get_device_id(h)); @@ -43,10 +44,10 @@ TEST(Raft, EigenSolvers) index_type* ro{nullptr}; index_type* ci{nullptr}; value_type* vs{nullptr}; - index_type nnz = 0; + nnz_type nnz = 0; index_type nrows = 0; - sparse_matrix_t sm1{h, ro, ci, vs, nrows, nnz}; + sparse_matrix_t sm1{h, ro, ci, vs, nrows, nnz}; ASSERT_EQ(nullptr, sm1.row_offsets_); index_type neigvs{10}; diff --git a/cpp/tests/sparse/cluster/spectral.cu b/cpp/tests/sparse/cluster/spectral.cu index 98b963451..b3822d9c4 100644 --- a/cpp/tests/sparse/cluster/spectral.cu +++ b/cpp/tests/sparse/cluster/spectral.cu @@ -73,13 +73,13 @@ TEST(Raft, Spectral) raft::update_device(indices.data(), h_indices.data(), h_indices.size(), handle.get_stream()); raft::update_device(values.data(), h_values.data(), h_values.size(), handle.get_stream()); - raft::spectral::matrix::sparse_matrix_t const matrix{ + raft::spectral::matrix::sparse_matrix_t const matrix{ handle, offsets.data(), indices.data(), values.data(), static_cast(offsets.size() - 1), - static_cast(indices.size())}; + static_cast(indices.size())}; cuvs::spectral::eigen_solver_config_t eig_cfg{ n_eigenvectors, evs_max_it, restartIter_lanczos, evs_tol, reorthog, seed1};