Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAFT API updates for lap, label, cluster, and spectral apis #4548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions cpp/src/glm/qn/simple_mat/sparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <raft/mr/device/allocator.hpp>
#include <rmm/device_uvector.hpp>

#include <raft/sparse/detail/cusparse_wrappers.h>

namespace ML {

/**
Expand Down Expand Up @@ -94,7 +96,7 @@ struct SimpleSparseMat : SimpleMat<T> {
// to swap arguments A and B in cusparseSpMM.
cusparseDnMatDescr_t descrC;
auto order = C.ord == COL_MAJOR ? CUSPARSE_ORDER_ROW : CUSPARSE_ORDER_COL;
RAFT_CUSPARSE_TRY(raft::sparse::cusparsecreatednmat(
RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsecreatednmat(
cjnolet marked this conversation as resolved.
Show resolved Hide resolved
&descrC, C.n, C.m, order == CUSPARSE_ORDER_COL ? C.n : C.m, C.data, order));

/*
Expand All @@ -115,49 +117,49 @@ struct SimpleSparseMat : SimpleMat<T> {
ldX' - leading dimension - m or n, depending on order and transX
*/
cusparseDnMatDescr_t descrA;
RAFT_CUSPARSE_TRY(raft::sparse::cusparsecreatednmat(&descrA,
C.ord == A.ord ? A.n : A.m,
C.ord == A.ord ? A.m : A.n,
A.ord == COL_MAJOR ? A.m : A.n,
A.data,
order));
RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsecreatednmat(&descrA,
C.ord == A.ord ? A.n : A.m,
C.ord == A.ord ? A.m : A.n,
A.ord == COL_MAJOR ? A.m : A.n,
A.data,
order));
auto opA =
transA ^ (C.ord == A.ord) ? CUSPARSE_OPERATION_NON_TRANSPOSE : CUSPARSE_OPERATION_TRANSPOSE;

cusparseSpMatDescr_t descrB;
RAFT_CUSPARSE_TRY(
raft::sparse::cusparsecreatecsr(&descrB, B.m, B.n, B.nnz, B.row_ids, B.cols, B.values));
RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsecreatecsr(
&descrB, B.m, B.n, B.nnz, B.row_ids, B.cols, B.values));
auto opB = transB ? CUSPARSE_OPERATION_NON_TRANSPOSE : CUSPARSE_OPERATION_TRANSPOSE;

auto alg = order == CUSPARSE_ORDER_COL ? CUSPARSE_SPMM_CSR_ALG1 : CUSPARSE_SPMM_CSR_ALG2;

size_t bufferSize;
RAFT_CUSPARSE_TRY(raft::sparse::cusparsespmm_bufferSize(handle.get_cusparse_handle(),
opB,
opA,
&alpha,
descrB,
descrA,
&beta,
descrC,
alg,
&bufferSize,
stream));
RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsespmm_bufferSize(handle.get_cusparse_handle(),
opB,
opA,
&alpha,
descrB,
descrA,
&beta,
descrC,
alg,
&bufferSize,
stream));

raft::interruptible::synchronize(stream);
rmm::device_uvector<T> tmp(bufferSize, stream);

RAFT_CUSPARSE_TRY(raft::sparse::cusparsespmm(handle.get_cusparse_handle(),
opB,
opA,
&alpha,
descrB,
descrA,
&beta,
descrC,
alg,
tmp.data(),
stream));
RAFT_CUSPARSE_TRY(raft::sparse::detail::cusparsespmm(handle.get_cusparse_handle(),
opB,
opA,
&alpha,
descrB,
descrA,
&beta,
descrC,
alg,
tmp.data(),
stream));

RAFT_CUSPARSE_TRY(cusparseDestroyDnMat(descrA));
RAFT_CUSPARSE_TRY(cusparseDestroySpMat(descrB));
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/hdbscan/condensed_hierarchy.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <cub/cub.cuh>

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/hdbscan/detail/extract.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#include "stabilities.cuh"
#include "utils.h"

#include <label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <cuml/cluster/hdbscan.hpp>

#include <raft/cudart_utils.h>
#include <raft/label/classlabels.cuh>
#include <raft/sparse/convert/csr.hpp>
#include <raft/sparse/op/sort.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/hdbscan/detail/membership.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cuml/cluster/hdbscan.hpp>

#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <algorithm>

