Define TVM_FFI_DLL_EXPORT_TYPED_FUNC

Define TVM_FFI_DLL_EXPORT_TYPED_FUNC#

Define Documentation#

TVM_FFI_DLL_EXPORT_TYPED_FUNC(ExportName, Function)#

Export typed function as a SafeCallType symbol that follows the FFI ABI.

This macro exports the function and automatically exports metadata when TVM_FFI_DLL_EXPORT_INCLUDE_METADATA is defined.

int AddOne_(int x) {
  return x + 1;
}

// Expose the function as "AddOne"
TVM_FFI_DLL_EXPORT_TYPED_FUNC(AddOne, AddOne_);

// Expose the function as "SubOne"
TVM_FFI_DLL_EXPORT_TYPED_FUNC(SubOne, [](int x) {
  return x - 1;
});

See also

ffi::TypedFunction, TVM_FFI_DLL_EXPORT_TYPED_FUNC_DOC

Note

The final symbol names are:

  • __tvm_ffi_<ExportName> (function)

  • __tvm_ffi__metadata_<ExportName> (metadata - only when TVM_FFI_DLL_EXPORT_INCLUDE_METADATA is defined)

Parameters:
  • ExportName – The symbol name to be exported.

  • Function – The typed function.