Skip to content

Commit

Permalink
working through updates for cuvs
Browse files Browse the repository at this point in the history
  • Loading branch information
divyegala committed Jan 30, 2025
1 parent eb919d1 commit cbae315
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions cpp/include/raft/linalg/detail/lanczos.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,10 @@ static int lanczosRestart(raft::resources const& handle,
* @param seed random seed.
* @return error flag.
*/
template <typename index_type_t, typename value_type_t>
template <typename index_type_t, typename value_type_t, typename nnz_type_t>
int computeSmallestEigenvectors(
raft::resources const& handle,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t> const* A,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t, nnz_type_t> const* A,
index_type_t nEigVecs,
index_type_t maxIter,
index_type_t restartIter,
Expand Down Expand Up @@ -986,10 +986,10 @@ int computeSmallestEigenvectors(
return 0;
}

template <typename index_type_t, typename value_type_t>
template <typename index_type_t, typename value_type_t, typename nnz_type_t>
int computeSmallestEigenvectors(
raft::resources const& handle,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t> const& A,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t, nnz_type_t> const& A,
index_type_t nEigVecs,
index_type_t maxIter,
index_type_t restartIter,
Expand Down Expand Up @@ -1090,10 +1090,10 @@ int computeSmallestEigenvectors(
* @param seed random seed.
* @return error flag.
*/
template <typename index_type_t, typename value_type_t>
template <typename index_type_t, typename value_type_t, typename nnz_type_t>
int computeLargestEigenvectors(
raft::resources const& handle,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t> const* A,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t, nnz_type_t> const* A,
index_type_t nEigVecs,
index_type_t maxIter,
index_type_t restartIter,
Expand Down Expand Up @@ -1334,10 +1334,10 @@ int computeLargestEigenvectors(
return 0;
}

template <typename index_type_t, typename value_type_t>
template <typename index_type_t, typename value_type_t, typename nnz_type_t>
int computeLargestEigenvectors(
raft::resources const& handle,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t> const& A,
spectral::matrix::sparse_matrix_t<index_type_t, value_type_t, nnz_type_t> const& A,
index_type_t nEigVecs,
index_type_t maxIter,
index_type_t restartIter,
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/sparse/neighbors/detail/knn_graph.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void knn_graph(raft::resources const& handle,
conv_indices(int64_indices.data(), indices.data(), nnz, stream);

raft::sparse::linalg::symmetrize(
handle, rows.data(), indices.data(), data.data(), (value_idx)m, (value_idx)k, (nnz_t)nnz, out);
handle, rows.data(), indices.data(), data.data(), m, k, nnz, out);
}

}; // namespace raft::sparse::neighbors::detail
40 changes: 20 additions & 20 deletions cpp/include/raft/spectral/detail/matrix_wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ struct sparse_matrix_t {
nnz_type const nnz_;
};

template <typename index_type, typename value_type>
struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type> {
template <typename index_type, typename value_type, typename nnz_type = uint64_t>
struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type, nnz_type> {
laplacian_matrix_t(resources const& raft_handle,
index_type const* row_offsets,
index_type const* col_indices,
value_type const* values,
index_type const nrows,
index_type const nnz)
: sparse_matrix_t<index_type, value_type>(
nnz_type const nnz)
: sparse_matrix_t<index_type, value_type, nnz_type>(
raft_handle, row_offsets, col_indices, values, nrows, nnz),
diagonal_(raft_handle, nrows)
{
Expand All @@ -332,8 +332,8 @@ struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type> {
}

laplacian_matrix_t(resources const& raft_handle,
sparse_matrix_t<index_type, value_type> const& csr_m)
: sparse_matrix_t<index_type, value_type>(raft_handle,
sparse_matrix_t<index_type, value_type, nnz_type> const& csr_m)
: sparse_matrix_t<index_type, value_type, nnz_type>(raft_handle,
csr_m.row_offsets_,
csr_m.col_indices_,
csr_m.values_,
Expand All @@ -343,7 +343,7 @@ struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type> {
{
vector_t<value_type> ones{raft_handle, (size_t)csr_m.nrows_};
ones.fill(1.0);
sparse_matrix_t<index_type, value_type>::mv(1, ones.raw(), 0, diagonal_.raw());
sparse_matrix_t<index_type, value_type, nnz_type>::mv(1, ones.raw(), 0, diagonal_.raw());
}

// y = alpha*A*x + beta*y
Expand All @@ -357,9 +357,9 @@ struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type> {
bool symmetric = false) const override
{
constexpr int BLOCK_SIZE = 1024;
auto n = sparse_matrix_t<index_type, value_type>::nrows_;
auto n = sparse_matrix_t<index_type, value_type, nnz_type>::nrows_;

auto handle = sparse_matrix_t<index_type, value_type>::get_handle();
auto handle = sparse_matrix_t<index_type, value_type, nnz_type>::get_handle();
auto cublas_h = resource::get_cublas_handle(handle);
auto stream = resource::get_cuda_stream(handle);

Expand All @@ -382,31 +382,31 @@ struct laplacian_matrix_t : sparse_matrix_t<index_type, value_type> {

// Apply adjacency matrix
//
sparse_matrix_t<index_type, value_type>::mv(-alpha, x, 1, y, alg, transpose, symmetric);
sparse_matrix_t<index_type, value_type, nnz_type>::mv(-alpha, x, 1, y, alg, transpose, symmetric);
}

vector_t<value_type> diagonal_;
};

template <typename index_type, typename value_type>
struct modularity_matrix_t : laplacian_matrix_t<index_type, value_type> {
template <typename index_type, typename value_type, typename nnz_type = uint64_t>
struct modularity_matrix_t : laplacian_matrix_t<index_type, value_type, nnz_type> {
modularity_matrix_t(resources const& raft_handle,
index_type const* row_offsets,
index_type const* col_indices,
value_type const* values,
index_type const nrows,
index_type const nnz)
: laplacian_matrix_t<index_type, value_type>(
nnz_type const nnz)
: laplacian_matrix_t<index_type, value_type, nnz_type>(
raft_handle, row_offsets, col_indices, values, nrows, nnz)
{
edge_sum_ = laplacian_matrix_t<index_type, value_type>::diagonal_.nrm1();
edge_sum_ = laplacian_matrix_t<index_type, value_type, nnz_type>::diagonal_.nrm1();
}

modularity_matrix_t(resources const& raft_handle,
sparse_matrix_t<index_type, value_type> const& csr_m)
: laplacian_matrix_t<index_type, value_type>(raft_handle, csr_m)
: laplacian_matrix_t<index_type, value_type, nnz_type>(raft_handle, csr_m)
{
edge_sum_ = laplacian_matrix_t<index_type, value_type>::diagonal_.nrm1();
edge_sum_ = laplacian_matrix_t<index_type, value_type, nnz_type>::diagonal_.nrm1();
}

// y = alpha*A*x + beta*y
Expand All @@ -427,7 +427,7 @@ struct modularity_matrix_t : laplacian_matrix_t<index_type, value_type> {

// y = A*x
//
sparse_matrix_t<index_type, value_type>::mv(alpha, x, 0, y, alg, transpose, symmetric);
sparse_matrix_t<index_type, value_type, nnz_type>::mv(alpha, x, 0, y, alg, transpose, symmetric);
value_type dot_res;

// gamma = d'*x
Expand All @@ -437,7 +437,7 @@ struct modularity_matrix_t : laplacian_matrix_t<index_type, value_type> {
RAFT_CUBLAS_TRY(
raft::linalg::detail::cublasdot(cublas_h,
n,
laplacian_matrix_t<index_type, value_type>::diagonal_.raw(),
laplacian_matrix_t<index_type, value_type, nnz_type>::diagonal_.raw(),
1,
x,
1,
Expand All @@ -452,7 +452,7 @@ struct modularity_matrix_t : laplacian_matrix_t<index_type, value_type> {
raft::linalg::detail::cublasaxpy(cublas_h,
n,
&gamma_,
laplacian_matrix_t<index_type, value_type>::diagonal_.raw(),
laplacian_matrix_t<index_type, value_type, nnz_type>::diagonal_.raw(),
1,
y,
1,
Expand Down

0 comments on commit cbae315

Please sign in to comment.