11#
2- # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+ # SPDX-FileCopyrightText: Copyright (c) 2025-2026 , NVIDIA CORPORATION.
33# SPDX-License-Identifier: Apache-2.0
44#
55
66import cuml .neighbors
77from cuml .accel .estimator_proxy import ProxyBase
8+ from cuml .common .sparse_utils import is_sparse
9+ from cuml .internals .interop import UnsupportedOnGPU
810
911__all__ = (
1012 "NearestNeighbors" ,
@@ -18,6 +20,21 @@ class NearestNeighbors(ProxyBase):
1820 _gpu_class = cuml .neighbors .NearestNeighbors
1921 _other_attributes = frozenset (("_fit_method" , "_tree" , "_fit_X" ))
2022
23+ def _gpu_radius_neighbors_graph (
24+ self , X = None , radius = None , mode = "connectivity" , sort_results = False
25+ ):
26+ if mode != "connectivity" :
27+ raise UnsupportedOnGPU (f"`mode={ mode !r} ` is not supported" )
28+ if sort_results :
29+ raise UnsupportedOnGPU ("`sort_results=True` is not supported" )
30+ if is_sparse (X ):
31+ raise UnsupportedOnGPU ("Sparse inputs are not supported" )
32+ if self .effective_metric_ not in cuml .neighbors .VALID_METRICS ["rbc" ]:
33+ raise UnsupportedOnGPU (
34+ f"metric={ self .effective_metric_ !r} is not supported"
35+ )
36+ return self ._gpu .radius_neighbors_graph (X = X , radius = radius )
37+
2138
2239class KNeighborsClassifier (ProxyBase ):
2340 _gpu_class = cuml .neighbors .KNeighborsClassifier
0 commit comments