From 216a980fc956ce0938a0f03056a4ae52335ab806 Mon Sep 17 00:00:00 2001 From: Oleg Pipikin Date: Fri, 20 Sep 2024 15:54:45 +0000 Subject: [PATCH] Fix clang-format --- .../openvino/runtime/shared_buffer.hpp | 17 ++--- src/inference/src/cache_manager.hpp | 2 +- src/inference/src/dev/core_impl.cpp | 68 ++++++++++--------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/core/dev_api/openvino/runtime/shared_buffer.hpp b/src/core/dev_api/openvino/runtime/shared_buffer.hpp index 14a0aa87879937..dfb2935b8fc312 100644 --- a/src/core/dev_api/openvino/runtime/shared_buffer.hpp +++ b/src/core/dev_api/openvino/runtime/shared_buffer.hpp @@ -28,19 +28,14 @@ class SharedBuffer : public ov::AlignedBuffer { T _shared_object; }; - /// \brief SharedStreamBuffer class to store pointer to pre-acclocated buffer and provide streambuf interface. class SharedStreamBuffer : public std::streambuf { public: - SharedStreamBuffer(char* data, size_t size) : - m_data(data), - m_size(size), - m_offset(0) { - } + SharedStreamBuffer(char* data, size_t size) : m_data(data), m_size(size), m_offset(0) {} protected: - std::streamsize xsgetn(char* s, std::streamsize count) override{ - auto real_count = std::min(m_size - m_offset, + count); + std::streamsize xsgetn(char* s, std::streamsize count) override { + auto real_count = std::min(m_size - m_offset, count); std::memcpy(s, m_data + m_offset, real_count); m_offset += real_count; return real_count; @@ -63,10 +58,11 @@ class SharedStreamBuffer : public std::streambuf { size_t m_offset; }; -/// \brief OwningSharedStreamBuffer is a SharedStreamBuffer which owns its shared object. Can return AlignedBuffer to shared memory +/// \brief OwningSharedStreamBuffer is a SharedStreamBuffer which owns its shared object. Can return AlignedBuffer to +/// shared memory class OwningSharedStreamBuffer : public SharedStreamBuffer { public: - template + template OwningSharedStreamBuffer(char* data, size_t size, const T& shared_object) : SharedStreamBuffer(data, size), m_alligned_buffer(std::make_shared>(data, size, shared_object)) {} @@ -79,5 +75,4 @@ class OwningSharedStreamBuffer : public SharedStreamBuffer { std::shared_ptr m_alligned_buffer; }; - } // namespace ov diff --git a/src/inference/src/cache_manager.hpp b/src/inference/src/cache_manager.hpp index 81a9f07592a95a..9f898e9a9e1510 100644 --- a/src/inference/src/cache_manager.hpp +++ b/src/inference/src/cache_manager.hpp @@ -14,9 +14,9 @@ #include #include +#include "openvino/runtime/shared_buffer.hpp" #include "openvino/util/file_util.hpp" #include "openvino/util/mmap_object.hpp" -#include "openvino/runtime/shared_buffer.hpp" namespace ov { diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index 8c538615d181bd..2c756cd584dd83 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -1407,42 +1407,46 @@ ov::SoPtr ov::CoreImpl::load_model_from_cache( OPENVINO_ASSERT(cacheContent.cacheManager != nullptr); try { - cacheContent.cacheManager->read_cache_entry(cacheContent.blobId, coreConfig.get_enable_mmap(), [&](std::istream& networkStream) { - OV_ITT_SCOPE(FIRST_INFERENCE, - ov::itt::domains::LoadTime, - "Core::load_model_from_cache::ReadStreamAndImport"); - try { - ov::CompiledBlobHeader header; - networkStream >> header; - if (header.get_file_info() != ov::ModelCache::calculate_file_info(cacheContent.modelPath)) { - // Original file is changed, don't use cache - OPENVINO_THROW("Original model file is changed"); - } - if (util::contains(plugin.get_property(ov::internal::supported_properties), - ov::internal::compiled_model_runtime_properties_supported.name())) { - ov::AnyMap compiled_model_runtime_properties = { - {ov::internal::compiled_model_runtime_properties.name(), - std::string(header.get_runtime_info())}}; - auto res = plugin.get_property(ov::internal::compiled_model_runtime_properties_supported.name(), - compiled_model_runtime_properties); - if (!res.as()) { - OPENVINO_THROW("Original model runtime properties have been changed, not supported anymore!"); + cacheContent.cacheManager->read_cache_entry( + cacheContent.blobId, + coreConfig.get_enable_mmap(), + [&](std::istream& networkStream) { + OV_ITT_SCOPE(FIRST_INFERENCE, + ov::itt::domains::LoadTime, + "Core::load_model_from_cache::ReadStreamAndImport"); + try { + ov::CompiledBlobHeader header; + networkStream >> header; + if (header.get_file_info() != ov::ModelCache::calculate_file_info(cacheContent.modelPath)) { + // Original file is changed, don't use cache + OPENVINO_THROW("Original model file is changed"); } - } else { - if (header.get_openvino_version() != ov::get_openvino_version().buildNumber) { - // Build number mismatch, don't use this cache - OPENVINO_THROW("Version does not match"); + if (util::contains(plugin.get_property(ov::internal::supported_properties), + ov::internal::compiled_model_runtime_properties_supported.name())) { + ov::AnyMap compiled_model_runtime_properties = { + {ov::internal::compiled_model_runtime_properties.name(), + std::string(header.get_runtime_info())}}; + auto res = plugin.get_property(ov::internal::compiled_model_runtime_properties_supported.name(), + compiled_model_runtime_properties); + if (!res.as()) { + OPENVINO_THROW( + "Original model runtime properties have been changed, not supported anymore!"); + } + } else { + if (header.get_openvino_version() != ov::get_openvino_version().buildNumber) { + // Build number mismatch, don't use this cache + OPENVINO_THROW("Version does not match"); + } } + } catch (...) { + throw HeaderException(); } - } catch (...) { - throw HeaderException(); - } - ov::AnyMap update_config = config; - update_config[ov::loaded_from_cache.name()] = true; - compiled_model = context ? plugin.import_model(networkStream, context, update_config) - : plugin.import_model(networkStream, update_config); - }); + ov::AnyMap update_config = config; + update_config[ov::loaded_from_cache.name()] = true; + compiled_model = context ? plugin.import_model(networkStream, context, update_config) + : plugin.import_model(networkStream, update_config); + }); } catch (const HeaderException&) { // For these exceptions just remove old cache and set that import didn't work cacheContent.cacheManager->remove_cache_entry(cacheContent.blobId);