Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Added remove_global_func to the Python API #6787

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/tvm/runtime/c_runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions python/tvm/_ffi/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,9 @@ int TVMFuncListGlobalNames(int* out_size, const char*** out_array) {
*out_size = static_cast<int>(ret->ret_vec_str.size());
API_END();
}

int TVMFuncRemoveGlobal(const char* name) {
API_BEGIN();
tvm::runtime::Registry::Remove(name);
API_END();
}