From 1d5918d39ef761660388eaa013f879de343e9009 Mon Sep 17 00:00:00 2001 From: "Corey J. Nolet" Date: Mon, 18 Nov 2024 10:02:08 -0500 Subject: [PATCH] MOre updates --- cpp/CMakeLists.txt | 2 +- cpp/include/cuvs/{dimred => embed}/spectral.hpp | 4 ++-- cpp/src/distance/kernel_gram.cu | 1 + cpp/src/{dimred => embed}/spectral.cu | 6 +++--- cpp/test/CMakeLists.txt | 2 +- cpp/test/distance/gram.cu | 14 +++++++------- cpp/test/distance/gram_base.cuh | 7 ++++--- cpp/test/sparse/gram.cu | 16 ++++++++-------- 8 files changed, 27 insertions(+), 25 deletions(-) rename cpp/include/cuvs/{dimred => embed}/spectral.hpp (96%) rename cpp/src/{dimred => embed}/spectral.cu (94%) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 18f9f6e6a..24d4fc4cd 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -373,7 +373,7 @@ if(BUILD_SHARED_LIBS) src/distance/distance.cu src/distance/kernel_gram.cu src/distance/pairwise_distance.cu - src/dimred/spectral.cu + src/embed/spectral.cu src/neighbors/brute_force.cu src/neighbors/cagra_build_float.cu src/neighbors/cagra_build_half.cu diff --git a/cpp/include/cuvs/dimred/spectral.hpp b/cpp/include/cuvs/embed/spectral.hpp similarity index 96% rename from cpp/include/cuvs/dimred/spectral.hpp rename to cpp/include/cuvs/embed/spectral.hpp index 6c6baabb4..23ed4c33f 100644 --- a/cpp/include/cuvs/dimred/spectral.hpp +++ b/cpp/include/cuvs/embed/spectral.hpp @@ -17,7 +17,7 @@ #include #include -namespace cuvs::dimred::spectral { +namespace cuvs::embed::spectral { /** * Given a COO formatted (symmetric) knn graph, this function computes the spectral embeddings @@ -39,4 +39,4 @@ void fit(const raft::resources& handle, int n_components, raft::device_matrix_view out, unsigned long long seed = 0L); -}; // namespace cuvs::dimred::spectral +}; // namespace cuvs::embed::spectral diff --git a/cpp/src/distance/kernel_gram.cu b/cpp/src/distance/kernel_gram.cu index 365c538e1..78cd2d065 100644 --- a/cpp/src/distance/kernel_gram.cu +++ b/cpp/src/distance/kernel_gram.cu @@ -19,6 +19,7 @@ namespace cuvs::distance::kernels { template class KernelFactory; + template class KernelFactory; template class GramMatrixBase; diff --git a/cpp/src/dimred/spectral.cu b/cpp/src/embed/spectral.cu similarity index 94% rename from cpp/src/dimred/spectral.cu rename to cpp/src/embed/spectral.cu index fb6bb6abc..f7b153325 100644 --- a/cpp/src/dimred/spectral.cu +++ b/cpp/src/embed/spectral.cu @@ -19,7 +19,7 @@ #include #include -namespace cuvs::dimred::spectral { +namespace cuvs::embed::spectral { /** * Given a COO formatted (symmetric) knn graph, this function computes the spectral embeddings @@ -37,7 +37,7 @@ void fit(const raft::resources& handle, raft::device_coo_matrix_view knn_graph, int n_components, raft::device_matrix_view out, - unsigned long long seed = 0L) + unsigned long long seed) { cuvs::sparse::cluster::spectral::detail::fit_embedding( handle, @@ -50,4 +50,4 @@ void fit(const raft::resources& handle, out.data_handle(), seed); } -}; // namespace cuvs::dimred::spectral +}; // namespace cuvs::embed::spectral diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 5ed63efe3..49011daaf 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -215,7 +215,7 @@ if(BUILD_TESTS) ConfigureTest( NAME SPARSE_TEST PATH sparse/cluster/cluster_solvers.cu sparse/cluster/eigen_solvers.cu - sparse/gram.cu sparse/cluster/spectral.cu GPUS 1 PERCENT 100 + sparse/cluster/spectral.cu GPUS 1 PERCENT 100 ) ConfigureTest( NAME STATS_TEST PATH stats/trustworthiness.cu stats/silhouette_score.cu GPUS 1 PERCENT 100 diff --git a/cpp/test/distance/gram.cu b/cpp/test/distance/gram.cu index 5c64eb3e4..89b1525ea 100644 --- a/cpp/test/distance/gram.cu +++ b/cpp/test/distance/gram.cu @@ -81,12 +81,12 @@ class GramMatrixTest : public ::testing::TestWithParam { GramMatrixTest() : params(GetParam()), handle(), - x1(0, resource::get_cuda_stream(handle)), - x2(0, resource::get_cuda_stream(handle)), - gram(0, resource::get_cuda_stream(handle)), + x1(0, raft::resource::get_cuda_stream(handle)), + x2(0, raft::resource::get_cuda_stream(handle)), + gram(0, raft::resource::get_cuda_stream(handle)), gram_host(0) { - auto stream = resource::get_cuda_stream(handle); + auto stream = raft::resource::get_cuda_stream(handle); if (params.ld1 == 0) { params.ld1 = params.is_row_major ? params.n_cols : params.n1; } if (params.ld2 == 0) { params.ld2 = params.is_row_major ? params.n_cols : params.n2; } @@ -136,7 +136,7 @@ class GramMatrixTest : public ::testing::TestWithParam { (*kernel)(handle, x1_span, x2_span, out_span); - auto stream = resource::get_cuda_stream(handle); + auto stream = raft::resource::get_cuda_stream(handle); naiveGramMatrixKernel(params.n1, params.n2, params.n_cols, @@ -151,8 +151,8 @@ class GramMatrixTest : public ::testing::TestWithParam { stream, handle); - ASSERT_TRUE(raft::devArrMatchHost( - gram_host.data(), gram.data(), gram.size(), raft::CompareApprox(1e-6f), stream)); + ASSERT_TRUE(cuvs::devArrMatchHost( + gram_host.data(), gram.data(), gram.size(), cuvs::CompareApprox(1e-6f), stream)); } GramMatrixInputs params; diff --git a/cpp/test/distance/gram_base.cuh b/cpp/test/distance/gram_base.cuh index 21cce475b..326cdb4f8 100644 --- a/cpp/test/distance/gram_base.cuh +++ b/cpp/test/distance/gram_base.cuh @@ -14,6 +14,7 @@ * limitations under the License. */ +#pragma once #include #include #include @@ -25,7 +26,7 @@ #include #include -namespace raft { +namespace cuvs { namespace distance { namespace kernels { @@ -55,7 +56,7 @@ void naiveGramMatrixKernel(int n1, raft::update_host(x1_host.data(), x1.data(), x1.size(), stream); std::vector x2_host(x2.size()); raft::update_host(x2_host.data(), x2.data(), x2.size(), stream); - resource::sync_stream(handle, stream); + raft::resource::sync_stream(handle, stream); for (int i = 0; i < n1; i++) { for (int j = 0; j < n2; j++) { @@ -87,4 +88,4 @@ void naiveGramMatrixKernel(int n1, } // namespace kernels } // namespace distance -} // namespace raft \ No newline at end of file +} // namespace cuvs \ No newline at end of file diff --git a/cpp/test/sparse/gram.cu b/cpp/test/sparse/gram.cu index cd662d339..d7af30a1c 100644 --- a/cpp/test/sparse/gram.cu +++ b/cpp/test/sparse/gram.cu @@ -35,7 +35,7 @@ #include #include -namespace cuvs::distance::kernels { +namespace cuvs::distance::kernels::sparse { /** * Structure to describe structure of the input matrices: @@ -127,7 +127,7 @@ class GramMatrixTest : public ::testing::TestWithParam { protected: GramMatrixTest() : params(GetParam()), - stream(resource::get_cuda_stream(handle)), + stream(raft::resource::get_cuda_stream(handle)), x1(0, stream), x2(0, stream), x1_csr_indptr(0, stream), @@ -173,7 +173,7 @@ class GramMatrixTest : public ::testing::TestWithParam { std::vector dense_host(dense_size); raft::update_host(dense_host.data(), dense, dense_size, stream); - resource::sync_stream(handle, stream); + raft::resource::sync_stream(handle, stream); std::vector indptr_host(n_rows + 1); std::vector indices_host(n_rows * n_cols); @@ -205,7 +205,7 @@ class GramMatrixTest : public ::testing::TestWithParam { raft::update_device(indptr, indptr_host.data(), n_rows + 1, stream); raft::update_device(indices, indices_host.data(), nnz, stream); raft::update_device(data, data_host.data(), nnz, stream); - resource::sync_stream(handle, stream); + raft::resource::sync_stream(handle, stream); return nnz; } @@ -290,10 +290,10 @@ class GramMatrixTest : public ::testing::TestWithParam { params.kernel, stream, handle); - resource::sync_stream(handle, stream); + raft::resource::sync_stream(handle, stream); - ASSERT_TRUE(raft::devArrMatchHost( - gram_host.data(), gram.data(), gram.size(), raft::CompareApprox(1e-6f), stream)); + ASSERT_TRUE(cuvs::devArrMatchHost( + gram_host.data(), gram.data(), gram.size(), cuvs::CompareApprox(1e-6f), stream)); } raft::resources handle; @@ -327,4 +327,4 @@ INSTANTIATE_TEST_SUITE_P(GramMatrixTests, GramMatrixTestFloatLd, ::testing::Valu INSTANTIATE_TEST_SUITE_P(GramMatrixTests, GramMatrixTestFloatLdCsr, ::testing::ValuesIn(inputs_ld_csr)); -}; // namespace cuvs::distance::kernels \ No newline at end of file +}; // namespace cuvs::distance::kernels::sparse \ No newline at end of file