[misc]refactor Platform.set_device method (#20262)

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
Kunshang Ji
2025-07-09 01:39:47 +00:00
committed by GitHub
parent 5eaf570050
commit 0b407479ef
9 changed files with 43 additions and 4 deletions
+7
View File
@@ -75,6 +75,13 @@ class CpuPlatform(Platform):
def get_device_total_memory(cls, device_id: int = 0) -> int:
return psutil.virtual_memory().total
@classmethod
def set_device(cls, device: torch.device) -> None:
"""
Set the device for the current platform.
"""
torch.cpu.set_device(device)
@classmethod
def is_async_output_supported(cls, enforce_eager: Optional[bool]) -> bool:
return False