MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / _single_array_device

Function _single_array_device

sklearn/utils/_array_api.py:191–204  ·  view source on GitHub ↗

Hardware device where the array data resides on.

(array)

Source from the content-addressed store, hash-verified

189
190
191def _single_array_device(array):
192 """Hardware device where the array data resides on."""
193 if (
194 not hasattr(array, "device")
195 # When array API dispatch is disabled, we expect the scikit-learn code
196 # to use np.asarray so that the resulting NumPy array will implicitly use the
197 # CPU. In this case, scikit-learn should stay as device neutral as possible,
198 # hence the use of `device=None` which is accepted by all libraries, before
199 # and after the expected conversion to NumPy via np.asarray.
200 or not get_config()["array_api_dispatch"]
201 ):
202 return None
203 else:
204 return array.device
205
206
207def device(*array_list, remove_none=True, remove_types=REMOVE_TYPES_DEFAULT):

Callers 1

deviceFunction · 0.85

Calls 1

get_configFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…