Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Remove metadata padding (#35492)

Alexandru Enache36a7d9a2dba1
diff --git a/src/plugins/intel_npu/src/plugin/include/metadata.hpp b/src/plugins/intel_npu/src/plugin/include/metadata.hpp
index 5f0b15ef997..fb350ef0246 100644
--- a/src/plugins/intel_npu/src/plugin/include/metadata.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/metadata.hpp
@@ -107,7 +107,7 @@ protected:
* @note This operation was detached from "write" since "write" writes at the beginning of the stream, while this
* method writes at the end. This change allows better extension of class hierarchy.
*/
- void append_padding_blob_size_and_magic(std::ostream& stream);
+ void append_blob_size_and_magic(std::ostream& stream);
uint32_t _version;
uint64_t _blobDataSize;
diff --git a/src/plugins/intel_npu/src/plugin/src/metadata.cpp b/src/plugins/intel_npu/src/plugin/src/metadata.cpp
index 1fc0b2c321c..94c08db06ba 100644
--- a/src/plugins/intel_npu/src/plugin/src/metadata.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/metadata.cpp
@@ -130,14 +130,7 @@ void MetadataBase::read_data_from_source(char* destination, const size_t size) {
}
}
-void MetadataBase::append_padding_blob_size_and_magic(std::ostream& stream) {
- size_t metadataSize = get_metadata_size() + sizeof(_blobDataSize) + MAGIC_BYTES.size();
- size_t size = utils::align_size_to_standard_page_size(metadataSize);
- size_t paddingSize = size - metadataSize;
- if (paddingSize > 0) {
- std::fill_n(std::ostream_iterator<char>(stream), paddingSize, 0);
- }
-
+void MetadataBase::append_blob_size_and_magic(std::ostream& stream) {
stream.write(reinterpret_cast<const char*>(&_blobDataSize), sizeof(_blobDataSize));
stream.write(MAGIC_BYTES.data(), MAGIC_BYTES.size());
}
@@ -281,7 +274,7 @@ void Metadata<METADATA_VERSION_2_4>::write(std::ostream& stream) {
uint32_t compilerVersion = _compilerVersion.value_or(0);
stream.write(reinterpret_cast<const char*>(&compilerVersion), sizeof(compilerVersion));
- append_padding_blob_size_and_magic(stream);
+ append_blob_size_and_magic(stream);
}
std::unique_ptr<MetadataBase> create_metadata(uint32_t version, uint64_t blobSize) {
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
index 3e231299118..c9eadd14c51 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
@@ -68,20 +68,23 @@ TEST_P(OVCompiledGraphImportExportTestNPU, CanImportModelWithApplicationHeaderAn
}
}
-TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfExportedModelIfMultipleOfPageSize) {
+TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfRawBlobIfMultipleOfPageSize) {
ov::Core core;
std::stringstream sstream;
+ auto rawBlobConfig = configuration;
+ rawBlobConfig.emplace(ov::intel_npu::export_raw_blob(true));
+
auto model = ov::test::utils::make_conv_pool_relu();
- core.compile_model(model, target_device, configuration).export_model(sstream);
+ core.compile_model(model, target_device, rawBlobConfig).export_model(sstream);
std::size_t size = sstream.str().size();
- ASSERT_TRUE(size != 0) << "Size of the exported model shall be different from 0";
- ASSERT_TRUE(size % 4096 == 0) << "Size of the exported model shall be multiple of 4096";
+ ASSERT_TRUE(size != 0) << "Size of the blob should be different from 0";
+ ASSERT_TRUE(size % 4096 == 0) << "Size of the blob should be multiple of 4096";
}
-TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfBlobIfMultipleOfPageSize) {
+TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfExportedModelIfMultipleOfPageSize) {
ov::Core core;
std::stringstream sstream;