Hardware device where the array data resides on.
(array)
| 189 | |
| 190 | |
| 191 | def _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 | |
| 207 | def device(*array_list, remove_none=True, remove_types=REMOVE_TYPES_DEFAULT): |
no test coverage detected
searching dependent graphs…