[Misc] Add a wrapper for torch.inference_mode (#6618)

This commit is contained in:
Woosuk Kwon
2024-07-21 18:43:11 -07:00
committed by GitHub
parent c9eef37f32
commit 42de2cefcb
5 changed files with 49 additions and 4 deletions
+17
View File
@@ -0,0 +1,17 @@
from typing import Tuple
import torch
from .interface import Platform, PlatformEnum
class TpuPlatform(Platform):
_enum = PlatformEnum.TPU
@staticmethod
def get_device_capability(device_id: int = 0) -> Tuple[int, int]:
raise RuntimeError("TPU does not have device capability.")
@staticmethod
def inference_mode():
return torch.no_grad()