Skip to content

Commit

Permalink
Free memory on reload using memory allocator clear func (octoml#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJH5574 authored May 19, 2023
1 parent 944fc69 commit 058cbbf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/llm_chat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ class LLMChat {
}

void Reload(tvm::runtime::Module executable, String model_path) {
// Step 0. Clear the previously allocated memory.
const PackedFunc* fclear_memory_manager =
tvm::runtime::Registry::Get("vm.builtin.memory_manager.clear");
ICHECK(fclear_memory_manager) << "Cannot find env function vm.builtin.memory_manager.clear";
(*fclear_memory_manager)();

// Step 1. Set tokenizer.
this->tokenizer_ = TokenizerFromPath(model_path);

Expand Down

0 comments on commit 058cbbf

Please sign in to comment.