From 49e880be674d5cb6a9511fd8b4e7e577d428b5db Mon Sep 17 00:00:00 2001 From: MirceaDan99 Date: Tue, 14 Jan 2025 18:25:04 +0200 Subject: [PATCH] Fix offsets mismatch for HETERO plugin blob headers --- .../intel_npu/src/plugin/include/metadata.hpp | 52 ------------------- .../intel_npu/src/plugin/src/plugin.cpp | 2 +- .../tests/unit/npu/metadata_version.cpp | 41 --------------- 3 files changed, 1 insertion(+), 94 deletions(-) diff --git a/src/plugins/intel_npu/src/plugin/include/metadata.hpp b/src/plugins/intel_npu/src/plugin/include/metadata.hpp index d2be257c02bb8f..f4ae25e84c9136 100644 --- a/src/plugins/intel_npu/src/plugin/include/metadata.hpp +++ b/src/plugins/intel_npu/src/plugin/include/metadata.hpp @@ -64,58 +64,6 @@ struct MetadataBase { } }; -struct MetadataBase { -protected: - uint32_t _version; - -public: - MetadataBase(uint32_t version) : _version(version) {} - - /** - * @brief Reads metadata from a stream. - */ - virtual void read(std::istream& stream) = 0; - - /** - * @brief Writes metadata to a stream. - */ - virtual void write(std::ostream& stream) = 0; - - virtual bool is_compatible() = 0; - - virtual uint64_t get_blob_size() const = 0; - - virtual ~MetadataBase() = default; - - /** - * @brief Returns a uint32_t value which represents two uint16_t values concatenated. - * @details Convention for bumping the metadata version: - * - Increment Major in case of: removing a current field OR adding a new field in between fields. - * - Increment Minor in case of: adding a new field at the end. - * - * @return Major and minor versions concatenated into a single uint32_t value. - */ - static constexpr uint32_t make_version(uint16_t major, uint16_t minor) { - return major << 16 | (minor & 0x0000ffff); - } - - /** - * @brief Gets the major version. - * @return Major version. - */ - static constexpr uint16_t get_major(uint32_t version) { - return static_cast(version >> 16); - } - - /** - * @brief Gets the minor version. - * @return Minor version. - */ - static constexpr uint16_t get_minor(uint32_t version) { - return static_cast(version); - } -}; - /** * @brief Magic bytes used for identifying NPU blobs. */ diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp index dfef6d475024de..fb863e1cfa7f0f 100644 --- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp +++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp @@ -766,7 +766,7 @@ std::shared_ptr Plugin::import_model(std::istream& stream, c npu_plugin_properties.erase(ov::internal::cached_model_buffer.name()); } - const std::map propertiesMap = any_copy(npu_plugin_properties); + const auto propertiesMap = any_copy(npu_plugin_properties); auto localConfig = merge_configs(_globalConfig, propertiesMap, OptionMode::RunTime); _logger.setLevel(localConfig.get()); diff --git a/src/plugins/intel_npu/tests/unit/npu/metadata_version.cpp b/src/plugins/intel_npu/tests/unit/npu/metadata_version.cpp index 9bd2193db3f6ef..0c94a1e5334b36 100644 --- a/src/plugins/intel_npu/tests/unit/npu/metadata_version.cpp +++ b/src/plugins/intel_npu/tests/unit/npu/metadata_version.cpp @@ -199,44 +199,3 @@ TEST_F(MetadataUnitTests, writeAndReadMetadataWithRemovedField) { std::unique_ptr storedMeta; EXPECT_ANY_THROW(storedMeta = read_metadata_from(stream)); } - -struct MetadataVersionTestFixture : Metadata, ::testing::TestWithParam { -public: - std::stringstream blob; - - void set_version(uint32_t newVersion) { - _version = newVersion; - } - - MetadataVersionTestFixture() : Metadata(0, std::nullopt) {} - - MetadataVersionTestFixture(uint64_t blobSize, std::optional ovVersion) - : Metadata(blobSize, ovVersion) {} - - void TestBody() override {} -}; - -TEST_P(MetadataVersionTestFixture, readInvalidMetadataVersion) { - auto dummyMeta = MetadataVersionTestFixture(0, ov::get_openvino_version().buildNumber); - auto metaVersion = GetParam(); - - dummyMeta.set_version(metaVersion); - - OV_ASSERT_NO_THROW(dummyMeta.write(blob)); - - ASSERT_ANY_THROW(read_metadata_from(blob)); -} - -constexpr uint16_t currentMajor = get_major(CURRENT_METADATA_VERSION), - currentMinor = get_minor(CURRENT_METADATA_VERSION); - -INSTANTIATE_TEST_CASE_P(MetadataUnitTests, - MetadataVersionTestFixture, - ::testing::Values(make_version(currentMajor, currentMinor + 1), - make_version(currentMajor, currentMinor - 1), - make_version(currentMajor + 1, currentMinor), - make_version(currentMajor + 1, currentMinor + 1), - make_version(currentMajor + 1, currentMinor - 1), - make_version(currentMajor - 1, currentMinor), - make_version(currentMajor - 1, currentMinor + 1), - make_version(currentMajor - 1, currentMinor - 1)));