File size: 6,179 Bytes
59f1501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from ctypes import c_void_p
from typing import overload, Protocol

from torch import Tensor

# Defined in torch/csrc/inductor/aoti_runner/pybind.cpp

# Tensor to AtenTensorHandle
def unsafe_alloc_void_ptrs_from_tensors(tensors: list[Tensor]) -> list[c_void_p]: ...
def unsafe_alloc_void_ptr_from_tensor(tensor: Tensor) -> c_void_p: ...

# AtenTensorHandle to Tensor
def alloc_tensors_by_stealing_from_void_ptrs(

    handles: list[c_void_p],

) -> list[Tensor]: ...
def alloc_tensor_by_stealing_from_void_ptr(

    handle: c_void_p,

) -> Tensor: ...

class AOTIModelContainerRunner(Protocol):
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
    def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
    def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def swap_constant_buffer(self) -> None: ...
    def free_inactive_constant_buffer(self) -> None: ...

class AOTIModelContainerRunnerCpu:
    def __init__(self, model_so_path: str, num_models: int) -> None: ...
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
    def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
    def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def swap_constant_buffer(self) -> None: ...
    def free_inactive_constant_buffer(self) -> None: ...

class AOTIModelContainerRunnerCuda:
    @overload
    def __init__(self, model_so_path: str, num_models: int) -> None: ...
    @overload
    def __init__(

        self, model_so_path: str, num_models: int, device_str: str

    ) -> None: ...
    @overload
    def __init__(

        self, model_so_path: str, num_models: int, device_str: str, cubin_dir: str

    ) -> None: ...
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
    def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
    def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def swap_constant_buffer(self) -> None: ...
    def free_inactive_constant_buffer(self) -> None: ...

class AOTIModelContainerRunnerXpu:
    @overload
    def __init__(self, model_so_path: str, num_models: int) -> None: ...
    @overload
    def __init__(

        self, model_so_path: str, num_models: int, device_str: str

    ) -> None: ...
    @overload
    def __init__(

        self, model_so_path: str, num_models: int, device_str: str, kernel_bin_dir: str

    ) -> None: ...
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
    def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
    def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def swap_constant_buffer(self) -> None: ...
    def free_inactive_constant_buffer(self) -> None: ...

class AOTIModelContainerRunnerMps:
    def __init__(self, model_so_path: str, num_models: int) -> None: ...
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
    def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
    def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def swap_constant_buffer(self) -> None: ...
    def free_inactive_constant_buffer(self) -> None: ...

# Defined in torch/csrc/inductor/aoti_package/pybind.cpp
class AOTIModelPackageLoader:
    def __init__(

        self,

        model_package_path: str,

        model_name: str,

        run_single_threaded: bool,

        num_runners: int,

        device_index: int,

    ) -> None: ...
    def get_metadata(self) -> dict[str, str]: ...
    def run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def boxed_run(

        self, inputs: list[Tensor], stream_handle: c_void_p = ...

    ) -> list[Tensor]: ...
    def get_call_spec(self) -> list[str]: ...
    def get_constant_fqns(self) -> list[str]: ...
    def load_constants(

        self,

        constants_map: dict[str, Tensor],

        use_inactive: bool,

        check_full_update: bool,

        user_managed: bool = ...,

    ) -> None: ...
    def update_constant_buffer(

        self,

        tensor_map: dict[str, Tensor],

        use_inactive: bool,

        validate_full_updates: bool,

        user_managed: bool = ...,

    ) -> None: ...