File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ class XnnpackBackend final : public ::executorch::runtime::BackendInterface {
7676 auto executor = ET_ALLOCATE_INSTANCE_OR_RETURN_ERROR (
7777 context.get_runtime_allocator (), xnnpack::delegate::XNNExecutor);
7878
79+ #ifdef ENABLE_XNNPACK_SHARED_WORKSPACE
80+ // This is needed to serialize access to xnn_create_runtime which is not
81+ // thread safe. This can heppen when multiple threads call init() on
82+ // the same backend instance.
83+ const std::lock_guard<std::mutex> lock (workspace_mutex_);
84+ #endif
85+
7986 // Executor has been allocated but not constructed, ensure that runtime_ is
8087 // nullptr by constructing it in place here. NOTE: Since we use placement
8188 // new and since this type is not trivially destructible, we must call the
You can’t perform that action at this time.
0 commit comments