Get metadata for a function exported from the module. This retrieves metadata for functions exported via c:macro:`TVM_FFI_DLL_EXPORT_TYPED_FUNC` and when c:macro:`TVM_FFI_DLL_EXPORT_INCLUDE_METADATA` is on, which includes type schema information. Parameters
(
self, name: str, query_imports: bool = False
)
| 192 | return func |
| 193 | |
| 194 | def get_function_metadata( |
| 195 | self, name: str, query_imports: bool = False |
| 196 | ) -> dict[str, Any] | None: |
| 197 | """Get metadata for a function exported from the module. |
| 198 | |
| 199 | This retrieves metadata for functions exported via c:macro:`TVM_FFI_DLL_EXPORT_TYPED_FUNC` |
| 200 | and when c:macro:`TVM_FFI_DLL_EXPORT_INCLUDE_METADATA` is on, which includes type schema |
| 201 | information. |
| 202 | |
| 203 | Parameters |
| 204 | ---------- |
| 205 | name |
| 206 | The name of the function |
| 207 | |
| 208 | query_imports |
| 209 | Whether to also query modules imported by this module. |
| 210 | |
| 211 | Returns |
| 212 | ------- |
| 213 | metadata |
| 214 | A dictionary containing function metadata. The ``type_schema`` field |
| 215 | encodes the callable signature. |
| 216 | |
| 217 | Examples |
| 218 | -------- |
| 219 | .. code-block:: python |
| 220 | |
| 221 | import tvm_ffi |
| 222 | from tvm_ffi.core import TypeSchema |
| 223 | import json |
| 224 | |
| 225 | mod = tvm_ffi.load_module("add_one_cpu.so") |
| 226 | metadata = mod.get_function_metadata("add_one_cpu") |
| 227 | schema = TypeSchema.from_json_str(metadata["type_schema"]) |
| 228 | print(schema) # Shows function signature |
| 229 | |
| 230 | See Also |
| 231 | -------- |
| 232 | :py:func:`tvm_ffi.get_global_func_metadata` |
| 233 | Get metadata for global registry functions. |
| 234 | |
| 235 | """ |
| 236 | metadata_str = _ffi_api.ModuleGetFunctionMetadata(self, name, query_imports) |
| 237 | if metadata_str is None: |
| 238 | return None |
| 239 | return json.loads(metadata_str) |
| 240 | |
| 241 | def get_function_doc(self, name: str, query_imports: bool = False) -> str | None: |
| 242 | """Get documentation string for a function exported from the module. |
no outgoing calls