From 0f9b62188c9f427e63a577810109ac6e16387d74 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 18 May 2023 11:15:21 -0700 Subject: [PATCH 1/8] update to new API --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- cpp/src/metrics/pairwise_distance.cu | 33 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 24b2db76ea..cfc09c7b28 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -85,8 +85,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${CUML_MIN_VERSION_raft} - FORK rapidsai - PINNED_TAG branch-${CUML_BRANCH_VERSION_raft} + FORK divyegala + PINNED_TAG sparse_pairwise_distances-api EXCLUDE_FROM_ALL ${CUML_EXCLUDE_RAFT_FROM_ALL} # When PINNED_TAG above doesn't match cuml, # force local raft clone in build directory diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index 1928091c33..a724667b39 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -164,23 +164,28 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, raft::distance::DistanceType metric, float metric_arg) { - raft::sparse::distance::distances_config_t dist_config(handle); + auto out = raft::make_device_matrix_view( + dists, + x_nrows, + y_nrows); - dist_config.b_nrows = x_nrows; - dist_config.b_ncols = n_cols; - dist_config.b_nnz = x_nnz; - dist_config.b_indptr = x_indptr; - dist_config.b_indices = x_indices; - dist_config.b_data = x; + auto x_structure = raft::make_device_compressed_structure_view( + x_indptr, + x_indices, + x_nrows, + n_cols, + x_nnz); + auto x_csr_view = raft::make_device_csr_matrix_view(x, x_structure); - dist_config.a_nrows = y_nrows; - dist_config.a_ncols = n_cols; - dist_config.a_nnz = y_nnz; - dist_config.a_indptr = y_indptr; - dist_config.a_indices = y_indices; - dist_config.a_data = y; + auto y_structure = raft::make_device_compressed_structure_view( + y_indptr, + y_indices, + y_nrows, + n_cols, + y_nnz); + auto y_csr_view = raft::make_device_csr_matrix_view(x, x_structure); - raft::sparse::distance::pairwiseDistance(dist, dist_config, metric, metric_arg); + raft::sparse::distance::pairwise_distance(handle, x_csr_view, y_csr_view, out, metric, metric_arg); } void pairwiseDistance_sparse(const raft::handle_t& handle, From 75e221b5c5da823094179f9b81f3990f38db47fb Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 18 May 2023 11:19:51 -0700 Subject: [PATCH 2/8] run pre-commit --- cpp/src/metrics/pairwise_distance.cu | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index a724667b39..5949b4dc2d 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -1,6 +1,6 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,28 +164,18 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, raft::distance::DistanceType metric, float metric_arg) { - auto out = raft::make_device_matrix_view( - dists, - x_nrows, - y_nrows); + auto out = raft::make_device_matrix_view(dists, x_nrows, y_nrows); auto x_structure = raft::make_device_compressed_structure_view( - x_indptr, - x_indices, - x_nrows, - n_cols, - x_nnz); + x_indptr, x_indices, x_nrows, n_cols, x_nnz); auto x_csr_view = raft::make_device_csr_matrix_view(x, x_structure); auto y_structure = raft::make_device_compressed_structure_view( - y_indptr, - y_indices, - y_nrows, - n_cols, - y_nnz); + y_indptr, y_indices, y_nrows, n_cols, y_nnz); auto y_csr_view = raft::make_device_csr_matrix_view(x, x_structure); - raft::sparse::distance::pairwise_distance(handle, x_csr_view, y_csr_view, out, metric, metric_arg); + raft::sparse::distance::pairwise_distance( + handle, x_csr_view, y_csr_view, out, metric, metric_arg); } void pairwiseDistance_sparse(const raft::handle_t& handle, From bcec0e1b4a23f92fa3a614405a2f34b761716e8d Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 18 May 2023 11:59:00 -0700 Subject: [PATCH 3/8] remove unnecessary include --- cpp/src/metrics/pairwise_distance.cu | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index 5949b4dc2d..88e47d316e 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -31,7 +31,6 @@ #include #include #include -#include #include namespace ML { From e7dfb047d9f582c3efcc257db3fbc45c0d766f1f Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 18 May 2023 12:44:28 -0700 Subject: [PATCH 4/8] fix another error --- cpp/src/metrics/pairwise_distance.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index 88e47d316e..0946ada9e4 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -163,7 +163,7 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, raft::distance::DistanceType metric, float metric_arg) { - auto out = raft::make_device_matrix_view(dists, x_nrows, y_nrows); + auto out = raft::make_device_matrix_view(dist, x_nrows, y_nrows); auto x_structure = raft::make_device_compressed_structure_view( x_indptr, x_indices, x_nrows, n_cols, x_nnz); From 88808d5cf79d1819da186dfe1ce4525c9ed4e0bd Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 18 May 2023 13:14:45 -0700 Subject: [PATCH 5/8] fix more errors --- cpp/src/metrics/pairwise_distance.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index 0946ada9e4..50e2b72189 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -171,7 +171,7 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, auto y_structure = raft::make_device_compressed_structure_view( y_indptr, y_indices, y_nrows, n_cols, y_nnz); - auto y_csr_view = raft::make_device_csr_matrix_view(x, x_structure); + auto y_csr_view = raft::make_device_csr_matrix_view(y, y_structure); raft::sparse::distance::pairwise_distance( handle, x_csr_view, y_csr_view, out, metric, metric_arg); From 7a8758dd404171e46651f43a97e3c32ee3039ab6 Mon Sep 17 00:00:00 2001 From: Divye Gala Date: Wed, 28 Jun 2023 15:46:17 -0400 Subject: [PATCH 6/8] Update pairwise_distance.cu --- cpp/src/metrics/pairwise_distance.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index 50e2b72189..c7d2427b70 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -174,7 +174,7 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, auto y_csr_view = raft::make_device_csr_matrix_view(y, y_structure); raft::sparse::distance::pairwise_distance( - handle, x_csr_view, y_csr_view, out, metric, metric_arg); + handle, y_csr_view, x_csr_view, out, metric, metric_arg); } void pairwiseDistance_sparse(const raft::handle_t& handle, From 782238adf241458ab2b25de8befb5612e5b7eb40 Mon Sep 17 00:00:00 2001 From: Divye Gala Date: Wed, 28 Jun 2023 17:17:36 -0400 Subject: [PATCH 7/8] Update pairwise_distance.cu --- cpp/src/metrics/pairwise_distance.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/metrics/pairwise_distance.cu b/cpp/src/metrics/pairwise_distance.cu index c7d2427b70..7a05e9b63d 100644 --- a/cpp/src/metrics/pairwise_distance.cu +++ b/cpp/src/metrics/pairwise_distance.cu @@ -163,7 +163,7 @@ void pairwiseDistance_sparse(const raft::handle_t& handle, raft::distance::DistanceType metric, float metric_arg) { - auto out = raft::make_device_matrix_view(dist, x_nrows, y_nrows); + auto out = raft::make_device_matrix_view(dist, y_nrows, x_nrows); auto x_structure = raft::make_device_compressed_structure_view( x_indptr, x_indices, x_nrows, n_cols, x_nnz); From 90a8553f3527b4b50085e6c0f09fc584d40c1667 Mon Sep 17 00:00:00 2001 From: divyegala Date: Mon, 3 Jul 2023 09:26:05 -0700 Subject: [PATCH 8/8] revert raft pin --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index cfc09c7b28..24b2db76ea 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -85,8 +85,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${CUML_MIN_VERSION_raft} - FORK divyegala - PINNED_TAG sparse_pairwise_distances-api + FORK rapidsai + PINNED_TAG branch-${CUML_BRANCH_VERSION_raft} EXCLUDE_FROM_ALL ${CUML_EXCLUDE_RAFT_FROM_ALL} # When PINNED_TAG above doesn't match cuml, # force local raft clone in build directory