xref: /aosp_15_r20/external/pytorch/torch/_streambase.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# mypy: allow-untyped-defs
2from abc import ABC, abstractmethod
3
4
5class _StreamBase(ABC):
6    r"""Base stream class abstraction for multi backends Stream to herit from"""
7
8    @abstractmethod
9    def wait_event(self, event) -> None:
10        raise NotImplementedError
11
12    @abstractmethod
13    def wait_stream(self, stream) -> None:
14        raise NotImplementedError
15
16    @abstractmethod
17    def record_event(self, event=None) -> None:
18        raise NotImplementedError
19
20    @abstractmethod
21    def query(self) -> bool:
22        raise NotImplementedError
23
24    @abstractmethod
25    def synchronize(self) -> None:
26        raise NotImplementedError
27
28    @abstractmethod
29    def __eq__(self, stream) -> bool:
30        raise NotImplementedError
31
32
33class _EventBase(ABC):
34    r"""Base Event class abstraction for multi backends Event to herit from"""
35
36    @abstractmethod
37    def wait(self, stream=None) -> None:
38        raise NotImplementedError
39
40    @abstractmethod
41    def query(self) -> bool:
42        raise NotImplementedError
43
44    @abstractmethod
45    def synchronize(self) -> None:
46        raise NotImplementedError
47