Attention

The vector search and clustering algorithms in RAFT are being migrated to a new library dedicated to vector search called cuVS. We will continue to support the vector search algorithms in RAFT during this move, but will no longer update them after the RAPIDS 24.06 (June) release. We plan to complete the migration by RAPIDS 24.10 (October) release and they will be removed from RAFT altogether in the 24.12 (December) release.

Epsilon Neighborhood#

#include <raft/neighbors/epsilon_neighborhood.cuh>

namespace raft::neighbors::epsilon_neighborhood

template<typename value_t, typename idx_t, typename matrix_idx_t>
void eps_neighbors_l2sq(raft::resources const &handle, raft::device_matrix_view<const value_t, matrix_idx_t, row_major> x, raft::device_matrix_view<const value_t, matrix_idx_t, row_major> y, raft::device_matrix_view<bool, matrix_idx_t, row_major> adj, raft::device_vector_view<idx_t, matrix_idx_t> vd, value_t eps)#

Computes epsilon neighborhood for the L2-Squared distance metric and given ball size. The epsilon neighbors is represented by a dense boolean adjacency matrix of size m * n and an array of degrees for each vertex, which can be used as a compressed sparse row (CSR) indptr array.

#include <raft/neighbors/epsilon_neighborhood.cuh>
#include <raft/core/resources.hpp>
#include <raft/core/device_mdarray.hpp>
using namespace raft::neighbors;
raft::raft::resources handle;
...
auto adj = raft::make_device_matrix<bool>(handle, m * n);
auto vd = raft::make_device_vector<int>(handle, m+1);
epsilon_neighborhood::eps_neighbors_l2sq(handle, x, y, adj.view(), vd.view(), eps);
Template Parameters:
  • value_t – IO and math type

  • idx_t – Index type

  • matrix_idx_t – matrix indexing type

Parameters:
  • handle[in] raft handle to manage library resources

  • x[in] first matrix [row-major] [on device] [dim = m x k]

  • y[in] second matrix [row-major] [on device] [dim = n x k]

  • adj[out] adjacency matrix [row-major] [on device] [dim = m x n]

  • vd[out] vertex degree array [on device] [len = m + 1] vd + m stores the total number of edges in the adjacency matrix. Pass a nullptr if you don’t need this info.

  • eps[in] defines epsilon neighborhood radius (should be passed as squared as we compute L2-squared distance in this method)