Skip to content

Commit

Permalink
fix doubloe locking
Browse files Browse the repository at this point in the history
  • Loading branch information
caillonantoine committed Jun 6, 2023
1 parent bab917b commit a26d146
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/backend/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ int Backend::load(std::string path) {
auto model = torch::jit::load(path);
model.eval();
model.to(m_device);

std::unique_lock<std::mutex> model_lock(m_model_mutex);
m_model = model;
m_loaded = 1;
model_lock.unlock();

m_available_methods = get_available_methods();
m_path = path;
return 0;
Expand All @@ -98,9 +102,7 @@ int Backend::load(std::string path) {
}

int Backend::reload() {
std::unique_lock<std::mutex> model_lock(m_model_mutex);
auto return_code = load(m_path);
model_lock.unlock();
return return_code;
}

Expand Down

0 comments on commit a26d146

Please sign in to comment.