MCPcopy
hub / github.com/huggingface/transformers / is_accelerator_device

Function is_accelerator_device

src/transformers/modeling_utils.py:4981–4988  ·  view source on GitHub ↗

Check if the device is an accelerator. We need to function, as device_map can be "disk" as well, which is not a proper `torch.device`.

(device: str | int | torch.device)

Source from the content-addressed store, hash-verified

4979
4980
4981def is_accelerator_device(device: str | int | torch.device) -> bool:
4982 """Check if the device is an accelerator. We need to function, as device_map can be "disk" as well, which is not
4983 a proper `torch.device`.
4984 """
4985 if device == "disk":
4986 return False
4987 else:
4988 return torch.device(device).type not in ["meta", "cpu"]
4989
4990
4991def get_total_byte_count(

Callers 1

caching_allocator_warmupFunction · 0.85

Calls 1

deviceMethod · 0.45

Tested by

no test coverage detected