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

Preparing sparse primitives for movement to RAFT #3157

Merged
merged 152 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from 149 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
4dbabf4
Adding brute force knn shell to sparse
cjnolet Jul 24, 2020
46b2f09
Stubbing out algorithm flow
cjnolet Jul 24, 2020
03dbdb8
Adding initial headers to wrapper
cjnolet Jul 24, 2020
86ad78a
Performing idx batching
cjnolet Jul 24, 2020
b50611c
Starting to full in cusparse calls
cjnolet Jul 24, 2020
33f7e6a
Checking in
cjnolet Jul 27, 2020
0342eb4
Beginning to add selection kernel
cjnolet Jul 27, 2020
a3ead77
Finished header
cjnolet Jul 27, 2020
db4ff22
Updates. Need to finish populating merge buffer
cjnolet Jul 28, 2020
7752e8e
Using block select for selecting k and using 3-partition merge buffer
cjnolet Jul 31, 2020
363b433
Logic is just about done.
cjnolet Jul 31, 2020
9d70a69
Merge branch 'branch-0.15' into fea-016-sparse_knn
cjnolet Jul 31, 2020
29e82af
Checking in changes. Need to swap out cuda 11 cusparse calls for cuda…
cjnolet Jul 31, 2020
2ee8de2
Merge branch 'branch-0.15' into fea-016-sparse_knn
cjnolet Aug 21, 2020
6f9f6d5
Everything is building. Need end-to-end test
cjnolet Aug 21, 2020
8c9dfb3
Running clang format
cjnolet Aug 21, 2020
87478ad
Updating changelog
cjnolet Aug 21, 2020
1bb9c0e
Using raft's cusparse_wrappers.h instead of cuml
cjnolet Aug 21, 2020
a65f378
Merge branch 'imp-016-use_raft_cusparse_wrappers' into fea-016-sparse…
cjnolet Aug 21, 2020
fa2e64d
Removing cuda11-required GEMM calls (commenting them out for now, wil…
cjnolet Aug 21, 2020
8789378
Fixing clang style
cjnolet Aug 21, 2020
1db4d4d
Separating distance computation from selection from general brute for…
cjnolet Aug 24, 2020
6054863
Updating clang style
cjnolet Aug 24, 2020
d83f523
Adding batcher to help ease batch state management
cjnolet Aug 24, 2020
763d3c1
Fixing clang style
cjnolet Aug 24, 2020
18b9891
MOre clang fixes
cjnolet Aug 24, 2020
82aa14b
Merge branch 'branch-0.16' into fea-016-sparse_knn
cjnolet Aug 24, 2020
eabe273
IP distance is computed using search * index.T.
cjnolet Aug 24, 2020
9a9ada6
Making type template for value_t all the way through knn_merge_parts
cjnolet Aug 25, 2020
6d45c91
Adding simple googletest for sparse pairwise dists. The transpose con…
cjnolet Aug 26, 2020
e9a1120
Completing test for basic inner product distances
cjnolet Aug 26, 2020
f8038b1
Removing prints from test
cjnolet Aug 26, 2020
ff656ab
Cleaning up batching for knn. Ready to gtest
cjnolet Aug 26, 2020
2126db7
KNN w/ max inner product is working
cjnolet Aug 27, 2020
8e9c5ee
Adding guts of expanded l2 computation.
cjnolet Aug 27, 2020
0a329c9
Cleaning up some debug prints
cjnolet Aug 27, 2020
0fca4cb
Fixing clang format
cjnolet Aug 27, 2020
acd44b5
More cleanup and clang style fix
cjnolet Aug 27, 2020
8e885f8
Fixing style for sparse knn prim test
cjnolet Aug 27, 2020
04b5caa
Hoping i've captured all the clang updates
cjnolet Aug 27, 2020
41c8504
Updating per include_checker
cjnolet Aug 27, 2020
434e0b1
I feel like I"m bouncing back and forth between clang and include che…
cjnolet Aug 27, 2020
e2eed28
Merge branch 'branch-0.16' into fea-016-sparse_knn
cjnolet Aug 27, 2020
e72af7f
Refactoring sparse pairwise dists to return dense outputs
cjnolet Aug 28, 2020
3a37daf
Beginning python layer
cjnolet Aug 31, 2020
8d28144
Merge branch 'fea-016-sparse-cuml-array' into fea-016-sparse_knn
cjnolet Sep 2, 2020
1c13bf5
iAdding python layer for sparse inputs to nearest neighbors
cjnolet Sep 2, 2020
50e3d4f
End to end sparse knn works. Need to finish norms for expanded euclid…
cjnolet Sep 2, 2020
dada87f
Removing unused file
cjnolet Sep 2, 2020
11a5b60
Merge branch 'fea-016-sparse-cuml-array' into fea-016-sparse_knn
cjnolet Sep 3, 2020
581d38e
Adding gtest for expanded l2.
cjnolet Sep 3, 2020
39a1fc4
Sparse l2 matches sklearn
cjnolet Sep 3, 2020
49fafaf
Fixing clang format style
cjnolet Sep 3, 2020
86a8e00
Merge branch 'branch-0.16' into fea-016-sparse_knn
cjnolet Sep 3, 2020
31aa7cf
Fixing dstyle in gtests
cjnolet Sep 3, 2020
e11560c
Merge branch 'fea-016-sparse-cuml-array' into fea-016-sparse_knn
cjnolet Sep 3, 2020
bf18a56
Lots of changes and cleanup. Still need to flip the batching
cjnolet Sep 8, 2020
51eca5c
Progress on tiling. Still a failure when tile sizes don't match up.
cjnolet Sep 9, 2020
e3c16e2
Tiling w/ uneven batch sizes works! Now just need to figure out what …
cjnolet Sep 11, 2020
2772f63
Some further optinmizations are necessary, but this works for now.
cjnolet Sep 14, 2020
d46f85e
Ready for cleanup
cjnolet Sep 15, 2020
40c7341
Parametrizing sparse knn tests
cjnolet Sep 15, 2020
65316fc
More cleanup.
cjnolet Sep 15, 2020
3cd7229
Fixing clang format
cjnolet Sep 15, 2020
922aa5a
Merge branch 'fea-016-sparse-cuml-array' into fea-016-sparse_knn
cjnolet Sep 15, 2020
243c640
Merge branch 'fea-016-sparse-cuml-array' into fea-016-sparse_knn
cjnolet Sep 15, 2020
af56727
Fixing clang format style
cjnolet Sep 15, 2020
33f6e2b
Fixing flake8 for sparse nn tests
cjnolet Sep 15, 2020
6ae4061
Fixing googletests
cjnolet Sep 16, 2020
10c2e4c
More cleanup of sparse knn
cjnolet Sep 17, 2020
83005f2
Adding sparse support to UMAP by abstracting the inputs
cjnolet Sep 17, 2020
583b397
Everything's building. Have one template issue to fix in the sparse knn
cjnolet Sep 17, 2020
912b2d2
Updates to API
cjnolet Sep 18, 2020
01d4c03
Usig a struct to manage the knn graph output state
cjnolet Sep 18, 2020
1676e12
C++ side is largely done. Still need to figure out what to do w/ the …
cjnolet Sep 18, 2020
aff4813
Merge branch 'branch-0.16' into fea-016-sparse_knn
cjnolet Sep 18, 2020
0f59990
Removing examples/comms, which seems to have gotten re-checked in by …
cjnolet Sep 18, 2020
c35533a
Fixing c++ style
cjnolet Sep 18, 2020
e567571
Fixing include checks
cjnolet Sep 18, 2020
d13bbb6
This darn style checker is going to kill me.....
cjnolet Sep 18, 2020
112bd06
Adding template type params for output
cjnolet Sep 21, 2020
4a794e0
UMAP is officially accepting sparse inputs
cjnolet Sep 21, 2020
cb9ea73
More cleanup
cjnolet Sep 21, 2020
82c6a8f
Merge branch 'fea-016-sparse_knn' into fea-016-umap_sparse_inputs
cjnolet Sep 21, 2020
d44bdd0
Cleaning up gtests and making them easier to write
cjnolet Sep 21, 2020
ef53bf2
Fixing up and parametrizing tests
cjnolet Sep 21, 2020
0c4e13b
Fixing style
cjnolet Sep 21, 2020
d0eae4e
Fixing python style
cjnolet Sep 21, 2020
554d074
Merge branch 'branch-0.16' into fea-016-umap_sparse_inputs
cjnolet Sep 21, 2020
0102759
More clang format style fixes
cjnolet Sep 21, 2020
17b21ae
Pulled umap inputs classes to more shared location so tsne can use them.
cjnolet Sep 22, 2020
d89df86
Updating clang format
cjnolet Sep 22, 2020
dc64e0a
Fixing bad ide refactor
cjnolet Sep 22, 2020
3ffc68e
Updating changelog
cjnolet Sep 22, 2020
f03edb6
Fixing more clang format
cjnolet Sep 22, 2020
e7879c6
Fixing flake8 style. Not sure why these didn't show up locally
cjnolet Sep 22, 2020
f8a3498
Decomposing sparse knn into a class.
cjnolet Sep 23, 2020
376c0b6
Review feedback
cjnolet Sep 23, 2020
d5bd4ba
Better umap sparse test
cjnolet Sep 23, 2020
0eec0d4
More testing updates
cjnolet Sep 23, 2020
2f07723
Adding docs to some of the remaining prims in csr.cuh
cjnolet Sep 23, 2020
19669d3
Adding gtests for transpose and row slice. Need to add one for todense
cjnolet Sep 23, 2020
5a509be
GTest for csr to dense
cjnolet Sep 23, 2020
cab06aa
Fixing style
cjnolet Sep 23, 2020
6479869
Removing debug logging from new gtests
cjnolet Sep 23, 2020
570bb24
Fixing flake8 style
cjnolet Sep 23, 2020
f0a4629
Merge branch 'branch-0.17' into fea-016-umap_sparse_inputs
cjnolet Oct 19, 2020
3af95af
Getting build to pass
cjnolet Oct 19, 2020
95b4c3b
Running clang-tidy
cjnolet Oct 19, 2020
aceefb2
Fixing format for sparse gtests
cjnolet Oct 19, 2020
0737e8c
Adding 'algo_params' to get_param_names()
cjnolet Oct 20, 2020
765315b
Merge branch 'branch-0.17' into fea-016-umap_sparse_inputs
cjnolet Nov 4, 2020
399f2cd
Removing cumlarray output in kneighbors
cjnolet Nov 5, 2020
ca2e930
Finishing review feedback
cjnolet Nov 5, 2020
96bf4c2
Fixing style
cjnolet Nov 5, 2020
9da7790
Fixing format
cjnolet Nov 5, 2020
c1e6c0c
clang-format
cjnolet Nov 5, 2020
c75daec
Style changes
cjnolet Nov 6, 2020
687e44f
More review updates
cjnolet Nov 13, 2020
d2dcf44
Style updates
cjnolet Nov 13, 2020
fa60ad4
Merge branch 'branch-0.17' into fea-016-umap_sparse_inputs
cjnolet Nov 18, 2020
9e888c4
Running clang format on distance.cuh
cjnolet Nov 18, 2020
458160d
Runing clang format on tests
cjnolet Nov 18, 2020
c068640
Fixing cython style
cjnolet Nov 18, 2020
10a13fc
Updating RAFT commit
cjnolet Nov 18, 2020
7e7fd76
First pass of renaming sparse namespaces for move to RAFT
cjnolet Nov 18, 2020
2555d28
Updating changelog
cjnolet Nov 18, 2020
55f4e0f
Updating neighbors from bad merge
cjnolet Nov 19, 2020
1b81c01
Merge branch 'fea-016-umap_sparse_inputs' into fea-017-raft_sparse_prims
cjnolet Nov 19, 2020
cff8de5
updating cpp style
cjnolet Nov 19, 2020
34b9c7d
Removing debug file
cjnolet Nov 19, 2020
2c0aacf
Update CHANGELOG.md
raydouglass Dec 10, 2020
7ab8cc0
Merge branch 'branch-0.17' into fea-017-raft_sparse_prims
cjnolet Dec 11, 2020
cd00c6b
Fixing style
cjnolet Dec 11, 2020
f343cb2
Breaking sparse prims out into different files/namespaces
cjnolet Dec 11, 2020
31e799d
Updating style
cjnolet Dec 11, 2020
e95025a
Merge branch 'branch-0.18' into fea-017-raft_sparse_prims
cjnolet Dec 11, 2020
7b9dc57
Fixing styl;e
cjnolet Dec 11, 2020
cab1439
Fixing include check
cjnolet Dec 11, 2020
9af9939
Upating tsne
cjnolet Dec 11, 2020
55f60ff
Fixing style
cjnolet Dec 11, 2020
08bbfa8
Replacing allocator
cjnolet Dec 11, 2020
7c8524f
Fixing style
cjnolet Dec 11, 2020
783e965
Fixing more style....
cjnolet Dec 11, 2020
f6d266c
Fixing column wise sort test
cjnolet Dec 11, 2020
7da08e9
Removing remaining cuml-specific dependencies.
cjnolet Dec 13, 2020
0568df3
Using raft handle
cjnolet Dec 14, 2020
5baac23
Implementing some review feedback, re-styling.
cjnolet Dec 14, 2020
3b84eee
Updates from review feedback
cjnolet Dec 17, 2020
928bcde
Merge branch 'branch-0.18' into fea-017-raft_sparse_prims
cjnolet Jan 14, 2021
6d692c6
Fixing merge issues
cjnolet Jan 14, 2021
ccaae61
Updates based on review feedback
cjnolet Jan 14, 2021
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
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")

if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --std=c++14")
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/dbscan/adjgraph/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "../common.cuh"
#include "pack.h"

#include <sparse/csr.cuh>
#include <sparse/convert/csr.cuh>

using namespace thrust;

Expand Down Expand Up @@ -54,7 +54,7 @@ void launcher(const raft::handle_t &handle, Pack<Index_> data, Index_ batchSize,
int minPts = data.minPts;
Index_ *vd = data.vd;

MLCommon::Sparse::csr_adj_graph_batched<Index_, TPB_X>(
raft::sparse::convert::csr_adj_graph_batched<Index_, TPB_X>(
data.ex_scan, data.N, data.adjnnz, batchSize, data.adj, data.adj_graph,
stream,
[core_pts, minPts, vd] __device__(Index_ row, Index_ start_idx,
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/dbscan/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ size_t run(const raft::handle_t& handle, Type_f* x, Index_ N, Index_ D,
temp += exScanSize;

// Running VertexDeg
MLCommon::Sparse::WeakCCState state(xa, fa, m);
raft::sparse::WeakCCState state(xa, fa, m);
MLCommon::device_buffer<Index_> adj_graph(handle.get_device_allocator(),
stream);

Expand Down Expand Up @@ -190,7 +190,7 @@ size_t run(const raft::handle_t& handle, Type_f* x, Index_ N, Index_ D,
CUML_LOG_DEBUG("--> Computing connected components");

start_time = raft::curTimeMillis();
MLCommon::Sparse::weak_cc_batched<Index_, 1024>(
raft::sparse::weak_cc_batched<Index_, 1024>(
labels, ex_scan, adj_graph.data(), curradjlen, N, startVertexId, nPoints,
&state, stream,
[core_pts, startVertexId, nPoints] __device__(Index_ global_id) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/knn/knn_sparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cuml/common/logger.hpp>
#include <cuml/neighbors/knn_sparse.hpp>

#include <sparse/knn.cuh>
#include <sparse/selection/knn.cuh>

#include <cusparse_v2.h>

Expand All @@ -40,7 +40,7 @@ void brute_force_knn(raft::handle_t &handle, const int *idx_indptr,
cusparseHandle_t cusparse_handle = handle.get_cusparse_handle();
cudaStream_t stream = handle.get_stream();

MLCommon::Sparse::Selection::brute_force_knn(
raft::sparse::selection::brute_force_knn(
idx_indptr, idx_indices, idx_data, idx_nnz, n_idx_rows, n_idx_cols,
query_indptr, query_indices, query_data, query_nnz, n_query_rows,
n_query_cols, output_indices, output_dists, k, cusparse_handle, d_alloc,
Expand Down
8 changes: 3 additions & 5 deletions cpp/src/spectral/spectral.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <cuml/cuml.hpp>
#include <sparse/coo.cuh>

#include <sparse/spectral.cuh>
#include <sparse/linalg/spectral.cuh>

namespace ML {

Expand All @@ -38,10 +38,8 @@ namespace Spectral {
*/
void fit_embedding(const raft::handle_t &handle, int *rows, int *cols,
float *vals, int nnz, int n, int n_components, float *out) {
const auto &impl = handle;
MLCommon::Spectral::fit_embedding(
impl.get_cusparse_handle(), rows, cols, vals, nnz, n, n_components, out,
handle.get_device_allocator(), handle.get_stream());
raft::sparse::spectral::fit_embedding(handle, rows, cols, vals, nnz, n,
n_components, out);
}
} // namespace Spectral
} // namespace ML
5 changes: 3 additions & 2 deletions cpp/src/tsne/distances.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <raft/linalg/eltwise.cuh>
#include <selection/knn.cuh>
#include <sparse/coo.cuh>
#include <sparse/linalg/symmetrize.cuh>

namespace ML {
namespace TSNE {
Expand Down Expand Up @@ -94,14 +95,14 @@ void normalize_distances(const int n, float *distances, const int n_neighbors,
template <int TPB_X = 32>
void symmetrize_perplexity(float *P, int64_t *indices, const int n, const int k,
const float exaggeration,
MLCommon::Sparse::COO<float> *COO_Matrix,
raft::sparse::COO<float> *COO_Matrix,
cudaStream_t stream, const raft::handle_t &handle) {
// Perform (P + P.T) / P_sum * early_exaggeration
const float div = exaggeration / (2.0f * n);
raft::linalg::scalarMultiply(P, P, div, n * k, stream);

// Symmetrize to form P + P.T
MLCommon::Sparse::from_knn_symmetrize_matrix(
raft::sparse::linalg::from_knn_symmetrize_matrix(
indices, P, n, k, COO_Matrix, stream, handle.get_device_allocator());
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/tsne/tsne.cu
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void TSNE_fit(const raft::handle_t &handle, const float *X, float *Y,
START_TIMER;
//---------------------------------------------------
// Convert data to COO layout
MLCommon::Sparse::COO<float> COO_Matrix(d_alloc, stream);
raft::sparse::COO<float> COO_Matrix(d_alloc, stream);
TSNE::symmetrize_perplexity(P.data(), knn_indices, n, n_neighbors,
early_exaggeration, &COO_Matrix, stream, handle);
P.release(stream);
Expand Down
10 changes: 6 additions & 4 deletions cpp/src/umap/fuzzy_simpl_set/naive.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include <raft/cudart_utils.h>
#include <raft/cuda_utils.cuh>

#include <sparse/op/sort.h>
#include <raft/stats/mean.cuh>
#include <sparse/coo.cuh>
#include <sparse/linalg/symmetrize.cuh>

#include <cuda_runtime.h>

Expand Down Expand Up @@ -277,7 +279,7 @@ void smooth_knn_dist(int n, const value_idx *knn_indices,
*/
template <int TPB_X, typename value_idx, typename value_t>
void launcher(int n, const value_idx *knn_indices, const float *knn_dists,
int n_neighbors, MLCommon::Sparse::COO<value_t> *out,
int n_neighbors, raft::sparse::COO<value_t> *out,
UMAPParams *params, std::shared_ptr<deviceAllocator> d_alloc,
cudaStream_t stream) {
/**
Expand All @@ -292,7 +294,7 @@ void launcher(int n, const value_idx *knn_indices, const float *knn_dists,
n, knn_indices, knn_dists, rhos.data(), sigmas.data(), params, n_neighbors,
params->local_connectivity, d_alloc, stream);

MLCommon::Sparse::COO<value_t> in(d_alloc, stream, n * n_neighbors, n, n);
raft::sparse::COO<value_t> in(d_alloc, stream, n * n_neighbors, n, n);

// check for logging in order to avoid the potentially costly `arr2Str` call!
if (ML::Logger::get().shouldLogFor(CUML_LEVEL_DEBUG)) {
Expand Down Expand Up @@ -329,7 +331,7 @@ void launcher(int n, const value_idx *knn_indices, const float *knn_dists,
* one via a fuzzy union. (Symmetrize knn graph).
*/
float set_op_mix_ratio = params->set_op_mix_ratio;
MLCommon::Sparse::coo_symmetrize<TPB_X, value_t>(
raft::sparse::linalg::coo_symmetrize<TPB_X, value_t>(
&in, out,
[set_op_mix_ratio] __device__(int row, int col, value_t result,
value_t transpose) {
Expand All @@ -340,7 +342,7 @@ void launcher(int n, const value_idx *knn_indices, const float *knn_dists,
},
d_alloc, stream);

MLCommon::Sparse::coo_sort<value_t>(out, d_alloc, stream);
raft::sparse::op::coo_sort<value_t>(out, d_alloc, stream);
}
} // namespace Naive
} // namespace FuzzySimplSet
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/umap/fuzzy_simpl_set/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace ML;
*/
template <int TPB_X, typename value_idx, typename T>
void run(int n, const value_idx *knn_indices, const T *knn_dists,
int n_neighbors, MLCommon::Sparse::COO<T> *coo, UMAPParams *params,
int n_neighbors, raft::sparse::COO<T> *coo, UMAPParams *params,
std::shared_ptr<deviceAllocator> alloc, cudaStream_t stream,
int algorithm = 0) {
switch (algorithm) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/umap/init_embed/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace ML;
template <typename value_idx, typename T>
void run(const raft::handle_t &handle, int n, int d,
const value_idx *knn_indices, const T *knn_dists,
MLCommon::Sparse::COO<float> *coo, UMAPParams *params, T *embedding,
raft::sparse::COO<float> *coo, UMAPParams *params, T *embedding,
cudaStream_t stream, int algo = 0) {
switch (algo) {
/**
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/umap/init_embed/spectral_algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ using namespace ML;
template <typename value_idx, typename T>
void launcher(const raft::handle_t &handle, int n, int d,
const value_idx *knn_indices, const T *knn_dists,
MLCommon::Sparse::COO<float> *coo, UMAPParams *params,
T *embedding) {
raft::sparse::COO<float> *coo, UMAPParams *params, T *embedding) {
cudaStream_t stream = handle.get_stream();

ASSERT(n > params->n_components,
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/umap/knn_graph/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <iostream>
#include <raft/linalg/unary_op.cuh>
#include <selection/knn.cuh>
#include <sparse/knn.cuh>
#include <sparse/selection/knn.cuh>

#include <raft/cudart_utils.h>

Expand Down Expand Up @@ -85,7 +85,7 @@ void launcher(const raft::handle_t &handle,
const ML::UMAPParams *params,
std::shared_ptr<ML::deviceAllocator> d_alloc,
cudaStream_t stream) {
MLCommon::Sparse::Selection::brute_force_knn(
raft::sparse::selection::brute_force_knn(
inputsA.indptr, inputsA.indices, inputsA.data, inputsA.nnz, inputsA.n,
inputsA.d, inputsB.indptr, inputsB.indices, inputsB.data, inputsB.nnz,
inputsB.n, inputsB.d, out.knn_indices, out.knn_dists, n_neighbors,
Expand Down
43 changes: 23 additions & 20 deletions cpp/src/umap/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
#include <thrust/scan.h>
#include <thrust/system/cuda/execution_policy.h>

#include <sparse/op/sort.h>
#include <sparse/convert/csr.cuh>
#include <sparse/coo.cuh>
#include <sparse/csr.cuh>
#include <sparse/linalg/norm.cuh>
#include <sparse/op/filter.cuh>

#include <raft/cuda_utils.cuh>

Expand All @@ -51,7 +54,6 @@ namespace FuzzySimplSetImpl = FuzzySimplSet::Naive;
namespace SimplSetEmbedImpl = SimplSetEmbed::Algo;

using namespace ML;
using namespace MLCommon::Sparse;

template <int TPB_X, typename T>
__global__ void init_transform(int *indices, T *weights, int n,
Expand Down Expand Up @@ -126,7 +128,7 @@ void _fit(const raft::handle_t &handle, const umap_inputs &inputs,
CUML_LOG_DEBUG("Done. Calling fuzzy simplicial set");

ML::PUSH_RANGE("umap::simplicial_set");
COO<value_t> rgraph_coo(d_alloc, stream);
raft::sparse::COO<value_t> rgraph_coo(d_alloc, stream);
FuzzySimplSet::run<TPB_X, value_idx, value_t>(
inputs.n, knn_graph.knn_indices, knn_graph.knn_dists, k, &rgraph_coo,
params, d_alloc, stream);
Expand All @@ -135,8 +137,8 @@ void _fit(const raft::handle_t &handle, const umap_inputs &inputs,
/**
* Remove zeros from simplicial set
*/
COO<value_t> cgraph_coo(d_alloc, stream);
MLCommon::Sparse::coo_remove_zeros<TPB_X, value_t>(&rgraph_coo, &cgraph_coo,
raft::sparse::COO<value_t> cgraph_coo(d_alloc, stream);
raft::sparse::op::coo_remove_zeros<TPB_X, value_t>(&rgraph_coo, &cgraph_coo,
d_alloc, stream);
ML::POP_RANGE();

Expand Down Expand Up @@ -209,8 +211,8 @@ void _fit_supervised(const raft::handle_t &handle, const umap_inputs &inputs,
* Allocate workspace for fuzzy simplicial set.
*/
ML::PUSH_RANGE("umap::simplicial_set");
COO<value_t> rgraph_coo(d_alloc, stream);
COO<value_t> tmp_coo(d_alloc, stream);
raft::sparse::COO<value_t> rgraph_coo(d_alloc, stream);
raft::sparse::COO<value_t> tmp_coo(d_alloc, stream);

/**
* Run Fuzzy simplicial set
Expand All @@ -221,10 +223,10 @@ void _fit_supervised(const raft::handle_t &handle, const umap_inputs &inputs,
&tmp_coo, params, d_alloc, stream);
CUDA_CHECK(cudaPeekAtLastError());

MLCommon::Sparse::coo_remove_zeros<TPB_X, value_t>(&tmp_coo, &rgraph_coo,
raft::sparse::op::coo_remove_zeros<TPB_X, value_t>(&tmp_coo, &rgraph_coo,
d_alloc, stream);

COO<value_t> final_coo(d_alloc, stream);
raft::sparse::COO<value_t> final_coo(d_alloc, stream);

/**
* If target metric is 'categorical', perform
Expand All @@ -247,10 +249,10 @@ void _fit_supervised(const raft::handle_t &handle, const umap_inputs &inputs,
/**
* Remove zeros
*/
MLCommon::Sparse::coo_sort<value_t>(&final_coo, d_alloc, stream);
raft::sparse::op::coo_sort<value_t>(&final_coo, d_alloc, stream);

COO<value_t> ocoo(d_alloc, stream);
MLCommon::Sparse::coo_remove_zeros<TPB_X, value_t>(&final_coo, &ocoo, d_alloc,
raft::sparse::COO<value_t> ocoo(d_alloc, stream);
raft::sparse::op::coo_remove_zeros<TPB_X, value_t>(&final_coo, &ocoo, d_alloc,
stream);
ML::POP_RANGE();

Expand Down Expand Up @@ -366,7 +368,8 @@ void _transform(const raft::handle_t &handle, const umap_inputs &inputs,
* Allocate workspace for fuzzy simplicial set.
*/

COO<value_t> graph_coo(d_alloc, stream, nnz, inputs.n, inputs.n);
raft::sparse::COO<value_t> graph_coo(d_alloc, stream, nnz, inputs.n,
inputs.n);

FuzzySimplSetImpl::compute_membership_strength_kernel<TPB_X>
<<<grid_nnz, blk, 0, stream>>>(knn_graph.knn_indices, knn_graph.knn_dists,
Expand All @@ -378,17 +381,17 @@ void _transform(const raft::handle_t &handle, const umap_inputs &inputs,
MLCommon::device_buffer<int> row_ind(d_alloc, stream, inputs.n);
MLCommon::device_buffer<int> ia(d_alloc, stream, inputs.n);

MLCommon::Sparse::sorted_coo_to_csr(&graph_coo, row_ind.data(), d_alloc,
stream);
MLCommon::Sparse::coo_row_count<TPB_X>(&graph_coo, ia.data(), stream);
raft::sparse::convert::sorted_coo_to_csr(&graph_coo, row_ind.data(), d_alloc,
stream);
raft::sparse::linalg::coo_degree<TPB_X>(&graph_coo, ia.data(), stream);

MLCommon::device_buffer<value_t> vals_normed(d_alloc, stream, graph_coo.nnz);
CUDA_CHECK(cudaMemsetAsync(vals_normed.data(), 0,
graph_coo.nnz * sizeof(value_t), stream));

CUML_LOG_DEBUG("Performing L1 normalization");

MLCommon::Sparse::csr_row_normalize_l1<TPB_X, value_t>(
raft::sparse::linalg::csr_row_normalize_l1<TPB_X, value_t>(
row_ind.data(), graph_coo.vals(), graph_coo.nnz, graph_coo.n_rows,
vals_normed.data(), stream);

Expand All @@ -402,7 +405,7 @@ void _transform(const raft::handle_t &handle, const umap_inputs &inputs,
CUDA_CHECK(cudaPeekAtLastError());

/**
* Go through COO values and set everything that's less than
* Go through raft::sparse::COO values and set everything that's less than
* vals.max() / params->n_epochs to 0.0
*/
thrust::device_ptr<value_t> d_ptr =
Expand Down Expand Up @@ -437,8 +440,8 @@ void _transform(const raft::handle_t &handle, const umap_inputs &inputs,
/**
* Remove zeros
*/
MLCommon::Sparse::COO<value_t> comp_coo(d_alloc, stream);
MLCommon::Sparse::coo_remove_zeros<TPB_X, value_t>(&graph_coo, &comp_coo,
raft::sparse::COO<value_t> comp_coo(d_alloc, stream);
raft::sparse::op::coo_remove_zeros<TPB_X, value_t>(&graph_coo, &comp_coo,
d_alloc, stream);

ML::PUSH_RANGE("umap::optimization");
Expand Down
8 changes: 5 additions & 3 deletions cpp/src/umap/simpl_set_embed/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <string>
#include "optimize_batch_kernel.cuh"

#include <sparse/op/filter.cuh>

#pragma once

namespace UMAPAlgo {
Expand Down Expand Up @@ -194,7 +196,7 @@ void optimize_layout(T *head_embedding, int head_n, T *tail_embedding,
* and their 1-skeletons.
*/
template <int TPB_X, typename T>
void launcher(int m, int n, MLCommon::Sparse::COO<T> *in, UMAPParams *params,
void launcher(int m, int n, raft::sparse::COO<T> *in, UMAPParams *params,
T *embedding, std::shared_ptr<deviceAllocator> d_alloc,
cudaStream_t stream) {
int nnz = in->nnz;
Expand Down Expand Up @@ -228,8 +230,8 @@ void launcher(int m, int n, MLCommon::Sparse::COO<T> *in, UMAPParams *params,
},
stream);

MLCommon::Sparse::COO<T> out(d_alloc, stream);
MLCommon::Sparse::coo_remove_zeros<TPB_X, T>(in, &out, d_alloc, stream);
raft::sparse::COO<T> out(d_alloc, stream);
raft::sparse::op::coo_remove_zeros<TPB_X, T>(in, &out, d_alloc, stream);

MLCommon::device_buffer<T> epochs_per_sample(d_alloc, stream, out.nnz);
CUDA_CHECK(
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/umap/simpl_set_embed/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace SimplSetEmbed {
using namespace ML;

template <int TPB_X, typename T>
void run(int m, int n, MLCommon::Sparse::COO<T> *coo, UMAPParams *params,
void run(int m, int n, raft::sparse::COO<T> *coo, UMAPParams *params,
T *embedding, std::shared_ptr<deviceAllocator> alloc,
cudaStream_t stream, int algorithm = 0) {
switch (algorithm) {
Expand Down
Loading