diff --git a/src/core/dev_api/openvino/runtime/shared_buffer.hpp b/src/core/dev_api/openvino/runtime/shared_buffer.hpp index 2c784ef6081c35..503b6fc42475b3 100644 --- a/src/core/dev_api/openvino/runtime/shared_buffer.hpp +++ b/src/core/dev_api/openvino/runtime/shared_buffer.hpp @@ -12,6 +12,12 @@ namespace ov { template class SharedBuffer : public ov::AlignedBuffer { public: + + SharedBuffer(const SharedBuffer&) = delete; + SharedBuffer(SharedBuffer&&) = default; + SharedBuffer& operator=(const SharedBuffer&) = delete; + SharedBuffer& operator=(SharedBuffer&&) = default; + SharedBuffer(char* data, size_t size, const T& shared_object) : _shared_object(shared_object) { m_allocated_buffer = data; m_aligned_buffer = data; diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/runtime.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/runtime.hpp index 4c8044d4de26c5..332790c30f8396 100644 --- a/src/plugins/intel_npu/src/al/include/intel_npu/config/runtime.hpp +++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/runtime.hpp @@ -9,7 +9,6 @@ #include "openvino/runtime/intel_npu/properties.hpp" #include "openvino/runtime/internal_properties.hpp" #include "openvino/runtime/properties.hpp" - namespace ov { namespace intel_npu { diff --git a/src/plugins/intel_npu/src/al/src/config/runtime.cpp b/src/plugins/intel_npu/src/al/src/config/runtime.cpp index 6555f0e7ae2f49..dba16fa7a4929b 100644 --- a/src/plugins/intel_npu/src/al/src/config/runtime.cpp +++ b/src/plugins/intel_npu/src/al/src/config/runtime.cpp @@ -7,7 +7,9 @@ #include #include "intel_npu/config/common.hpp" +#include "openvino/util/mmap_object.hpp" #include "openvino/runtime/properties.hpp" +#include "openvino/runtime/shared_buffer.hpp" using namespace intel_npu; using namespace ov::intel_npu; @@ -158,7 +160,7 @@ std::string intel_npu::WORKLOAD_TYPE::toString(const ov::WorkloadType& val) { } // -// WORKLOAD_TYPE +// CACHED_MODEL_BUFFER // std::shared_ptr intel_npu::CACHED_MODEL_BUFFER::parse(std::string_view val) { @@ -166,8 +168,14 @@ std::shared_ptr intel_npu::CACHED_MODEL_BUFFER::parse(std::st void* modelBufferPtr; ss >> modelBufferPtr; - - return std::shared_ptr(static_cast(modelBufferPtr)); + // If we don't "steal" below resources from the casted ov::AlignedBuffer, parsed blob will be freed + // after core.import_model causing problems at inference.get_profiling_info() + auto* modelBufferSO = dynamic_cast>*>(static_cast(modelBufferPtr)); + std::shared_ptr mappedMemorySOPtr; + auto modelBufferSOPtr = std::make_shared>>(nullptr, 0, mappedMemorySOPtr); + *modelBufferSOPtr = std::move(*modelBufferSO); + + return modelBufferSOPtr; } std::string intel_npu::CACHED_MODEL_BUFFER::toString(const std::shared_ptr& val) {