diff --git a/include/tvm/runtime/c_runtime_api.h b/include/tvm/runtime/c_runtime_api.h index e25394a88b5a6..aac49c198c72c 100644 --- a/include/tvm/runtime/c_runtime_api.h +++ b/include/tvm/runtime/c_runtime_api.h @@ -366,6 +366,12 @@ TVM_DLL int TVMFuncGetGlobal(const char* name, TVMFunctionHandle* out); */ TVM_DLL int TVMFuncListGlobalNames(int* out_size, const char*** out_array); +/*! + * \brief Remove a global function. + * \param name The name of the function. + */ +TVM_DLL int TVMFuncRemoveGlobal(const char* name); + // Array related apis for quick proptyping /*! * \brief Allocate a nd-array's memory, diff --git a/python/tvm/_ffi/registry.py b/python/tvm/_ffi/registry.py index 6637cd1743916..677ca5d8de8dc 100644 --- a/python/tvm/_ffi/registry.py +++ b/python/tvm/_ffi/registry.py @@ -262,6 +262,17 @@ def _list(name, func): return fdict +def remove_global_func(name): + """Remove a global function by name + + Parameters + ---------- + name : str + The name of the global function + """ + check_call(_LIB.TVMFuncRemoveGlobal(c_str(name))) + + def _get_api(f): flocal = f flocal.is_global = True diff --git a/src/runtime/registry.cc b/src/runtime/registry.cc index 6e74dc354259c..a65235090bfdc 100644 --- a/src/runtime/registry.cc +++ b/src/runtime/registry.cc @@ -146,3 +146,9 @@ int TVMFuncListGlobalNames(int* out_size, const char*** out_array) { *out_size = static_cast(ret->ret_vec_str.size()); API_END(); } + +int TVMFuncRemoveGlobal(const char* name) { + API_BEGIN(); + tvm::runtime::Registry::Remove(name); + API_END(); +}