Skip to content

Commit 33b7948

Browse files
committed
[REFACTOR][FFI] Phase out legacy C API (apache#18010)
This PR phases out the legacy c api in favor of the new FFI C API. Also removes the redirection sccafolding for registry.h - include <tvm/runtime/registry.h> => include <tvm/ffi/function.h> - include <tvm/runtime/c_runtime_api.h> => include <tvm/runtime/base.h> - TVM_REGISTER_GLOBAL => TVM_FFI_REGISTER_GLOBAL The cleanup will greatly simplify the overall FFI surface of the project and allows us to move towards an unified clean API based on tvm ffi.
1 parent 8e803e1 commit 33b7948

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/tvm/ffi/c_api.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
#include <dlpack/dlpack.h>
2828
#include <stdint.h>
2929

30+
// Macros to do weak linking
31+
#ifdef _MSC_VER
32+
#define TVM_FFI_WEAK __declspec(selectany)
33+
#else
34+
#define TVM_FFI_WEAK __attribute__((weak))
35+
#endif
36+
3037
#if !defined(TVM_FFI_DLL) && defined(__EMSCRIPTEN__)
3138
#include <emscripten/emscripten.h>
3239
#define TVM_FFI_DLL EMSCRIPTEN_KEEPALIVE

include/tvm/ffi/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class Function::Registry {
787787
* .set_body_typed(multiply); // will have type int(int, int)
788788
*
789789
* // will have type int(int, int)
790-
* TVM_REGISTER_GLOBAL("sub")
790+
* TVM_FFI_REGISTER_GLOBAL("sub")
791791
* .set_body_typed([](int a, int b) -> int { return a - b; });
792792
*
793793
* \endcode

0 commit comments

Comments
 (0)