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)
| 4979 | |
| 4980 | |
| 4981 | def 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 | |
| 4991 | def get_total_byte_count( |
no test coverage detected