tpu.py 378 B

1234567891011121314151617
  1. from typing import Tuple
  2. import torch
  3. from .interface import Platform, PlatformEnum
  4. class TpuPlatform(Platform):
  5. _enum = PlatformEnum.TPU
  6. @staticmethod
  7. def get_device_capability(device_id: int = 0) -> Tuple[int, int]:
  8. raise RuntimeError("TPU does not have device capability.")
  9. @staticmethod
  10. def inference_mode():
  11. return torch.no_grad()