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

ANN subsample dataset: use mdspan input #2111

Open
tfeher opened this issue Jan 23, 2024 · 0 comments
Open

ANN subsample dataset: use mdspan input #2111

tfeher opened this issue Jan 23, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@tfeher
Copy link
Contributor

tfeher commented Jan 23, 2024

Currently neighbors::detail::utils::subsample takes the dataset input as plain pointer.

The input shall be replaced with an mdspan. This is not done in #2077, because the following question needs to be clarified:

What is the right way to map a pointer for raft mdspan API, if I do not know (and do not care) whether the pointer is on host or device?

One way to do that is to query the pointer attribute and map it accordingly

  cudaPointerAttributes attr;
  RAFT_CUDA_TRY(cudaPointerGetAttributes(&attr, input));
  T* ptr = reinterpret_cast<T*>(attr.devicePointer);
  if (ptr != nullptr) {
    auto dataset = raft::make_device_matrix_view<const T, IdxT>(ptr, n_samples, n_dim);
    my_function(res, dataset);
  } else {
     auto dataset = raft::make_host_matrix_view<const T, IdxT>(input, n_samples, n_dim);
    my_function(res, dataset);
}

But if my_function does only pass the arrays to a third function, then I would need a plain mdspan without any host or device annotation. Shall we work with plain std::experimental::mdspan, or do we want to allow host_device_accessor that has no information about where the data is accessible?

@tfeher tfeher added the feature request New feature or request label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant