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,
)
| 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 |