MCPcopy Index your code
hub / github.com/huggingface/diffusers / get_device

Function get_device

src/diffusers/utils/torch_utils.py:288–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286
287@functools.lru_cache
288def get_device():
289 if torch.cuda.is_available():
290 return "cuda"
291 elif is_torch_npu_available():
292 return "npu"
293 elif hasattr(torch, "xpu") and torch.xpu.is_available():
294 return "xpu"
295 elif torch.backends.mps.is_available():
296 return "mps"
297 elif is_torch_mlu_available():
298 return "mlu"
299 else:
300 return "cpu"
301
302
303def empty_device_cache(device_type: str | None = None):

Callers 15

empty_device_cacheFunction · 0.85
device_synchronizeFunction · 0.85
torch_utils.pyFile · 0.85
pipeline_utils.pyFile · 0.85
__call__Method · 0.85
__call__Method · 0.85
__call__Method · 0.85
__call__Method · 0.85
__call__Method · 0.85
__call__Method · 0.85

Calls 2

is_torch_npu_availableFunction · 0.85
is_torch_mlu_availableFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…