File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
src/plugins/intel_npu/src/compiler_adapter Expand file tree Collapse file tree 2 files changed +14
-3
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
Original file line number Diff line number Diff line change @@ -615,10 +615,12 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model
615615
616616 if (useBaseModelSerializer) {
617617 _logger.debug (" serialize IR is base method, useBaseModelSerializer is %d" , useBaseModelSerializer);
618- std::cout << " 1) serialize IR is base method (copy weights), useBaseModelSerializer is " << useBaseModelSerializer << std::endl;
618+ std::cout << " 1) serialize IR is base method (copy weights), useBaseModelSerializer is "
619+ << useBaseModelSerializer << std::endl;
619620 } else {
620621 _logger.debug (" serialize IR is vcl method, useBaseModelSerializer is %d" , useBaseModelSerializer);
621- std::cout << " 2) serialize IR is vcl method(No copy weights), useBaseModelSerializer is " << useBaseModelSerializer << std::endl;
622+ std::cout << " 2) serialize IR is vcl method(No copy weights), useBaseModelSerializer is "
623+ << useBaseModelSerializer << std::endl;
622624
623625 // To resolve the issue with the default configuration where no user passes the serializer config, the VCL
624626 // serializer will be used as the default in the plugin adapter. You need to pass the serializer config;
You can’t perform that action at this time.
0 commit comments