[Misc] Refactor platform to get device specific stream and event (#14411)

Signed-off-by: shen-shanshan <467638484@qq.com>
This commit is contained in:
Shanshan Shen
2025-04-21 21:25:49 +08:00
committed by GitHub
parent d9ac9e3dc5
commit 7272bfae77
2 changed files with 15 additions and 5 deletions
+9
View File
@@ -404,6 +404,15 @@ class Platform:
) -> None:
"""Raises if this request is unsupported on this platform"""
def __getattr__(self, key: str):
device = getattr(torch, self.device_name, None)
if device is not None and hasattr(device, key):
return getattr(device, key)
else:
logger.warning("Current platform %s doesn't has '%s' attribute.",
self.device_name, key)
return None
class UnspecifiedPlatform(Platform):
_enum = PlatformEnum.UNSPECIFIED