Expand Down
2 changes: 0 additions & 2 deletions cpp/src/hdbscan/detail/reachability.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <raft/cuda_utils.cuh>
#include <raft/cudart_utils.h>

#include <raft/mr/device/buffer.hpp>

#include <raft/linalg/unary_op.hpp>

#include <raft/sparse/convert/csr.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/hdbscan/detail/select.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cuml/cluster/hdbscan.hpp>

#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <algorithm>

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/hdbscan/detail/stabilities.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cuml/cluster/hdbscan.hpp>

#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <algorithm>

Expand Down
6 changes: 2 additions & 4 deletions cpp/src/hdbscan/detail/utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,6 @@

#pragma once

#include <label/classlabels.cuh>

#include <cub/cub.cuh>

#include <raft/cudart_utils.h>
Expand All @@ -27,7 +25,7 @@

#include <cuml/cluster/hdbscan.hpp>

#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>

#include <algorithm>

Expand Down
1 change: 0 additions & 1 deletion cpp/src/hierarchy/pw_dist_graph.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <rmm/exec_policy.hpp>

#include <raft/distance/distance_type.hpp>
#include <raft/mr/device/buffer.hpp>

// TODO: Not a good strategy for pluggability but will be
// removed once our dense pairwise distance API is in RAFT
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/holtwinters/internal/hw_eval.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@

#include <raft/cudart_utils.h>
#include <raft/handle.hpp>
#include <raft/mr/device/buffer.hpp>

template <typename Dtype>
__device__ Dtype holtwinters_eval_device(int tid,
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/holtwinters/internal/hw_optim.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@
#include "hw_utils.cuh"

#include <raft/cudart_utils.h>
#include <raft/mr/device/buffer.hpp>

template <typename Dtype>
__device__ Dtype golden_step(Dtype a, Dtype b, Dtype c)
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/knn/knn.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

#include <cuda_runtime.h>
#include <raft/cuda_utils.cuh>
#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>
#include <raft/spatial/knn/ann.hpp>
#include <raft/spatial/knn/ball_cover.hpp>

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/svm/svc_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
#include <cuml/svm/svm_parameter.h>
#include <label/classlabels.cuh>
#include <matrix/kernelfactory.cuh>
#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>
// #TODO: Replace with public header when ready
#include <raft/linalg/detail/cublas_wrappers.hpp>
#include <raft/linalg/unary_op.hpp>
#include <raft/matrix/matrix.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src/tsne/fft_tsne.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <cufft_utils.h>
#include <linalg/init.h>
#include <raft/linalg/eltwise.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/stats/sum.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src_prims/functions/hinge.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <raft/linalg/unary_op.hpp>
#include <raft/matrix/math.hpp>
#include <raft/matrix/matrix.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/stats/mean.hpp>
#include <raft/stats/sum.hpp>
#include <rmm/device_uvector.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src_prims/functions/linearReg.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <raft/linalg/transpose.hpp>
#include <raft/matrix/math.hpp>
#include <raft/matrix/matrix.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/stats/mean.hpp>
#include <raft/stats/sum.hpp>
#include <rmm/device_uvector.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src_prims/label/classlabels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <raft/cuda_utils.cuh>
#include <raft/cudart_utils.h>
#include <raft/handle.hpp>
#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>
#include <raft/linalg/unary_op.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src_prims/linalg/lstsq.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <raft/linalg/transpose.hpp>
#include <raft/matrix/math.hpp>
#include <raft/matrix/matrix.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/random/rng.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src_prims/linalg/rsvd.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <raft/linalg/transpose.hpp>
#include <raft/matrix/math.hpp>
#include <raft/matrix/matrix.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/random/rng.hpp>

namespace MLCommon {
Expand Down
1 change: 0 additions & 1 deletion cpp/src_prims/random/make_regression.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <raft/linalg/qr.hpp>
#include <raft/linalg/transpose.hpp>
#include <raft/matrix/matrix.hpp>
#include <raft/mr/device/buffer.hpp>
#include <raft/random/rng.hpp>
#include <rmm/device_uvector.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/test/prims/knn_classify.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <iostream>
#include <raft/cuda_utils.cuh>
#include <raft/cudart_utils.h>
#include <raft/label/classlabels.cuh>
#include <raft/label/classlabels.hpp>
#include <raft/spatial/knn/knn.hpp>
#include <random/make_blobs.cuh>
#include <rmm/device_uvector.hpp>
Expand Down