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

can k >100 in knn? #199

Open
heyfavour opened this issue Nov 24, 2023 · 2 comments
Open

can k >100 in knn? #199

heyfavour opened this issue Nov 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@heyfavour
Copy link

when i use knn to calculate atom neighbour,it's easy count > 100,can i set k > 100?
in your cuda code u set k<=100

https://github.com/rusty1s/pytorch_cluster/blob/master/csrc/cuda/knn_cuda.cu line 98
AT_ASSERTM(k <= 100, "k needs to smaller than or equal to 100");

@heyfavour heyfavour changed the title can k in knn >100? can k >100 in knn? Nov 24, 2023
@rusty1s
Copy link
Owner

rusty1s commented Nov 26, 2023

Yes, currently we fix the maximum number of neighbors to 100. One way to increase this would be via templating, so that we can create specific kernels depending on the number of k, e.g.

template <typename, scalar_t, int max_k>
knn_kernel(...) {

}

torch::Tensor knn_cuda(...) {
  if (k <= 32) {
      knn_kernel<scalar_t, 32>(...);
  } else if (k <= 64) {
      knn_kernel<scalar>t, 64>(...);
  } ...
}

I don't have time to implement this right now. Do you have interest in adding this solution?

Copy link

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

@github-actions github-actions bot added the stale label May 25, 2024
@rusty1s rusty1s added enhancement New feature or request and removed stale labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants