From cd884fb9b6d89abe3f514a57d32bfd6dd05e28b3 Mon Sep 17 00:00:00 2001 From: MirceaDan99 Date: Tue, 17 Dec 2024 12:13:35 +0200 Subject: [PATCH] Move redundant `modelBuffer` check to `metadata.cpp` --- src/plugins/intel_npu/src/plugin/src/metadata.cpp | 7 +++++-- src/plugins/intel_npu/src/plugin/src/plugin.cpp | 8 +------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/plugins/intel_npu/src/plugin/src/metadata.cpp b/src/plugins/intel_npu/src/plugin/src/metadata.cpp index 72322b912f95d7..7a0ea5d80220a1 100644 --- a/src/plugins/intel_npu/src/plugin/src/metadata.cpp +++ b/src/plugins/intel_npu/src/plugin/src/metadata.cpp @@ -113,7 +113,6 @@ bool Metadata::is_compatible() { } std::unique_ptr read_metadata_from(std::istream& stream) { - Logger logger("NPUPlugin", Logger::global().level()); size_t magicBytesSize = MAGIC_BYTES.size(); std::string blobMagicBytes; blobMagicBytes.resize(magicBytesSize); @@ -151,6 +150,11 @@ std::unique_ptr read_metadata_from(std::istream& stream) { std::unique_ptr read_metadata_from(std::istream& stream, const std::shared_ptr& modelBuffer) { Logger logger("NPUPlugin", Logger::global().level()); + + if (modelBuffer == nullptr) { + return read_metadata_from(stream); + } + size_t magicBytesSize = MAGIC_BYTES.size(); std::string blobMagicBytes; blobMagicBytes.resize(magicBytesSize); @@ -175,7 +179,6 @@ std::unique_ptr read_metadata_from(std::istream& stream, const std if (storedMeta != nullptr) { storedMeta->read(stream); } else { ->>>>>>> a76d0bdf91 (POC for supporting blob metadata) logger.warning("Imported blob metadata version: %d.%d, but the current version is: %d.%d", get_major(metaVersion), get_minor(metaVersion), diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp index 248a174ad9c509..7bc7ce201843ed 100644 --- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp +++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp @@ -760,13 +760,7 @@ std::shared_ptr Plugin::import_model(std::istream& stream, c auto compiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), localConfig); std::unique_ptr blobPtr; - std::unique_ptr storedMeta; - - if (dynamic_cast(stream.rdbuf())) { - storedMeta = read_metadata_from(stream, dynamic_cast(stream.rdbuf())->get_buffer()); - } else { - storedMeta = read_metadata_from(stream); - } + auto storedMeta = read_model_from(stream, modelBuffer); if (storedMeta == nullptr) { OPENVINO_THROW("Could not read metadata!");