The GitHub Actions job "mainline-only" on tvm-ffi.git/main has failed.
Run started by GitHub user junrushao (triggered by junrushao).

Head commit for run:
ac7bf68058b392c3a8475619016fde48bd08334b / Kathryn (Jinqi) Chen 
<[email protected]>
feat: Embed metadata for FFI exported functions (#230)

## Summary

This PR adds reflection metadata support for functions exported via
`TVM_FFI_DLL_EXPORT_TYPED_FUNC`, enabling signature validation and
memory effect analysis without invoking the function. This addresses the
need for compiler frameworks (e.g., JAX/XLA, MLIR-based compilers) to
validate third-party FFI modules at compile time.

## Core Changes

**1. `TVM_FFI_DLL_EXPORT_TYPED_FUNC` macro**
- Exports two symbols per function:
  - `__tvm_ffi_<name>`
  - `__tvm_ffi__metadata_<name>`

**Metadata format:**
```
{
  "type_schema": "{\"type\":\"ffi.Function\",\"args\":[...]}",
}
```
Based on discussion, we choose to not include C++ const information in
metadata in this PR, and think about it as a followup.

**2. `TVM_FFI_DLL_EXPORT_TYPED_FUNC_DOC` macro**
- Exports three symbols per function:
  - `__tvm_ffi_<name>`
  - `__tvm_ffi__metadata_<name>`
  - `__tvm_ffi__doc_<name>`

**3. Module API** (C++)
- `Module::GetFunctionMetadata(name)` - Query metadata from loaded
modules
- `Module::GetFunctionDoc(name)` - Query documentation
- Works with both static and dynamic linking

**4. Module API** (Python)
- `mod.get_function_metadata("func_name")` - Query metadata from loaded
modules
- `mod.get_function_doc("func_name")` - Query documentation
- Might be good to keep methods private

## Tests

The tests include both unit tests and integration tests.

**C++ Tests:**
- `tests/cpp/test_metadata.cc` - Direct symbol tests
- `tests/cpp/test_function.cc` - Static linking scenario
- `tests/cpp/extra/test_module.cc` - Module API

**Python Tests:**
- `tests/python/test_metadata.py` - Unit test
- `tests/python/test_build.py` - Integration test

Report URL: https://github.com/apache/tvm-ffi/actions/runs/19557105816

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to