Skip to content

Commit

Permalink
Use the index_.graph() view instead of graph_ (which is sometimes nul…
Browse files Browse the repository at this point in the history
…lptr)
  • Loading branch information
achirkin committed Feb 27, 2025
1 parent 84475d0 commit 2a7b310
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cpp/bench/ann/src/cuvs/cuvs_cagra_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ void cuvs_cagra<T, IdxT>::set_search_param(const search_param_base& param,
auto mr = get_mr(graph_mem_);

// Create a new graph, then copy, and __only then__ replace the shared pointer.
// We shouldn't use index_->graph() here, because it may be just a view of graph_.
auto new_graph = raft::make_device_mdarray<IdxT, int64_t>(handle_, mr, graph_->extents());
auto old_graph =
index_->graph(); // view of graph_ if it exists, of an internal index member otherwise
auto new_graph = raft::make_device_mdarray<IdxT, int64_t>(handle_, mr, old_graph.extents());
raft::copy(new_graph.data_handle(),
graph_->data_handle(),
graph_->size(),
old_graph.data_handle(),
old_graph.size(),
raft::resource::get_cuda_stream(handle_));
raft::resource::sync_stream(handle_);
*graph_ = std::move(new_graph);
Expand Down

0 comments on commit 2a7b310

Please sign in to comment.