-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathkernels_data.pyi
More file actions
131 lines (104 loc) · 3.22 KB
/
kernels_data.pyi
File metadata and controls
131 lines (104 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""Type stubs for kernels_data module."""
import os
from enum import Enum
from typing import Optional, final
__all__ = ["Backend", "BackendInfo", "KernelName", "Metadata", "Version", "__version__"]
__version__: str
@final
class Backend(Enum):
"""Kernel backend (hardware target)."""
CANN = "CANN"
CPU = "CPU"
CUDA = "CUDA"
Metal = "Metal"
Neuron = "Neuron"
ROCm = "ROCm"
XPU = "XPU"
@staticmethod
def from_str(s: str) -> "Backend":
"""Parse a backend name.
Args:
s: One of ``"cann"``, ``"cpu"``, ``"cuda"``, ``"metal"``,
``"neuron"``, ``"rocm"``, ``"xpu"``.
Raises:
ValueError: If the backend name is unknown.
"""
...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
@final
class BackendInfo:
"""Backend information."""
@property
def backend_type(self) -> Backend:
"""Return the backend type."""
...
@property
def archs(self) -> Optional[list[str]]:
"""Optional list of target architectures."""
...
def __repr__(self) -> str: ...
@final
class Version:
"""A dotted numeric version (e.g. ``12.8.0``).
Trailing zeros are stripped during normalization.
"""
@staticmethod
def from_str(s: str) -> "Version":
"""Parse a version string of the form ``X``, ``X.Y``, ``X.Y.Z``, ...
Raises:
ValueError: If the string is empty or contains non-numeric parts.
"""
...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __eq__(self, value: object, /) -> bool: ...
def __lt__(self, value: "Version", /) -> bool: ...
def __le__(self, value: "Version", /) -> bool: ...
def __gt__(self, value: "Version", /) -> bool: ...
def __ge__(self, value: "Version", /) -> bool: ...
def __hash__(self) -> int: ...
@final
class KernelName:
"""A validated kernel name matching ``^[a-z][-a-z0-9]*[a-z0-9]$``."""
def __new__(cls, name: str) -> "KernelName":
"""Create a new ``KernelName``.
Raises:
ValueError: If the name does not match the required pattern.
"""
...
@property
def python_name(self) -> str:
"""The name with dashes replaced by underscores."""
...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
@final
class Metadata:
"""Parsed ``metadata.json`` for a kernel build variant."""
@staticmethod
def read_from_file(metadata_path: os.PathLike[str] | str) -> "Metadata":
"""Parse ``metadata.json`` at the given path.
Raises:
ValueError: On any I/O or parse error.
"""
...
@property
def id(self) -> str: ...
@property
def name(self) -> KernelName: ...
@property
def version(self) -> Optional[int]: ...
@property
def license(self) -> Optional[str]: ...
@property
def upstream(self) -> Optional[str]: ...
@property
def source(self) -> Optional[str]: ...
@property
def python_depends(self) -> list[str]: ...
@property
def backend(self) -> BackendInfo: ...
def __repr__(self) -> str: ...