cpu.py 288 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import torch

from .interface import Platform, PlatformEnum


class CpuPlatform(Platform):
    _enum = PlatformEnum.CPU

    @staticmethod
    def get_device_name(device_id: int = 0) -> str:
        return "cpu"

    @staticmethod
    def inference_mode():
        return torch.no_grad()