Skip to content

Commit

Permalink
Move redundant modelBuffer check to metadata.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
MirceaDan99 committed Dec 17, 2024
1 parent ee210c9 commit cd884fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/plugins/intel_npu/src/plugin/src/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ bool Metadata<METADATA_VERSION_1_0>::is_compatible() {
}

std::unique_ptr<MetadataBase> read_metadata_from(std::istream& stream) {
Logger logger("NPUPlugin", Logger::global().level());
size_t magicBytesSize = MAGIC_BYTES.size();
std::string blobMagicBytes;
blobMagicBytes.resize(magicBytesSize);
Expand Down Expand Up @@ -151,6 +150,11 @@ std::unique_ptr<MetadataBase> read_metadata_from(std::istream& stream) {

std::unique_ptr<MetadataBase> read_metadata_from(std::istream& stream, const std::shared_ptr<ov::AlignedBuffer>& 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);
Expand All @@ -175,7 +179,6 @@ std::unique_ptr<MetadataBase> 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),
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/intel_npu/src/plugin/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,13 +760,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c
auto compiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), localConfig);

std::unique_ptr<BlobContainer> blobPtr;
std::unique_ptr<MetadataBase> storedMeta;

if (dynamic_cast<ov::OwningSharedStreamBuffer*>(stream.rdbuf())) {
storedMeta = read_metadata_from(stream, dynamic_cast<ov::OwningSharedStreamBuffer*>(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!");
Expand Down

0 comments on commit cd884fb

Please sign in to comment.