File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from enum import IntEnum
2+
3+
4+ class DataAvailability (IntEnum ):
5+ """
6+ Indicates whether the device or host contains valid data.
7+ """
8+ AVAILABLE_ON_HOST_ONLY = 1
9+ AVAILABLE_ON_DEVICE_ONLY = 2
10+ AVAILABLE_ON_BOTH = 3
11+
12+
13+ class OffloadMixin :
14+ def get_availability (self ):
15+ raise NotImplementedError
16+
17+ def ensure_availability_on_host (self ):
18+ raise NotImplementedError
19+
20+ def ensure_availaibility_on_device (self ):
21+ raise NotImplementedError
22+
23+ def is_available_on_host (self ):
24+ return bool (self .get_availability () & AVAILABLE_ON_HOST_ONLY )
25+
26+ def is_available_on_device (self ):
27+ return bool (self .get_availability () & AVAILABLE_ON_DEVICE_ONLY )
28+
29+
30+ AVAILABLE_ON_HOST_ONLY = DataAvailability .AVAILABLE_ON_HOST_ONLY
31+ AVAILABLE_ON_DEVICE_ONLY = DataAvailability .AVAILABLE_ON_DEVICE_ONLY
32+ AVAILABLE_ON_BOTH = DataAvailability .AVAILABLE_ON_BOTH
You can’t perform that action at this time.
0 commit comments