File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/plugins/intel_npu/src/compiler_adapter/include Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 55#pragma once
66
77#include < memory>
8+ #include < mutex>
89
910#include " compiler.h"
1011#include " intel_npu/common/filtered_config.hpp"
@@ -23,7 +24,15 @@ class VCLCompilerImpl final : public intel_npu::ICompiler {
2324 ~VCLCompilerImpl () override ;
2425
2526 static std::shared_ptr<VCLCompilerImpl> getInstance () {
26- static std::weak_ptr<VCLCompilerImpl> compiler = std::make_shared<VCLCompilerImpl>();
27+ static std::mutex mutex;
28+ static std::weak_ptr<VCLCompilerImpl> weak_compiler;
29+
30+ std::lock_guard<std::mutex> lock (mutex);
31+ auto compiler = weak_compiler.lock ();
32+ if (!compiler) {
33+ compiler = std::make_shared<VCLCompilerImpl>();
34+ weak_compiler = compiler;
35+ }
2736 return compiler;
2837 }
2938
You can’t perform that action at this time.
0 commit comments