[Platforms] Add device_type in Platform (#10508)

Signed-off-by: MengqingCao <cmq0113@163.com>
This commit is contained in:
Mengqing Cao
2024-11-21 04:44:20 +00:00
committed by GitHub
parent 6c1208d083
commit 9d827170a3
10 changed files with 11 additions and 15 deletions
+2 -15
View File
@@ -1193,21 +1193,8 @@ class DeviceConfig:
def __init__(self, device: str = "auto") -> None:
if device == "auto":
# Automated device type detection
if current_platform.is_cuda_alike():
self.device_type = "cuda"
elif current_platform.is_neuron():
self.device_type = "neuron"
elif current_platform.is_hpu():
self.device_type = "hpu"
elif current_platform.is_openvino():
self.device_type = "openvino"
elif current_platform.is_tpu():
self.device_type = "tpu"
elif current_platform.is_cpu():
self.device_type = "cpu"
elif current_platform.is_xpu():
self.device_type = "xpu"
else:
self.device_type = current_platform.device_type
if self.device_type is None:
raise RuntimeError("Failed to infer device type")
else:
# Device type is assigned explicitly