[platforms] improve error message for unspecified platforms (#10520)

Signed-off-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
youkaichao 2024-11-20 23:07:56 -08:00 committed by GitHub
parent 3430857b64
commit aaddce5d26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -1191,12 +1191,13 @@ class SchedulerConfig:
class DeviceConfig:
device: Optional[torch.device]
device_type: str
def __init__(self, device: str = "auto") -> None:
if device == "auto":
# Automated device type detection
self.device_type = current_platform.device_type
if self.device_type is None:
if not self.device_type:
raise RuntimeError("Failed to infer device type")
else:
# Device type is assigned explicitly

View File

@ -170,3 +170,4 @@ class Platform:
class UnspecifiedPlatform(Platform):
_enum = PlatformEnum.UNSPECIFIED
device_type = ""