MCPcopy Index your code
hub / github.com/apache/tvm / export_library

Method export_library

python/tvm/runtime/module.py:148–323  ·  view source on GitHub ↗

Export the module and all imported modules into a single device library. This function only works on host LLVM modules, other runtime::Module subclasses will work with this API but they must support implement the save and load mechanisms of modules completely includ

(
        self,
        file_name,
        *,
        fcompile=None,
        fpack_imports=None,
        addons=None,
        workspace_dir=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

146 return self._collect_from_import_tree(lambda m: m.is_compilation_exportable())
147
148 def export_library(
149 self,
150 file_name,
151 *,
152 fcompile=None,
153 fpack_imports=None,
154 addons=None,
155 workspace_dir=None,
156 **kwargs,
157 ):
158 """
159 Export the module and all imported modules into a single device library.
160
161 This function only works on host LLVM modules, other runtime::Module
162 subclasses will work with this API but they must support implement
163 the save and load mechanisms of modules completely including saving
164 from streams and files. This will pack your non-shared library module
165 into a single shared library which can later be loaded by TVM.
166
167 Parameters
168 ----------
169 file_name : str
170 The name of the shared library.
171
172 fcompile : function(target, file_list, kwargs), optional
173 The compilation function to use create the final library object during
174 export.
175
176 For example, when fcompile=_cc.create_shared, or when it is not supplied but
177 module is "llvm," this is used to link all produced artifacts
178 into a final dynamic library.
179
180 This behavior is controlled by the type of object exported.
181 If fcompile has attribute object_format, will compile host library
182 to that format. Otherwise, will use default format "o".
183
184 fpack_imports: function(mod: runtime.Module, is_system_lib: bool, symbol_prefix: str,
185 workspace_dir: str) -> str
186 Function used to pack imported modules from `mod` into a file suitable for passing
187 to fcompile as an input file. The result can be a C source, or an .o object file,
188 or any other file that the fcompile function can handle. The function returns the
189 name of the created file.
190
191 If not provided, the imported modules will be serialized either via packing to an
192 LLVM module, or to a C source file.
193
194 workspace_dir : str, optional
195 The path of the directory used to create the intermediate
196 artifacts when exporting the module.
197 If this is not provided a temporary dir will be created.
198
199 kwargs : dict, optional
200 Additional arguments passed to fcompile
201
202 Returns
203 -------
204 result of fcompile() : unknown, optional
205 If the compilation function returns an artifact it would be returned via

Callers 15

prepare_relax_libFunction · 0.45
prepare_cpu_libFunction · 0.45
prepare_gpu_libFunction · 0.45
compile_cutlass_moduleFunction · 0.45
finalize_modulesFunction · 0.45
default_exportFunction · 0.45
run_module_via_rpcFunction · 0.45
export_withFunction · 0.45
_ndk_exportFunction · 0.45
test_rpc_moduleFunction · 0.45
test_rpc_moduleFunction · 0.45
compilingFunction · 0.45

Calls 7

_collect_dso_modulesMethod · 0.95
strFunction · 0.85
writeMethod · 0.65
joinMethod · 0.45
appendMethod · 0.45
get_functionMethod · 0.45
updateMethod · 0.45

Tested by 15

prepare_relax_libFunction · 0.36
prepare_cpu_libFunction · 0.36
prepare_gpu_libFunction · 0.36
test_rpc_moduleFunction · 0.36
test_rpc_moduleFunction · 0.36
compilingFunction · 0.36
check_roundtripFunction · 0.36
test_multi_systemlibFunction · 0.36
make_vmFunction · 0.36
run_on_rpcFunction · 0.36
load_moduleFunction · 0.36