Skip to content

Commit

Permalink
MOre updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cjnolet committed Nov 18, 2024
1 parent 25595ed commit 1d5918d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <raft/core/device_coo_matrix.hpp>
#include <raft/core/resources.hpp>

namespace cuvs::dimred::spectral {
namespace cuvs::embed::spectral {

/**
* Given a COO formatted (symmetric) knn graph, this function computes the spectral embeddings
Expand All @@ -39,4 +39,4 @@ void fit(const raft::resources& handle,
int n_components,
raft::device_matrix_view<float, int> out,
unsigned long long seed = 0L);
}; // namespace cuvs::dimred::spectral
}; // namespace cuvs::embed::spectral
1 change: 1 addition & 0 deletions cpp/src/distance/kernel_gram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace cuvs::distance::kernels {

template class KernelFactory<float>;

template class KernelFactory<double>;

template class GramMatrixBase<float>;
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/dimred/spectral.cu → cpp/src/embed/spectral.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <raft/core/device_coo_matrix.hpp>
#include <raft/core/resources.hpp>

namespace cuvs::dimred::spectral {
namespace cuvs::embed::spectral {

/**
* Given a COO formatted (symmetric) knn graph, this function computes the spectral embeddings
Expand All @@ -37,7 +37,7 @@ void fit(const raft::resources& handle,
raft::device_coo_matrix_view<float, int, int, int> knn_graph,
int n_components,
raft::device_matrix_view<float, int> out,
unsigned long long seed = 0L)
unsigned long long seed)
{
cuvs::sparse::cluster::spectral::detail::fit_embedding(
handle,
Expand All @@ -50,4 +50,4 @@ void fit(const raft::resources& handle,
out.data_handle(),
seed);
}
}; // namespace cuvs::dimred::spectral
}; // namespace cuvs::embed::spectral
2 changes: 1 addition & 1 deletion cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions cpp/test/distance/gram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {
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; }
Expand Down Expand Up @@ -136,7 +136,7 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {

(*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,
Expand All @@ -151,8 +151,8 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {
stream,
handle);

ASSERT_TRUE(raft::devArrMatchHost(
gram_host.data(), gram.data(), gram.size(), raft::CompareApprox<math_t>(1e-6f), stream));
ASSERT_TRUE(cuvs::devArrMatchHost(
gram_host.data(), gram.data(), gram.size(), cuvs::CompareApprox<math_t>(1e-6f), stream));
}

GramMatrixInputs params;
Expand Down
7 changes: 4 additions & 3 deletions cpp/test/distance/gram_base.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#pragma once
#include <cuvs/distance/distance.hpp>
#include <cuvs/distance/grammian.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand All @@ -25,7 +26,7 @@
#include <iostream>
#include <memory>

namespace raft {
namespace cuvs {
namespace distance {
namespace kernels {

Expand Down Expand Up @@ -55,7 +56,7 @@ void naiveGramMatrixKernel(int n1,
raft::update_host(x1_host.data(), x1.data(), x1.size(), stream);
std::vector<math_t> 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++) {
Expand Down Expand Up @@ -87,4 +88,4 @@ void naiveGramMatrixKernel(int n1,

} // namespace kernels
} // namespace distance
} // namespace raft
} // namespace cuvs
16 changes: 8 additions & 8 deletions cpp/test/sparse/gram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <iostream>
#include <memory>

namespace cuvs::distance::kernels {
namespace cuvs::distance::kernels::sparse {

/**
* Structure to describe structure of the input matrices:
Expand Down Expand Up @@ -127,7 +127,7 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {
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),
Expand Down Expand Up @@ -173,7 +173,7 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {

std::vector<math_t> 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<int> indptr_host(n_rows + 1);
std::vector<int> indices_host(n_rows * n_cols);
Expand Down Expand Up @@ -205,7 +205,7 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {
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;
}

Expand Down Expand Up @@ -290,10 +290,10 @@ class GramMatrixTest : public ::testing::TestWithParam<GramMatrixInputs> {
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<math_t>(1e-6f), stream));
ASSERT_TRUE(cuvs::devArrMatchHost(
gram_host.data(), gram.data(), gram.size(), cuvs::CompareApprox<math_t>(1e-6f), stream));
}

raft::resources handle;
Expand Down Expand Up @@ -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
}; // namespace cuvs::distance::kernels::sparse

0 comments on commit 1d5918d

Please sign in to comment.