Skip to content

Commit a47ea59

Browse files
committedJan 17, 2025·
Fix offsets mismatch for HETERO plugin blob headers
1 parent 2d290ef commit a47ea59

File tree

4 files changed

+2
-95
lines changed

4 files changed

+2
-95
lines changed
 

‎src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DriverGraph::DriverGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,
3434

3535
size_t DriverGraph::export_blob(std::ostream& stream) const {
3636
const uint8_t* blobPtr = nullptr;
37-
size_t blobSize = -1;
37+
size_t blobSize;
3838
std::vector<uint8_t> blob;
3939

4040
if (_blobIsReleased) {

‎src/plugins/intel_npu/src/plugin/include/metadata.hpp

-52
Original file line numberDiff line numberDiff line change
@@ -64,58 +64,6 @@ struct MetadataBase {
6464
}
6565
};
6666

67-
struct MetadataBase {
68-
protected:
69-
uint32_t _version;
70-
71-
public:
72-
MetadataBase(uint32_t version) : _version(version) {}
73-
74-
/**
75-
* @brief Reads metadata from a stream.
76-
*/
77-
virtual void read(std::istream& stream) = 0;
78-
79-
/**
80-
* @brief Writes metadata to a stream.
81-
*/
82-
virtual void write(std::ostream& stream) = 0;
83-
84-
virtual bool is_compatible() = 0;
85-
86-
virtual uint64_t get_blob_size() const = 0;
87-
88-
virtual ~MetadataBase() = default;
89-
90-
/**
91-
* @brief Returns a uint32_t value which represents two uint16_t values concatenated.
92-
* @details Convention for bumping the metadata version:
93-
* - Increment Major in case of: removing a current field OR adding a new field in between fields.
94-
* - Increment Minor in case of: adding a new field at the end.
95-
*
96-
* @return Major and minor versions concatenated into a single uint32_t value.
97-
*/
98-
static constexpr uint32_t make_version(uint16_t major, uint16_t minor) {
99-
return major << 16 | (minor & 0x0000ffff);
100-
}
101-
102-
/**
103-
* @brief Gets the major version.
104-
* @return Major version.
105-
*/
106-
static constexpr uint16_t get_major(uint32_t version) {
107-
return static_cast<uint16_t>(version >> 16);
108-
}
109-
110-
/**
111-
* @brief Gets the minor version.
112-
* @return Minor version.
113-
*/
114-
static constexpr uint16_t get_minor(uint32_t version) {
115-
return static_cast<uint16_t>(version);
116-
}
117-
};
118-
11967
/**
12068
* @brief Magic bytes used for identifying NPU blobs.
12169
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c
766766
npu_plugin_properties.erase(ov::internal::cached_model_buffer.name());
767767
}
768768

769-
const std::map<std::string, std::string> propertiesMap = any_copy(npu_plugin_properties);
769+
const auto propertiesMap = any_copy(npu_plugin_properties);
770770

771771
auto localConfig = merge_configs(_globalConfig, propertiesMap, OptionMode::RunTime);
772772
_logger.setLevel(localConfig.get<LOG_LEVEL>());

‎src/plugins/intel_npu/tests/unit/npu/metadata_version.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -199,44 +199,3 @@ TEST_F(MetadataUnitTests, writeAndReadMetadataWithRemovedField) {
199199
std::unique_ptr<MetadataBase> storedMeta;
200200
EXPECT_ANY_THROW(storedMeta = read_metadata_from(stream));
201201
}
202-
203-
struct MetadataVersionTestFixture : Metadata<CURRENT_METADATA_VERSION>, ::testing::TestWithParam<uint32_t> {
204-
public:
205-
std::stringstream blob;
206-
207-
void set_version(uint32_t newVersion) {
208-
_version = newVersion;
209-
}
210-
211-
MetadataVersionTestFixture() : Metadata<CURRENT_METADATA_VERSION>(0, std::nullopt) {}
212-
213-
MetadataVersionTestFixture(uint64_t blobSize, std::optional<std::string_view> ovVersion)
214-
: Metadata<CURRENT_METADATA_VERSION>(blobSize, ovVersion) {}
215-
216-
void TestBody() override {}
217-
};
218-
219-
TEST_P(MetadataVersionTestFixture, readInvalidMetadataVersion) {
220-
auto dummyMeta = MetadataVersionTestFixture(0, ov::get_openvino_version().buildNumber);
221-
auto metaVersion = GetParam();
222-
223-
dummyMeta.set_version(metaVersion);
224-
225-
OV_ASSERT_NO_THROW(dummyMeta.write(blob));
226-
227-
ASSERT_ANY_THROW(read_metadata_from(blob));
228-
}
229-
230-
constexpr uint16_t currentMajor = get_major(CURRENT_METADATA_VERSION),
231-
currentMinor = get_minor(CURRENT_METADATA_VERSION);
232-
233-
INSTANTIATE_TEST_CASE_P(MetadataUnitTests,
234-
MetadataVersionTestFixture,
235-
::testing::Values(make_version(currentMajor, currentMinor + 1),
236-
make_version(currentMajor, currentMinor - 1),
237-
make_version(currentMajor + 1, currentMinor),
238-
make_version(currentMajor + 1, currentMinor + 1),
239-
make_version(currentMajor + 1, currentMinor - 1),
240-
make_version(currentMajor - 1, currentMinor),
241-
make_version(currentMajor - 1, currentMinor + 1),
242-
make_version(currentMajor - 1, currentMinor - 1)));

0 commit comments

Comments
 (0)