Skip to content

Commit ebc5b90

Browse files
committed
Move redundant modelBuffer check to metadata.cpp
1 parent 83e9b5e commit ebc5b90

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/plugins/intel_npu/src/plugin/src/metadata.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ std::unique_ptr<MetadataBase> read_metadata_from(std::istream& stream) {
147147

148148
std::unique_ptr<MetadataBase> read_metadata_from(std::istream& stream, const std::shared_ptr<ov::AlignedBuffer>& modelBuffer) {
149149
Logger logger("NPUPlugin", Logger::global().level());
150+
if (modelBuffer == nullptr) {
151+
return read_metadata_from(stream);
152+
}
150153
size_t magicBytesSize = MAGIC_BYTES.size();
151154
std::string blobMagicBytes;
152155
blobMagicBytes.resize(magicBytesSize);

src/plugins/intel_npu/src/plugin/src/plugin.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c
760760
auto compiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), localConfig);
761761

762762
std::unique_ptr<BlobContainer> blobPtr;
763-
std::unique_ptr<MetadataBase> storedMeta;
764-
765-
if (dynamic_cast<ov::OwningSharedStreamBuffer*>(stream.rdbuf())) {
766-
storedMeta = read_metadata_from(stream, dynamic_cast<ov::OwningSharedStreamBuffer*>(stream.rdbuf())->get_buffer());
767-
} else {
768-
storedMeta = read_metadata_from(stream);
769-
}
763+
auto storedMeta = read_metadata_from(stream, modelBuffer);
770764

771765
if (storedMeta == nullptr) {
772766
OPENVINO_THROW("Could not read metadata!");
@@ -788,11 +782,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c
788782
blobPtr = std::make_unique<BlobContainerAlignedBuffer>(modelBuffer, storedMeta->get_ov_header_offset(), graphSize);
789783
}
790784

791-
auto storedMeta = read_metadata_from(blob);
792-
if (!storedMeta->is_compatible()) {
793-
OPENVINO_THROW("Incompatible blob version!");
794-
}
795-
796785
auto graph = compiler->parse(std::move(blobPtr), localConfig);
797786
graph->update_network_name("net" + std::to_string(_compiledModelLoadCounter++));
798787

0 commit comments

Comments
 (0)