MCPcopy
hub / github.com/apache/tvm / rpc_run

Function rpc_run

python/tvm/testing/runner.py:152–235  ·  view source on GitHub ↗

Run a TVM module on a remote device. Parameters ---------- mod : Module The TVM module to run. device_type : str The device type to run the module on. args : List[Union[np.ndarray, Tensor, int, float]] The arguments to be fed to the module. evaluator_

(  # pylint: disable=too-many-arguments,too-many-locals
    mod: "Module",
    device_type: str,
    args: list[Union["np.ndarray", "Tensor", int, float]],
    evaluator_config: Optional["EvaluatorConfig"] = None,
    rpc_config: Optional["RPCConfig"] = None,
    export_func: Callable[["Module", str], None] | Literal["tar", "ndk"] = "tar",
    output_format: str | None = None,
)

Source from the content-addressed store, hash-verified

150
151
152def rpc_run( # pylint: disable=too-many-arguments,too-many-locals
153 mod: "Module",
154 device_type: str,
155 args: list[Union["np.ndarray", "Tensor", int, float]],
156 evaluator_config: Optional["EvaluatorConfig"] = None,
157 rpc_config: Optional["RPCConfig"] = None,
158 export_func: Callable[["Module", str], None] | Literal["tar", "ndk"] = "tar",
159 output_format: str | None = None,
160):
161 """Run a TVM module on a remote device.
162
163 Parameters
164 ----------
165 mod : Module
166 The TVM module to run.
167 device_type : str
168 The device type to run the module on.
169 args : List[Union[np.ndarray, Tensor, int, float]]
170 The arguments to be fed to the module.
171 evaluator_config : Optional[EvaluatorConfig]
172 The evaluator configuration to use.
173 rpc_config : Optional[RPCConfig]
174 The RPC configuration to connect to the remote device.
175 If not specified, the default RPC configuration will be used, which reads the following
176 environment variables:
177 - TVM_TRACKER_HOST
178 - TVM_TRACKER_PORT
179 - TVM_TRACKER_KEY
180 export_func : Union[Callable[Module, str], Literal["tar", "ndk"]]
181 The function to export the module to a file.
182 If callable, it must be a function that takes two arguments: the module to export and the
183 path to export to.
184 If "tar", the module will be exported to a tar file.
185 If "ndk", the module will be exported to a shared library.
186 output_format : Optional[str]
187 The format of the exported module.
188 If not specified, it will be inferred from the `export_func` argument.
189
190 Returns
191 -------
192 args : List[Union[np.ndarray, Tensor, int, float]]
193 The results of running the module.
194 profile_result : tvm.runtime.BenchmarkResult
195 The profiling result of running the module.
196 """
197
198 import os.path as osp
199 import tempfile
200
201 from tvm.s_tir.meta_schedule.runner import EvaluatorConfig, RPCConfig
202
203 evaluator_config = EvaluatorConfig._normalized(evaluator_config)
204 rpc_config = RPCConfig._normalized(rpc_config)
205 export_func, output_format = _normalize_export_func(export_func, output_format)
206
207 with tempfile.TemporaryDirectory() as tmp_dir:
208 artifact_path = osp.join(tmp_dir, "tvm_tmp_mod." + output_format)
209 _, remote_path = osp.split(artifact_path)

Callers 2

mainFunction · 0.90
benchmarkFunction · 0.90

Calls 12

_normalize_export_funcFunction · 0.85
_args_to_deviceFunction · 0.85
_args_to_numpyFunction · 0.85
connect_serverMethod · 0.80
_normalizedMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
deviceMethod · 0.45
uploadMethod · 0.45
load_moduleMethod · 0.45
time_evaluatorMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…