@@ -79,7 +79,7 @@ def jit(self, fcompile=None, addons=None, **kwargs) -> tvm.runtime.Module:
7979 vm = tvm.relax.VirtualMachine(rt_mod, tvm.cuda())
8080 """
8181
82- # TODO(tvm-team): Update runtime.Module interfac
82+ # TODO(tvm-team): Update runtime.Module interface
8383 # to query these properties as bitmask.
8484 def _not_runnable (x ):
8585 return x .type_key in ("c" , "static_library" )
@@ -179,13 +179,17 @@ def _vmcodegen(
179179 raise ValueError (f"Unknown exec_mode { exec_mode } " )
180180
181181
182- def _autodetect_system_lib_req (target : tvm .target .Target , system_lib ):
182+ def _autodetect_system_lib_req (
183+ target : Optional [tvm .target .Target ] = None , system_lib : Optional [bool ] = None
184+ ):
183185 """Automatically detect system lib requirement"""
184- host = target if target .host is None else target .host
185- if system_lib is None :
186- system_lib = False
187- if "wasm" in host .attrs .get ("mtriple" , "" ):
188- system_lib = True
186+ if target is not None :
187+ host = target if target .host is None else target .host
188+ if system_lib is None :
189+ system_lib = False
190+ if "wasm" in host .attrs .get ("mtriple" , "" ):
191+ system_lib = True
192+
189193 if system_lib :
190194 # use packed-func to avoid relay dep.
191195 return tvm .get_global_func ("relay.backend.CreateRuntime" )("cpp" , {"system-lib" : system_lib })
@@ -194,7 +198,7 @@ def _autodetect_system_lib_req(target: tvm.target.Target, system_lib):
194198
195199def _vmlink (
196200 builder : "relax.ExecBuilder" ,
197- target : Union [str , tvm .target .Target ],
201+ target : Optional [ Union [str , tvm .target .Target ] ],
198202 tir_mod : Optional [tvm .IRModule ] = None ,
199203 ext_libs : List [tvm .runtime .Module ] = None ,
200204 params : Optional [Dict [str , list ]] = None ,
@@ -213,8 +217,10 @@ def _vmlink(
213217 builder: relax.ExecBuilder
214218 Builder used to collect executables.
215219
216- target : Union[str, tvm.target.Target]
220+ target : Optional[ Union[str, tvm.target.Target] ]
217221 A build target which can have optional host side compilation target.
222+ If the target is not specified, the target in the vdevice list will be used.
223+ For multi-target compilation, the vdevice should be annotated.
218224
219225 tir_mod: IRModule
220226 The input TIR IRModule to be linked together.
@@ -239,14 +245,16 @@ def _vmlink(
239245 lib = None
240246 if tir_mod is not None :
241247 lib = tvm .build (
242- tir_mod , target = target , runtime = _autodetect_system_lib_req (target , system_lib )
248+ tir_mod ,
249+ target = target ,
250+ runtime = _autodetect_system_lib_req (target , system_lib ),
243251 )
244252 return Executable (_ffi_api .VMLink (builder , target , lib , ext_libs , params )) # type: ignore
245253
246254
247255def build (
248256 mod : tvm .IRModule ,
249- target : Union [str , tvm .target .Target ],
257+ target : Optional [ Union [str , tvm .target .Target ]] = None ,
250258 params : Optional [Dict [str , list ]] = None ,
251259 pipeline : Union [None , str , tvm .transform .Pass ] = "default_build" ,
252260 exec_mode : str = "bytecode" ,
@@ -261,7 +269,7 @@ def build(
261269 mod: IRModule
262270 The input IRModule to be built.
263271
264- target : Union[str, tvm.target.Target]
272+ target : Optional[ Union[str, tvm.target.Target] ]
265273 A build target which can have optional host side compilation target.
266274
267275 When TVM compiles device specific program such as CUDA,
0 commit comments