Skip to content
Open
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
5 changes: 5 additions & 0 deletions c/include/cuvs/neighbors/nn_descent.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ extern "C" {
* `max_iterations`: The number of iterations that nn-descent will refine
* the graph for. More iterations produce a better quality graph at cost of performance
* `termination_threshold`: The delta at which nn-descent will terminate its iterations
* `return_distances`: Boolean to decide whether to return distances array
* `fp32_dist_computation`: Boolean to decide whether to use fp32 distance computation for better
* precision at the cost of performance and memory usage. We recommend using this for smaller
* dimensions or if the distances array is needed for precision-sensitive workloads.
*/
struct cuvsNNDescentIndexParams {
cuvsDistanceType metric;
Expand All @@ -43,6 +47,7 @@ struct cuvsNNDescentIndexParams {
size_t max_iterations;
float termination_threshold;
bool return_distances;
bool fp32_dist_computation;
};

typedef struct cuvsNNDescentIndexParams* cuvsNNDescentIndexParams_t;
Expand Down
4 changes: 3 additions & 1 deletion c/src/neighbors/nn_descent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void* _build(cuvsResources_t res,
build_params.max_iterations = params.max_iterations;
build_params.termination_threshold = params.termination_threshold;
build_params.return_distances = params.return_distances;
build_params.fp32_dist_computation = params.fp32_dist_computation;

using graph_type = raft::host_matrix_view<IdxT, int64_t, raft::row_major>;
std::optional<graph_type> graph;
Expand Down Expand Up @@ -177,7 +178,8 @@ extern "C" cuvsError_t cuvsNNDescentIndexParamsCreate(cuvsNNDescentIndexParams_t
.intermediate_graph_degree = cpp_params.intermediate_graph_degree,
.max_iterations = cpp_params.max_iterations,
.termination_threshold = cpp_params.termination_threshold,
.return_distances = cpp_params.return_distances};
.return_distances = cpp_params.return_distances,
.fp32_dist_computation = cpp_params.fp32_dist_computation};
});
}

Expand Down
4 changes: 4 additions & 0 deletions cpp/include/cuvs/neighbors/nn_descent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ namespace cuvs::neighbors::nn_descent {
* the graph for. More iterations produce a better quality graph at cost of performance
* - `termination_threshold`: The delta at which nn-descent will terminate its iterations
* - `return_distances`: Boolean to decide whether to return distances array
* - `fp32_dist_computation`: Boolean to decide whether to use fp32 distance computation for better
* precision at the cost of performance and memory usage. We recommend using this for smaller
* dimensions or if the distances array is needed for precision-sensitive workloads.
*/
struct index_params : cuvs::neighbors::index_params {
size_t graph_degree = 64;
size_t intermediate_graph_degree = 128;
size_t max_iterations = 20;
float termination_threshold = 0.0001;
bool return_distances = true;
bool fp32_dist_computation = false;

/** @brief Construct NN descent parameters for a specific kNN graph degree
*
Expand Down
Loading
Loading