2424from typing import Union
2525
2626import tvm
27- from tvm import relax
27+ import tvm . contrib . hexagon as hexagon
2828from tvm import rpc as _rpc
29+ from tvm import runtime
2930from tvm .contrib import utils
30- import tvm . contrib . hexagon as hexagon
31- from .tools import export_module , HEXAGON_SIMULATOR_NAME
31+
32+ from .tools import HEXAGON_SIMULATOR_NAME , export_module
3233
3334
3435class Session :
@@ -202,26 +203,26 @@ def load_module(self, module: Union[str, pathlib.Path, tvm.runtime.Module]):
202203 return self ._rpc .get_function ("tvm.hexagon.load_module" )(str (remote_file_path ))
203204
204205 def get_executor_from_factory (
205- self , module : Union [ExecutorFactoryModule , relax . Executable , str ], hexagon_arch : str = "v68"
206+ self , module : Union [runtime . executable , str ], hexagon_arch : str = "v68"
206207 ):
207208 """Create a local GraphModule which consumes a remote libmod.
208209
209210 Parameters
210211 ----------
211212
212- module : Union[relax .Executable]
213+ module : Union[runtime .Executable, str ]
213214
214215 The module to upload to the remote
215216 session and load.
216217 hexagon_arch : str
217218 The hexagon arch to be used
218219 """
219- if isinstance (module , (relax .Executable , str )):
220+ if isinstance (module , (runtime .Executable , str )):
220221 return self ._relax_vm_executable_executor (module , hexagon_arch = hexagon_arch )
221222
222223 raise TypeError (f"Unsupported executor type: { type (module )} " )
223224
224- def _set_device_type (self , module : Union [str , pathlib .Path , GraphExecutorFactoryModule ]):
225+ def _set_device_type (self , module : Union [str , pathlib .Path ]):
225226 """Set session device type(hexagon, cpu) based on target in module.
226227
227228 Parameters
@@ -244,40 +245,41 @@ def _set_device_type(self, module: Union[str, pathlib.Path, GraphExecutorFactory
244245 self ._requires_cpu_device = False
245246
246247 def _relax_vm_executable_executor (
247- self , vm_exec : Union [relax .Executable , str ], hexagon_arch : str
248+ self , executable : Union [runtime .Executable , str ], hexagon_arch : str
248249 ):
249250 """Create a local TVM module which consumes a remote vm executable.
250251
251- Paramters
252- ---------
252+ Parameters
253+ ----------
253254
254- vm_exec : relax .Executable
255- The Relax VM Executable to upload to the remote and load. This will typically be the
256- output of `relax.build ` or the path to an already built and exported shared library
255+ executable : runtime .Executable
256+ The Executable to upload to the remote and load. This will typically be the
257+ output of `tvm.compile ` or the path to an already built and exported shared library
257258 hexagon_arch : str
258259 The hexagon arch to be used
260+
259261 Returns
260262 -------
261263 TVMModule :
262264 TVM module object
263265 """
264266 assert self ._rpc is not None , "Hexagon session must be started using __enter__ prior to use"
265267
266- if isinstance (vm_exec , relax .Executable ):
268+ if isinstance (executable , runtime .Executable ):
267269 temp_dir = utils .tempdir ()
268270 path_exec = temp_dir .relpath ("exec.so" )
269271
270- vm_exec . mod .export_library (
272+ executable .export_library (
271273 path_exec ,
272274 fcompile = hexagon .create_aot_shared ,
273275 hexagon_arch = hexagon_arch ,
274276 )
275277
276278 path = self .upload (path_exec , "exec.so" )
277- elif isinstance (vm_exec , str ):
278- path_exec = vm_exec
279+ elif isinstance (executable , str ):
280+ path_exec = executable
279281 else :
280- raise TypeError (f"Unsupported executor type: { type (vm_exec )} " )
282+ raise TypeError (f"Unsupported executor type: { type (executable )} " )
281283
282284 path = self .upload (path_exec , "exec.so" )
283285 return self ._rpc .get_function ("tvm.hexagon.load_module" )(str (path ))
0 commit comments