@@ -21,21 +21,23 @@ PyMODINIT_FUNC PyInit__radius_cpu(void) { return NULL; }
2121#endif
2222
2323CLUSTER_API torch::Tensor radius (torch::Tensor x, torch::Tensor y,
24- std::optional<torch::Tensor> ptr_x,
25- std::optional<torch::Tensor> ptr_y, double r,
26- int64_t max_num_neighbors,
27- int64_t num_workers,
28- bool ignore_same_index) {
29- return radius_cpu (x, y, ptr_x, ptr_y, r, max_num_neighbors, num_workers,
30- ignore_same_index);
31- }
32-
33- TORCH_LIBRARY (torch_cluster, m) {
34- m.def (" radius(Tensor x, Tensor y, Tensor? ptr_x, Tensor? ptr_y, float r, int max_num_neighbors, int num_workers = 1, bool ignore_same_index = False) -> Tensor" );
24+ std::optional<torch::Tensor> ptr_x,
25+ std::optional<torch::Tensor> ptr_y, double r,
26+ int64_t max_num_neighbors, int64_t num_workers,
27+ bool ignore_same_index) {
28+ if (x.device ().is_cuda ()) {
29+ #ifdef WITH_CUDA
30+ return radius_cuda (x, y, ptr_x, ptr_y, r, max_num_neighbors, ignore_same_index);
31+ #else
32+ AT_ERROR (" Not compiled with CUDA support" );
33+ #endif
34+ } else {
35+ return radius_cpu (x, y, ptr_x, ptr_y, r, max_num_neighbors, num_workers, ignore_same_index);
36+ }
3537}
3638
3739TORCH_LIBRARY_IMPL (torch_cluster, CPU , m) {
38- m.impl (" radius" , &radius );
40+ m.impl (" radius" , &radius_cpu );
3941}
4042
4143#ifdef WITH_CUDA
0 commit comments