Skip to content

Commit

Permalink
areusch review: New workaround for multiple runs on micro targets
Browse files Browse the repository at this point in the history
Instead of not calling FreeHandle() when a session terminates on the
host side, avoid calling TVMFreeMod() for system_lib_handle on the
target side.
  • Loading branch information
gromero committed Oct 28, 2021
1 parent 5d0fea1 commit e76156d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/runtime/crt/common/crt_runtime_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,17 @@ int TVMModCreateFromCModule(const TVMModule* mod, TVMModuleHandle* out_handle) {
return -1;
}

static const TVMModuleHandle kTVMModuleHandleUninitialized = (TVMModuleHandle)(~0UL);

static TVMModuleHandle system_lib_handle;

int TVMModFree(TVMModuleHandle mod) {
/* Never free system_lib_handler */
if (mod == system_lib_handle &&
system_lib_handle != kTVMModuleHandleUninitialized) {
return 0;
}

tvm_module_index_t module_index;
if (DecodeModuleHandle(mod, &module_index) != 0) {
return -1;
Expand All @@ -193,10 +203,6 @@ int TVMModFree(TVMModuleHandle mod) {
return 0;
}

static const TVMModuleHandle kTVMModuleHandleUninitialized = (TVMModuleHandle)(~0UL);

static TVMModuleHandle system_lib_handle;

int SystemLibraryCreate(TVMValue* args, int* type_codes, int num_args, TVMValue* ret_val,
int* ret_type_codes) {
const TVMModule* system_lib;
Expand Down

0 comments on commit e76156d

Please sign in to comment.