We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
init()
1 parent d66a37c commit a4bd823Copy full SHA for a4bd823
1 file changed
backends/xnnpack/runtime/XNNPACKBackend.cpp
@@ -91,8 +91,13 @@ class XnnpackBackend final
91
auto workspace = workspace_result.get();
92
93
bool use_weight_cache = options_.resolve_weight_cache(context);
94
+ // Hold the lock for the entire init-compile-finalize sequence to prevent
95
+ // concurrent inits from resetting is_finalized_ or overwriting
96
+ // named_data_map_ while compileModel is using the shared weights cache.
97
+ std::unique_lock<std::mutex> lock_weights_cache(
98
+ weights_cache_mutex_, std::defer_lock);
99
if (use_weight_cache) {
- const std::lock_guard<std::mutex> lock_weight_cache(weights_cache_mutex_);
100
+ lock_weights_cache.lock();
101
weights_cache_->initialize_for_runtime(
102
context.get_runtime_allocator(), named_data_map);
103
}
0 commit comments