OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Core] hsm: Implement codec for compile options (#39332)
Tomasz Jankowski1073978ace36
diff --git a/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/compiled-model.rst b/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/compiled-model.rstindex dba502e73d4..d5e26fd1b3f 100644--- a/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/compiled-model.rst+++ b/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/compiled-model.rst@@ -82,7 +82,7 @@ By default, the Template plugin exports an HSM blob: a container of sections. Thseekable. The blob has these sections:* model id and runtime requirements-* compiled options: the values of the properties listed by ``ov::internal::caching_properties`` and+* compile options: the values of the properties listed by ``ov::internal::caching_properties`` and``ov::weights_path``, if it is set* model structure (XML) and weights* blob info, which tells if the weights are stored in the blobdiff --git a/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/plugin.rst b/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/plugin.rstindex c8e2985eb81..b4da7bb5c17 100644--- a/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/plugin.rst+++ b/docs/articles_en/documentation/openvino-extensibility/openvino-plugin-library/plugin.rst@@ -209,11 +209,11 @@ The import works in these steps:* The model structure and the blob info sections are mandatory.* The blob is rejected if its runtime requirements are not supported by the plugin.-* The compiled options are restored into the plugin configuration. Properties passed to+* The compile options are restored into the plugin configuration. Properties passed to``import_model`` have a higher priority.* The weights are taken from the blob. If the blob has no weights section (for example, it was exportedwith ``ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE)``), they are read from ``ov::weights_path``,- or from the path stored in the compiled options.+ or from the path stored in the compile options.* Sections that the plugin does not know are skipped, so blobs written by a newer format minor versionstill import.diff --git a/src/inference/dev_api/openvino/runtime/hsm_compile_options_codec.hpp b/src/inference/dev_api/openvino/runtime/hsm_compile_options_codec.hppnew file mode 100644index 00000000000..12f72cc31b7--- /dev/null+++ b/src/inference/dev_api/openvino/runtime/hsm_compile_options_codec.hpp@@ -0,0 +1,82 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++/**+ * @brief Plugin-agnostic codec for the #compile_options_tag section payload.+ * @file openvino/runtime/hsm_compile_options_codec.hpp+ *+ * The payload is one encoded `ov::AnyMap`, written and parsed as a stream - no lengths, no size limits:+ * @verbatim+ Payload := Entry* FS digest+ Entry := Leaf | Map | Reserved+ Leaf := key US value US+ Map := key GS Entry* GS+ Reserved := key RS content RS+ @endverbatim+ * - Separators: `US` = 0x1F, `GS` = 0x1D, `RS` = 0x1E, `FS` = 0x1C. `key` and `value` are byte strings+ * containing none of `NUL`, `US`, `GS`, `RS`, `FS`; `content` is any bytes except `RS` and `FS`.+ * - A Leaf holds a string value, a Map a nested options map. Entries of one map are unique by key, whatever+ * their kind; they may come in any order.+ * - An entry with an empty key is skipped by the decoder. A `GS` with no key bytes before it closes the current+ * map instead.+ * - Reserved is for future extensions: the decoder skips it entirely, its key included; the encoder never writes it.+ * - `digest` is 8 bytes in native byte order. Every payload byte before it, `FS` included, is packed into 64-bit+ * words (the first byte is the lowest; a trailing partial word is zero-padded); `h = 0`, then+ * `h = ov::util::u64_hash_combine(h, word)` for every word. It detects accidental corruption only. The section+ * size must be exactly the position of `FS` + 1 + 8.+ */++#pragma once++#include <functional>+#include <optional>++#include "openvino/core/any.hpp"+#include "openvino/runtime/common.hpp"+#include "openvino/runtime/hsm_reader.hpp"+#include "openvino/runtime/hsm_writer.hpp"++namespace ov::runtime::hsm {+inline namespace v1 {++/**+ * @brief #ISectionEncoder for a #compile_options_tag section: borrows @p options and writes them straight to the+ * sink, with no intermediate buffer - for the unsized #IWriter::add_section() overload.+ * @note The borrowed map must outlive #IWriter::finalize().+ * @note Value types:+ * - `std::string` is written as is;+ * - `ov::AnyMap` and `std::map<std::string, ov::AnyMap>` (e.g. `ov::device::properties`) become nested maps;+ * - any other value is written as its `ov::Any::print()` text in the classic "C" locale, floating-point values+ * with `max_digits10` digits.+ * Such a value must read back unchanged through `ov::util::Read` - callbacks, pointers and tensors can't be+ * stored, leave them out of @p options.+ * @note Every nested map is decoded as `ov::AnyMap` and every leaf as `std::string`, whatever type was encoded.+ */+class OPENVINO_RUNTIME_API CompileOptionsEncoder final : public ISectionEncoder {+public:+ explicit CompileOptionsEncoder(const ov::AnyMap& options) noexcept : m_options{options} {}+ explicit CompileOptionsEncoder(ov::AnyMap&&) = delete;+ explicit CompileOptionsEncoder(const ov::AnyMap&&) = delete;++ /**+ * @throw ov::Exception if a key is empty, an `ov::Any` is empty, a key or value contains a reserved byte+ * (`NUL`, `US`, `GS`, `RS`, `FS`), a non-string value has no text form, or its conversion throws. Part of the+ * section may already be written to @p sink by then.+ */+ void encode(const SectionSink& sink) const override;++private:+ std::reference_wrapper<const ov::AnyMap> m_options;+};++/**+ * @brief Decodes a #compile_options_tag payload.+ * @param section Section to decode; its tag must be #compile_options_tag.+ * @return Decoded options; `std::nullopt` if the section is malformed, the hash does not match, or a key appears+ * more than once within the same map level (as a leaf, a nested map, or both).+ */+OPENVINO_RUNTIME_API std::optional<ov::AnyMap> decode_compile_options(const Section& section);++} // namespace v1+} // namespace ov::runtime::hsmdiff --git a/src/inference/dev_api/openvino/runtime/hsm_format.hpp b/src/inference/dev_api/openvino/runtime/hsm_format.hppindex 75b6025c9bd..3014ce7f0e6 100644--- a/src/inference/dev_api/openvino/runtime/hsm_format.hpp+++ b/src/inference/dev_api/openvino/runtime/hsm_format.hpp@@ -272,7 +272,7 @@ enum class Tags : uint32_t {model = 2, //!< See #model.runtime_requirements = 3, //!< See #runtime_requirements_tag.weights = 4, //!< See #weights_tag.- compiled_options = 5, //!< See #compiled_options_tag.+ compile_options = 5, //!< See #compile_options_tag.// Add new Core tags above this line only, each with the next explicit value - never change or reuse an// existing tag's value.sentinel_count, // Not a real tag id - always exactly one past the last real entry above.@@ -284,7 +284,7 @@ inline constexpr uint32_t model_id = static_cast<uint32_t>(Tags::model_id); //!inline constexpr uint32_t model = static_cast<uint32_t>(Tags::model); //!< The serialized compiled model itself.inline constexpr uint32_t runtime_requirements = static_cast<uint32_t>(Tags::runtime_requirements);inline constexpr uint32_t weights = static_cast<uint32_t>(Tags::weights);-inline constexpr uint32_t compiled_options = static_cast<uint32_t>(Tags::compiled_options);+inline constexpr uint32_t compile_options = static_cast<uint32_t>(Tags::compile_options);/// Wire tag for #model_id - always inline-mode.inline constexpr SectionTag model_id_tag = SectionTag::make(model_id, /*is_inline=*/true);@@ -304,8 +304,8 @@ inline constexpr SectionTag runtime_requirements_tag = SectionTag::make(runtime_/// Wire tag for #weights - always pointer-mode. Payload contract: CVS-196451.inline constexpr SectionTag weights_tag = SectionTag::make(weights, /*is_inline=*/false);-/// Wire tag for #compiled_options - always pointer-mode. Payload contract: CVS-196452.-inline constexpr SectionTag compiled_options_tag = SectionTag::make(compiled_options, /*is_inline=*/false);+/// Wire tag for #compile_options - always pointer-mode. Payload: see openvino/runtime/hsm_compile_options_codec.hpp.+inline constexpr SectionTag compile_options_tag = SectionTag::make(compile_options, /*is_inline=*/false);/*** @brief One fixed-size, 32-byte record of the manifest table (see #Header::manifest_offset).diff --git a/src/inference/sources.cmake b/src/inference/sources.cmakeindex c49c2441167..7cef93983a3 100644--- a/src/inference/sources.cmake+++ b/src/inference/sources.cmake@@ -20,6 +20,7 @@ set(OV_RUNTIME_SRCS${CMAKE_CURRENT_LIST_DIR}/src/dev/core_impl.cpp${CMAKE_CURRENT_LIST_DIR}/src/dev/device_id_parser.cpp${CMAKE_CURRENT_LIST_DIR}/src/dev/exec_model_info.cpp+ ${CMAKE_CURRENT_LIST_DIR}/src/dev/hsm_compile_options_codec.cpp${CMAKE_CURRENT_LIST_DIR}/src/dev/hsm_format.cpp${CMAKE_CURRENT_LIST_DIR}/src/dev/hsm_deferred_writer.cpp${CMAKE_CURRENT_LIST_DIR}/src/dev/hsm_model_id_codec.cppdiff --git a/src/inference/src/dev/hsm_compile_options_codec.cpp b/src/inference/src/dev/hsm_compile_options_codec.cppnew file mode 100644index 00000000000..584be5f70c1--- /dev/null+++ b/src/inference/src/dev/hsm_compile_options_codec.cpp@@ -0,0 +1,358 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/runtime/hsm_compile_options_codec.hpp"++#include <algorithm>+#include <array>+#include <cstdint>+#include <exception>+#include <iomanip>+#include <limits>+#include <locale>+#include <map>+#include <optional>+#include <sstream>+#include <string>+#include <string_view>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/util/hash_util.hpp"+#include "openvino/util/memory.hpp"++namespace ov::runtime::hsm {+inline namespace v1 {+namespace {++constexpr char us = '\x1f'; // ends a key and its value+constexpr char gs = '\x1d'; // opens and closes a nested map+constexpr char rs = '\x1e'; // opens and closes a reserved block+constexpr char fs = '\x1c'; // ends the entries+constexpr std::string_view reserved_bytes{"\0\x1f\x1d\x1e\x1c", 5};++// Packs bytes into little-endian 64-bit words and folds every complete word into the hash.+class HashAccumulator {+public:+ HashAccumulator() noexcept : m_hash{0}, m_word{0}, m_count{0} {}++ void add(char byte) noexcept {+ m_word |= static_cast<uint64_t>(static_cast<uint8_t>(byte)) << (8 * m_count);+ if (++m_count == sizeof(m_word)) {+ m_hash = ov::util::u64_hash_combine(m_hash, m_word);+ m_word = 0;+ m_count = 0;+ }+ }++ void add(std::string_view bytes) noexcept {+ for (const auto byte : bytes) {+ add(byte);+ }+ }++ // A trailing partial word is zero-padded; the accumulator itself is not changed.+ uint64_t digest() const noexcept {+ return m_count == 0 ? m_hash : ov::util::u64_hash_combine(m_hash, m_word);+ }++private:+ uint64_t m_hash;+ uint64_t m_word;+ size_t m_count;+};++// Sends every piece to the sink and folds it into the digest that closes the payload.+class HashingWriter {+public:+ explicit HashingWriter(const SectionSink& sink) noexcept : m_sink{sink} {}++ void put(std::string_view bytes) {+ if (!bytes.empty()) {+ m_hash.add(bytes);+ m_sink(ov::util::as_memory_view(bytes));+ }+ }++ void put(char separator) {+ put(std::string_view{&separator, 1});+ }++ void finish() {+ put(fs);+ const auto digest = m_hash.digest();+ m_sink(ov::util::as_memory_view(digest));+ }++private:+ const SectionSink& m_sink;+ HashAccumulator m_hash;+};++void check_text(std::string_view what, std::string_view text, std::string_view key) {+ OPENVINO_ASSERT(text.find_first_of(reserved_bytes) == std::string_view::npos,+ "Compile option ",+ what,+ " contains a reserved byte (NUL, 0x1C-0x1F), key: ",+ key);+}++template <class T>+bool set_precision(std::ostream& os, const ov::Any& value) {+ if (value.is<T>()) {+ os << std::setprecision(std::numeric_limits<T>::max_digits10);+ return true;+ }+ return false;+}++// Classic locale and max_digits10 keep the text deterministic and parseable back to the same value.+std::string to_option_string(const ov::Any& value) {+ std::ostringstream os;+ os.imbue(std::locale::classic());+ (set_precision<float>(os, value) || set_precision<double>(os, value) || set_precision<long double>(os, value));+ value.print(os);+ return os.str();+}++void write_key(HashingWriter& out, const std::string& key) {+ OPENVINO_ASSERT(!key.empty(), "Compile option key must not be empty");+ check_text("key", key, key);+ out.put(key);+}++void write_leaf(HashingWriter& out, const std::string& key, const std::string& text) {+ write_key(out, key);+ out.put(us);+ check_text("value", text, key);+ out.put(text);+ out.put(us);+}++void write_entries(HashingWriter& out, const ov::AnyMap& options);++void write_nested(HashingWriter& out, const std::string& key, const ov::AnyMap& options) {+ write_key(out, key);+ out.put(gs);+ write_entries(out, options);+ out.put(gs);+}++void write_nested(HashingWriter& out, const std::string& key, const std::map<std::string, ov::AnyMap>& options) {+ write_key(out, key);+ out.put(gs);+ for (const auto& [name, nested] : options) {+ write_nested(out, name, nested);+ }+ out.put(gs);+}++void write_entries(HashingWriter& out, const ov::AnyMap& options) {+ for (const auto& [key, value] : options) {+ OPENVINO_ASSERT(!value.empty(), "Compile option value must not be empty, key: ", key);++ if (value.is<std::string>()) {+ write_leaf(out, key, value.as<std::string>());+ } else if (value.is<ov::AnyMap>()) {+ write_nested(out, key, value.as<ov::AnyMap>());+ } else if (value.is<std::map<std::string, ov::AnyMap>>()) {+ write_nested(out, key, value.as<std::map<std::string, ov::AnyMap>>());+ } else {+ std::string text;+ try {+ text = to_option_string(value);+ } catch (const std::exception& e) {+ OPENVINO_THROW("Cannot convert compile option ", key, " to string: ", e.what());+ }+ OPENVINO_ASSERT(!text.empty(),+ "Compile option ",+ key,+ " of type ",+ value.type_info().name(),+ " has no string form");+ write_leaf(out, key, text);+ }+ }+}++enum class Status { more, done, malformed };++/*+ * Byte-at-a-time parser; open nested maps live on a heap stack so depth is bounded by memory, not the call stack.+ *+ * state byte action next+ * key other append to key key+ * US - value+ * GS key set: open nested map; key empty: close map key+ * RS drop key reserved+ * FS key empty at root: done; otherwise malformed -+ * NUL malformed -+ * value other append to value value+ * US store leaf (duplicate key: malformed) key+ * GS RS FS NUL malformed -+ * reserved other skip reserved+ * RS - key+ * FS malformed -+ */+class Parser {+public:+ Parser() {+ m_levels.emplace_back();+ }++ Status consume(char byte) {+ switch (m_state) {+ case State::key:+ return on_key(byte);+ case State::value:+ return on_value(byte);+ default:+ return on_reserved(byte);+ }+ }++ ov::AnyMap take() {+ return std::move(m_levels.front().options);+ }++private:+ enum class State { key, value, reserved };++ struct Level {+ std::string name;+ ov::AnyMap options;+ };++ Status on_key(char byte) {+ switch (byte) {+ case us:+ m_state = State::value;+ return Status::more;+ case gs:+ return m_key.empty() ? close_level() : open_level();+ case rs:+ m_key.clear();+ m_state = State::reserved;+ return Status::more;+ case fs:+ return m_key.empty() && m_levels.size() == 1 ? Status::done : Status::malformed;+ case '\0':+ return Status::malformed;+ default:+ m_key.push_back(byte);+ return Status::more;+ }+ }++ Status on_value(char byte) {+ switch (byte) {+ case us:+ if (!m_key.empty() && !m_levels.back().options.emplace(m_key, ov::Any{std::move(m_value)}).second) {+ return Status::malformed;+ }+ m_key.clear();+ m_value.clear();+ m_state = State::key;+ return Status::more;+ case gs:+ case rs:+ case fs:+ case '\0':+ return Status::malformed;+ default:+ m_value.push_back(byte);+ return Status::more;+ }+ }++ Status on_reserved(char byte) {+ if (byte == fs) {+ return Status::malformed;+ } else if (byte == rs) {+ m_state = State::key;+ }+ return Status::more;+ }++ // The key is checked here, not when the map closes: nothing else can add to this level meanwhile.+ Status open_level() {+ if (m_levels.back().options.count(m_key) != 0) {+ return Status::malformed;+ }+ m_levels.push_back({std::move(m_key), {}});+ m_key.clear();+ return Status::more;+ }++ Status close_level() {+ if (m_levels.size() == 1) {+ return Status::malformed;+ }+ auto level = std::move(m_levels.back());+ m_levels.pop_back();+ m_levels.back().options.emplace(std::move(level.name), ov::Any{std::move(level.options)});+ return Status::more;+ }++ State m_state = State::key;+ std::string m_key;+ std::string m_value;+ std::vector<Level> m_levels;+};++constexpr size_t chunk_size = ov::util::min_page_alignment;++} // namespace++void CompileOptionsEncoder::encode(const SectionSink& sink) const {+ HashingWriter out{sink};+ write_entries(out, m_options.get());+ out.finish();+}++std::optional<ov::AnyMap> decode_compile_options(const Section& section) {+ const auto size = section.size();+ if (size == 0) {+ return std::nullopt;+ }++ std::array<std::byte, chunk_size> chunk;+ Parser parser;+ HashAccumulator hash;++ const auto view = section.view();+ ov::util::MemoryView block = view;+ for (size_t offset = 0; offset < size;) {+ if (view.empty()) { // No addressable memory (stream-backed): copy the next chunk.+ const auto count = std::min(chunk.size(), size - offset);+ if (!section.read(offset, count, chunk.data())) {+ return std::nullopt;+ }+ block = {chunk.data(), count};+ }++ for (size_t i = 0; i < block.size(); ++i) {+ const auto byte = static_cast<char>(block.data()[i]);+ hash.add(byte);+ switch (parser.consume(byte)) {+ case Status::more:+ break;+ case Status::malformed:+ return std::nullopt;+ case Status::done: {+ const auto digest_offset = offset + i + 1;+ uint64_t digest = 0;+ const auto is_valid = size - digest_offset == sizeof(digest) &&+ section.read(digest_offset, sizeof(digest), &digest) && digest == hash.digest();+ return is_valid ? std::optional{parser.take()} : std::nullopt;+ }+ }+ }+ offset += block.size();+ }+ return std::nullopt;+}++} // namespace v1+} // namespace ov::runtime::hsmdiff --git a/src/inference/tests/unit/CMakeLists.txt b/src/inference/tests/unit/CMakeLists.txtindex bad6934b004..daef41ce37e 100644--- a/src/inference/tests/unit/CMakeLists.txt+++ b/src/inference/tests/unit/CMakeLists.txt@@ -26,6 +26,7 @@ ov_add_test_target(${CMAKE_CURRENT_SOURCE_DIR}/cpu_stream_info_test.cpp${CMAKE_CURRENT_SOURCE_DIR}/executor_config_test.cpp${CMAKE_CURRENT_SOURCE_DIR}/executor_manager_tests.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/hsm_compile_options_codec.cpp${CMAKE_CURRENT_SOURCE_DIR}/hsm_deferred_writer.cpp${CMAKE_CURRENT_SOURCE_DIR}/hsm_format.cpp${CMAKE_CURRENT_SOURCE_DIR}/hsm_model_id_codec.cppdiff --git a/src/inference/tests/unit/hsm_compile_options_codec.cpp b/src/inference/tests/unit/hsm_compile_options_codec.cppnew file mode 100644index 00000000000..86c845908a4--- /dev/null+++ b/src/inference/tests/unit/hsm_compile_options_codec.cpp@@ -0,0 +1,843 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/runtime/hsm_compile_options_codec.hpp"++#include <gtest/gtest.h>++#include <cmath>+#include <cstdint>+#include <ios>+#include <limits>+#include <locale>+#include <map>+#include <memory>+#include <optional>+#include <ostream>+#include <set>+#include <sstream>+#include <stdexcept>+#include <streambuf>+#include <string>+#include <string_view>+#include <type_traits>+#include <utility>+#include <vector>++#include "openvino/core/type/element_type.hpp"+#include "openvino/runtime/hsm_format.hpp"+#include "openvino/runtime/hsm_reader.hpp"+#include "openvino/runtime/hsm_writer.hpp"+#include "openvino/runtime/properties.hpp"+#include "openvino/util/hash_util.hpp"+#include "openvino/util/memory.hpp"++namespace ov::test {+namespace hsm = ov::runtime::hsm;+using namespace std::string_literals;+namespace {++static_assert(std::is_convertible_v<decltype(&hsm::decode_compile_options), hsm::SectionDecoder<ov::AnyMap>>,+ "decode_compile_options(const Section&) must be usable as a SectionDecoder<ov::AnyMap>.");+static_assert(std::is_base_of_v<hsm::ISectionEncoder, hsm::CompileOptionsEncoder>,+ "CompileOptionsEncoder must be an ISectionEncoder.");+static_assert(std::is_convertible_v<std::shared_ptr<hsm::CompileOptionsEncoder>, hsm::SectionEncoderPtr>,+ "CompileOptionsEncoder must be passable as a SectionEncoderPtr.");+static_assert(std::is_constructible_v<hsm::CompileOptionsEncoder, const ov::AnyMap&>,+ "CompileOptionsEncoder must borrow an existing map.");+static_assert(!std::is_constructible_v<hsm::CompileOptionsEncoder, ov::AnyMap&&>,+ "CompileOptionsEncoder must not borrow a temporary map.");+static_assert(!std::is_constructible_v<hsm::CompileOptionsEncoder, const ov::AnyMap&&>,+ "CompileOptionsEncoder must not borrow a temporary const map.");+static_assert(std::is_same_v<decltype(std::declval<hsm::IWriter&>().add_section(+ hsm::DeviceId{},+ hsm::compile_options_tag,+ std::declval<std::shared_ptr<hsm::CompileOptionsEncoder>>())),+ bool>,+ "CompileOptionsEncoder must fit the unsized IWriter::add_section(SectionEncoderPtr).");++constexpr hsm::DeviceId fake_device_id = hsm::private_device_id_range_start + 42;+constexpr size_t chunk_size = ov::util::min_page_alignment;++// Separators, spelled out here on purpose - the codec's own constants are not visible to the tests.+const std::string US{"\x1f"};+const std::string GS{"\x1d"};+const std::string RS{"\x1e"};+const std::string FS{"\x1c"};++// The digest rule from the format description, applied to everything up to and including FS.+std::string digest_of(std::string_view bytes) {+ constexpr size_t word_size = sizeof(uint64_t);+ uint64_t hash = 0;+ for (size_t pos = 0; pos < bytes.size(); pos += word_size) {+ uint64_t word = 0;+ for (size_t i = 0; i < word_size && pos + i < bytes.size(); ++i) {+ word |= static_cast<uint64_t>(static_cast<uint8_t>(bytes[pos + i])) << (8 * i);+ }+ hash = ov::util::u64_hash_combine(hash, word);+ }+ return std::string{reinterpret_cast<const char*>(&hash), sizeof(hash)};+}++// @p body must end with FS.+std::string with_digest(const std::string& body) {+ return body + digest_of(body);+}++/// @p input is what the encoder gets; @p decoded what the decoder must return (if unset, same as @p input).+struct ReferenceCase {+ std::string name;+ ov::AnyMap input;+ std::optional<ov::AnyMap> decoded;+ std::string entries; ///< Everything up to and including FS.+ std::string digest; ///< Little-endian, computed offline by an independent implementation of the rule.++ const ov::AnyMap& expected_decoded() const {+ return decoded ? *decoded : input;+ }++ std::string bytes() const {+ return entries + digest;+ }+};++void PrintTo(const ReferenceCase& reference, std::ostream* os) {+ *os << reference.name;+}++// Reference payloads are spelled out byte by byte - never produced by the codec.+const ReferenceCase empty_map_case{"empty_map", {}, std::nullopt, FS, "\x6c\x57\xd4\xaa\xc2\x65\x0d\x33"s};++const ReferenceCase single_string_case{"single_string",+ {{"k", "v"}},+ std::nullopt,+ "k" + US + "v" + US + FS,+ "\xb9\xd1\xe8\xfc\x6a\x40\xd3\xf8"s};++const ReferenceCase empty_string_value_case{"empty_string_value",+ {{"E", ""}},+ std::nullopt,+ "E" + US + US + FS,+ "\x23\x52\x1a\x2b\x1c\xd9\x50\xbc"s};++const ReferenceCase typed_case{"typed",+ {ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT),+ ov::hint::inference_precision(ov::element::f16),+ ov::enable_profiling(true),+ ov::hint::num_requests(4)},+ ov::AnyMap{{"INFERENCE_PRECISION_HINT", "f16"},+ {"PERFORMANCE_HINT", "THROUGHPUT"},+ {"PERFORMANCE_HINT_NUM_REQUESTS", "4"},+ {"PERF_COUNT", "YES"}},+ "INFERENCE_PRECISION_HINT" + US + "f16" + US + "PERFORMANCE_HINT" + US + "THROUGHPUT" ++ US + "PERFORMANCE_HINT_NUM_REQUESTS" + US + "4" + US + "PERF_COUNT" + US + "YES" ++ US + FS,+ "\x0e\x23\x50\x0c\xa8\x63\xb1\x62"s};++const ReferenceCase special_chars_case{"special_chars",+ {{"a\nb=c", "{x:y,z}"}, {"\xC5\xBC", "\xE2\x9C\x93"}},+ std::nullopt,+ "a\nb=c" + US + "{x:y,z}" + US + "\xC5\xBC" + US + "\xE2\x9C\x93" + US + FS,+ "\x88\x26\x75\x45\x43\x34\x35\x4d"s};++const ReferenceCase nested_empty_map_case{"nested_empty_map",+ {{"M", ov::AnyMap{}}},+ std::nullopt,+ "M" + GS + GS + FS,+ "\x69\xca\x73\x15\x28\xa4\x34\xb2"s};++const ReferenceCase nested_three_levels_case{+ "nested_three_levels",+ {{"A", ov::AnyMap{{"B", ov::AnyMap{{"C", ov::AnyMap{{"k", "v"}}}}}}}, {"T", "1"}},+ std::nullopt,+ "A" + GS + "B" + GS + "C" + GS + "k" + US + "v" + US + GS + GS + GS + "T" + US + "1" + US + FS,+ "\x20\xc5\xcd\xc7\x1f\xce\x6f\x4b"s};++const ReferenceCase sorted_keys_case{"sorted_keys",+ {{"b", "2"}, {"a", "1"}},+ std::nullopt,+ "a" + US + "1" + US + "b" + US + "2" + US + FS,+ "\x12\x82\x94\xf7\xb3\x00\x17\x04"s};++const ReferenceCase numeric_case{+ "numeric",+ {{"D", 0.1}, {"F", 0.1f}, {"I", int64_t{-9000000000}}, {"N", uint32_t{1234}}},+ ov::AnyMap{{"D", "0.10000000000000001"}, {"F", "0.100000001"}, {"I", "-9000000000"}, {"N", "1234"}},+ "D" + US + "0.10000000000000001" + US + "F" + US + "0.100000001" + US + "I" + US + "-9000000000" + US + "N" + US ++ "1234" + US + FS,+ "\x80\x2d\x92\xab\x8e\x3f\x6c\x83"s};++// ov::device::properties holds exactly this type; it must come out as two nested levels.+const ReferenceCase device_properties_case{+ "device_properties_type",+ {{"DEVICE_PROPERTIES",+ std::map<std::string, ov::AnyMap>{{"CPU", {{"CACHE_DIR", "/tmp/c d"}}}, {"GPU", {{"PERF_COUNT", "YES"}}}}}},+ ov::AnyMap{+ {"DEVICE_PROPERTIES",+ ov::AnyMap{{"CPU", ov::AnyMap{{"CACHE_DIR", "/tmp/c d"}}}, {"GPU", ov::AnyMap{{"PERF_COUNT", "YES"}}}}}},+ "DEVICE_PROPERTIES" + GS + "CPU" + GS + "CACHE_DIR" + US + "/tmp/c d" + US + GS + "GPU" + GS + "PERF_COUNT" + US ++ "YES" + US + GS + GS + FS,+ "\xe5\x68\x31\x1e\xe7\x4c\xef\x54"s};++std::vector<ReferenceCase> reference_cases() {+ return {empty_map_case,+ single_string_case,+ empty_string_value_case,+ typed_case,+ special_chars_case,+ nested_empty_map_case,+ nested_three_levels_case,+ sorted_keys_case,+ numeric_case,+ device_properties_case};+}++std::string to_string(ov::util::MemoryView bytes) {+ return {reinterpret_cast<const char*>(bytes.data()), bytes.size()};+}++std::string encode(const ov::AnyMap& options) {+ const hsm::CompileOptionsEncoder encoder{options};+ std::string written;+ encoder.encode([&written](ov::util::MemoryView chunk) {+ written += to_string(chunk);+ });+ return written;+}++hsm::ManifestEntry make_entry(size_t size) {+ hsm::ManifestEntry entry{};+ entry.device = fake_device_id;+ entry.tag = hsm::compile_options_tag;+ entry.size = size;+ return entry;+}++std::optional<ov::AnyMap> decode_buffer(std::string_view bytes) {+ return hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), ov::util::as_memory_view(bytes)});+}++// The payload starts at a non-zero stream position, as it does inside a container.+std::optional<ov::AnyMap> decode_stream(std::string_view bytes) {+ std::stringstream stream{"prefix" + std::string{bytes}};+ return hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 6});+}++// Any::operator== is false for two empty Anys, so compare structurally; decoded leaves must be strings.+::testing::AssertionResult same_options(const ov::AnyMap& actual,+ const ov::AnyMap& expected,+ const std::string& path = {}) {+ if (actual.size() != expected.size()) {+ return ::testing::AssertionFailure()+ << path << "/: " << actual.size() << " entries, expected " << expected.size();+ }+ for (const auto& [key, value] : expected) {+ const auto where = path + "/" + key;+ const auto found = actual.find(key);+ if (found == actual.end()) {+ return ::testing::AssertionFailure() << where << ": missing";+ }+ const auto& got = found->second;+ if (value.is<ov::AnyMap>()) {+ if (!got.is<ov::AnyMap>()) {+ return ::testing::AssertionFailure() << where << ": expected a nested map";+ }+ if (auto nested = same_options(got.as<ov::AnyMap>(), value.as<ov::AnyMap>(), where); !nested) {+ return nested;+ }+ } else if (!got.is<std::string>() || got.as<std::string>() != value.as<std::string>()) {+ return ::testing::AssertionFailure()+ << where << ": got " << (got.is<std::string>() ? got.as<std::string>() : "<not a string>")+ << ", expected " << value.as<std::string>();+ }+ }+ return ::testing::AssertionSuccess();+}++// Decodes from a buffer-backed and from a stream-backed section.+void expect_decoded(std::string_view bytes, const ov::AnyMap& expected) {+ const auto from_buffer = decode_buffer(bytes);+ ASSERT_TRUE(from_buffer);+ EXPECT_TRUE(same_options(*from_buffer, expected));++ const auto from_stream = decode_stream(bytes);+ ASSERT_TRUE(from_stream);+ EXPECT_TRUE(same_options(*from_stream, expected));+}++void expect_rejected(std::string_view bytes) {+ EXPECT_FALSE(decode_buffer(bytes));+ EXPECT_FALSE(decode_stream(bytes));+}++template <typename Value>+void expect_value_roundtrip(const Value& input, const std::optional<std::string>& expected_text = std::nullopt) {+ const ov::AnyMap options{{"k", input}};+ const auto bytes = encode(options);+ for (const auto& [source, decoded] :+ {std::pair{"buffer", decode_buffer(bytes)}, std::pair{"stream", decode_stream(bytes)}}) {+ SCOPED_TRACE(source);+ ASSERT_TRUE(decoded);+ ASSERT_EQ(decoded->size(), 1);+ const ov::Any& leaf = decoded->at("k");+ ASSERT_TRUE(leaf.is<std::string>());+ if (expected_text) {+ EXPECT_EQ(leaf.as<std::string>(), *expected_text);+ }+ const auto restored = leaf.as<Value>();+ EXPECT_EQ(restored, input);+ if constexpr (std::is_floating_point_v<Value>) {+ EXPECT_EQ(std::signbit(restored), std::signbit(input));+ }+ }+}++template <class Case>+std::string case_name(const ::testing::TestParamInfo<Case>& info) {+ return info.param.name;+}++} // namespace++// --- Format: the reference digests follow the documented rule ---++using HsmCompileOptionsFormatReferenceTest = ::testing::TestWithParam<ReferenceCase>;++TEST_P(HsmCompileOptionsFormatReferenceTest, reference_digest_follows_the_documented_rule) {+ EXPECT_EQ(digest_of(GetParam().entries), GetParam().digest);+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsFormatReferenceTest,+ ::testing::ValuesIn(reference_cases()),+ case_name<ReferenceCase>);++// --- Encoding: options -> reference bytes ---++using HsmCompileOptionsEncodeReferenceTest = ::testing::TestWithParam<ReferenceCase>;++TEST_P(HsmCompileOptionsEncodeReferenceTest, encoder_writes_reference_bytes_to_sink) {+ EXPECT_EQ(encode(GetParam().input), GetParam().bytes());+}++TEST_P(HsmCompileOptionsEncodeReferenceTest, encoding_twice_gives_identical_bytes) {+ const hsm::CompileOptionsEncoder encoder{GetParam().input};+ std::string first;+ std::string second;+ encoder.encode([&first](ov::util::MemoryView chunk) {+ first += to_string(chunk);+ });+ encoder.encode([&second](ov::util::MemoryView chunk) {+ second += to_string(chunk);+ });++ EXPECT_EQ(first, second);+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsEncodeReferenceTest,+ ::testing::ValuesIn(reference_cases()),+ case_name<ReferenceCase>);++TEST(HsmCompileOptionsEncodeTest, digest_covers_every_payload_length_modulo_word_size) {+ for (size_t length = 0; length <= 2 * sizeof(uint64_t); ++length) {+ SCOPED_TRACE(length);+ const std::string value(length, 'x');+ EXPECT_EQ(encode(ov::AnyMap{{"k", value}}), with_digest("k" + US + value + US + FS));+ }+}++namespace {+struct NoStringForm {};++struct ThrowingStringForm {};++std::ostream& operator<<(std::ostream&, const ThrowingStringForm&) {+ throw std::runtime_error{"printer failure"};+}++struct SinkFailure : std::runtime_error {+ using std::runtime_error::runtime_error;+};++class NonSeekableStringBuf : public std::stringbuf {+public:+ using std::stringbuf::stringbuf;++protected:+ pos_type seekpos(pos_type, std::ios_base::openmode) override {+ return pos_type{off_type{-1}};+ }+};++struct InvalidOptionsCase {+ std::string name;+ ov::AnyMap options;+};++void PrintTo(const InvalidOptionsCase& invalid, std::ostream* os) {+ *os << invalid.name;+}++std::vector<InvalidOptionsCase> invalid_options_cases() {+ std::vector<InvalidOptionsCase> cases{+ {"empty_key", {{"", "v"}}},+ {"empty_nested_key", {{"M", ov::AnyMap{{"", "v"}}}}},+ {"empty_key_in_device_properties", {{"M", std::map<std::string, ov::AnyMap>{{"", {{"k", "v"}}}}}}},+ {"empty_any", {{"k", ov::Any{}}}},+ {"empty_nested_any", {{"M", ov::AnyMap{{"k", ov::Any{}}}}}},+ {"non_string_without_text", {{"k", NoStringForm{}}}},+ {"empty_vector_without_text", {{"k", std::vector<int>{}}}},+ };+ for (const char reserved : {'\0', '\x1f', '\x1d', '\x1e', '\x1c'}) {+ const auto suffix = std::to_string(static_cast<int>(reserved));+ const auto with_byte = "a"s + reserved + "b"s;+ cases.push_back({"reserved_byte_in_key_" + suffix, {{with_byte, "v"}}});+ cases.push_back({"reserved_byte_in_nested_key_" + suffix, {{"M", ov::AnyMap{{with_byte, "v"}}}}});+ cases.push_back({"reserved_byte_in_string_value_" + suffix, {{"k", with_byte}}});+ cases.push_back({"reserved_byte_in_printed_value_" + suffix, {{"k", std::vector<std::string>{with_byte}}}});+ }+ return cases;+}+} // namespace++using HsmCompileOptionsEncodeInvalidTest = ::testing::TestWithParam<InvalidOptionsCase>;++TEST_P(HsmCompileOptionsEncodeInvalidTest, encoder_throws) {+ EXPECT_THROW(encode(GetParam().options), ov::Exception);+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsEncodeInvalidTest,+ ::testing::ValuesIn(invalid_options_cases()),+ case_name<InvalidOptionsCase>);++TEST(HsmCompileOptionsEncodeTest, error_for_non_string_value_without_text_names_key_and_type) {+ const ov::AnyMap options{{"THE_KEY", NoStringForm{}}};+ std::string message;+ try {+ encode(options);+ } catch (const ov::Exception& e) {+ message = e.what();+ }++ EXPECT_NE(message.find("THE_KEY"), std::string::npos) << message;+ EXPECT_NE(message.find("NoStringForm"), std::string::npos) << message;+}++TEST(HsmCompileOptionsEncodeTest, printer_exception_is_wrapped_with_key_and_original_message) {+ const ov::AnyMap options{{"THE_KEY", ThrowingStringForm{}}};++ try {+ encode(options);+ FAIL() << "Expected a conversion exception";+ } catch (const ov::Exception& error) {+ const std::string message{error.what()};+ EXPECT_NE(message.find("THE_KEY"), std::string::npos) << message;+ EXPECT_NE(message.find("printer failure"), std::string::npos) << message;+ }+}++using HsmCompileOptionsEncodeSinkExceptionTest = ::testing::TestWithParam<size_t>;++TEST_P(HsmCompileOptionsEncodeSinkExceptionTest, sink_exception_propagates_without_further_output) {+ const hsm::CompileOptionsEncoder encoder{single_string_case.input};+ std::string written;+ size_t failed_calls = 0;++ try {+ encoder.encode([&](ov::util::MemoryView chunk) {+ if (written.size() >= GetParam()) {+ ++failed_calls;+ throw SinkFailure{"sink failure"};+ }+ written += to_string(chunk);+ });+ FAIL() << "Expected a sink exception";+ } catch (const SinkFailure& error) {+ EXPECT_STREQ(error.what(), "sink failure");+ }++ EXPECT_EQ(failed_calls, 1);+ EXPECT_EQ(written, single_string_case.entries.substr(0, GetParam()));+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsEncodeSinkExceptionTest,+ ::testing::Values(size_t{0}, size_t{2}, single_string_case.entries.size()),+ [](const ::testing::TestParamInfo<size_t>& info) {+ if (info.param == 0) {+ return "first_output";+ }+ return info.param == single_string_case.entries.size() ? "digest" : "partial_output";+ });++TEST(HsmCompileOptionsEncodeTest, encoder_encodes_borrowed_map_only_in_encode) {+ ov::AnyMap options{{"", "invalid until fixed"}};+ const hsm::CompileOptionsEncoder encoder{options};++ EXPECT_THROW(encoder.encode([](ov::util::MemoryView) {}), ov::Exception);++ options = single_string_case.input;+ std::string written;+ encoder.encode([&written](ov::util::MemoryView chunk) {+ written += to_string(chunk);+ });+ EXPECT_EQ(written, single_string_case.bytes());+}++namespace {+struct GroupingNumpunct : std::numpunct<char> {+ char do_decimal_point() const override {+ return '/';+ }+ char do_thousands_sep() const override {+ return '_';+ }+ std::string do_grouping() const override {+ return "\2";+ }+};++class GlobalLocaleGuard {+public:+ explicit GlobalLocaleGuard(const std::locale& locale) : m_previous{std::locale::global(locale)} {}+ ~GlobalLocaleGuard() {+ std::locale::global(m_previous);+ }++private:+ std::locale m_previous;+};+} // namespace++TEST(HsmCompileOptionsEncodeTest, numbers_do_not_depend_on_global_locale) {+ const GlobalLocaleGuard guard{std::locale{std::locale::classic(), new GroupingNumpunct}};+ std::ostringstream global_format;+ global_format << 1234.5;+ ASSERT_EQ(global_format.str(), "12_34/5");++ EXPECT_EQ(encode(numeric_case.input), numeric_case.bytes());+}++// --- Decoding: reference bytes -> options ---++using HsmCompileOptionsDecodeReferenceTest = ::testing::TestWithParam<ReferenceCase>;++TEST_P(HsmCompileOptionsDecodeReferenceTest, decode_produces_reference_options) {+ expect_decoded(GetParam().bytes(), GetParam().expected_decoded());+}++TEST_P(HsmCompileOptionsDecodeReferenceTest, every_truncated_prefix_is_rejected) {+ const auto bytes = GetParam().bytes();++ for (size_t size = 0; size < bytes.size(); ++size) {+ EXPECT_FALSE(decode_buffer(std::string_view{bytes}.substr(0, size))) << "prefix size: " << size;+ }+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsDecodeReferenceTest,+ ::testing::ValuesIn(reference_cases()),+ case_name<ReferenceCase>);++namespace {+struct AcceptCase {+ std::string name;+ std::string body; ///< Up to and including FS; the digest is added by the test.+ ov::AnyMap expected;+};++void PrintTo(const AcceptCase& accept, std::ostream* os) {+ *os << accept.name;+}++std::vector<AcceptCase> accept_cases() {+ const std::string reserved_content("\0\x1f\x1d", 3);+ return {+ {"unsorted_keys", "b" + US + "2" + US + "a" + US + "1" + US + FS, {{"a", "1"}, {"b", "2"}}},+ {"same_key_on_different_levels", "a" + GS + "a" + US + "1" + US + GS + FS, {{"a", ov::AnyMap{{"a", "1"}}}}},+ {"empty_key_leaf_is_skipped", US + "x" + US + "k" + US + "v" + US + FS, {{"k", "v"}}},+ {"several_empty_key_leaves_are_not_duplicates",+ US + "x" + US + US + "y" + US + "k" + US + "v" + US + FS,+ {{"k", "v"}}},+ {"empty_key_leaf_in_nested_map",+ "M" + GS + US + "x" + US + "k" + US + "v" + US + GS + FS,+ {{"M", ov::AnyMap{{"k", "v"}}}}},+ {"reserved_block_with_empty_content", "k" + RS + RS + FS, {}},+ {"reserved_block_is_skipped",+ "a" + US + "1" + US + "r" + RS + reserved_content + RS + "b" + US + "2" + US + FS,+ {{"a", "1"}, {"b", "2"}}},+ {"reserved_block_in_nested_map",+ "M" + GS + "r" + RS + "zz" + RS + "k" + US + "v" + US + GS + FS,+ {{"M", ov::AnyMap{{"k", "v"}}}}},+ {"reserved_block_key_is_not_a_duplicate", "a" + US + "1" + US + "a" + RS + "zz" + RS + FS, {{"a", "1"}}},+ {"reserved_block_with_empty_key", RS + "zz" + RS + "k" + US + "v" + US + FS, {{"k", "v"}}},+ };+}+} // namespace++using HsmCompileOptionsDecodeAcceptTest = ::testing::TestWithParam<AcceptCase>;++TEST_P(HsmCompileOptionsDecodeAcceptTest, decode_accepts) {+ expect_decoded(with_digest(GetParam().body), GetParam().expected);+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsDecodeAcceptTest,+ ::testing::ValuesIn(accept_cases()),+ case_name<AcceptCase>);++namespace {+struct MalformedCase {+ std::string name;+ std::string bytes;+};++void PrintTo(const MalformedCase& malformed, std::ostream* os) {+ *os << malformed.name;+}++std::vector<MalformedCase> malformed_cases() {+ const auto empty_map_digest = digest_of(FS);+ auto wrong_digest = with_digest(single_string_case.entries);+ wrong_digest.back() ^= 1;++ std::vector<MalformedCase> cases{+ {"empty_section", ""},+ {"no_fs_and_no_digest", "k" + US + "v" + US},+ {"section_ends_in_key", "k"},+ {"section_ends_in_value", "k" + US + "v"},+ {"section_ends_in_reserved_block", "k" + RS + "zz"},+ {"digest_mismatch", wrong_digest},+ {"trailing_byte_after_digest", with_digest(single_string_case.entries) + '\0'},+ {"gs_at_top_level", with_digest(GS + FS)},+ {"gs_after_leaf_at_top_level", with_digest("k" + US + "v" + US + GS + FS)},+ {"fs_in_nested_map", with_digest("M" + GS + "k" + US + "v" + US + FS)},+ {"fs_in_key", with_digest("k" + FS)},+ {"fs_in_value", with_digest("k" + US + "v" + FS)},+ {"gs_in_value", with_digest("k" + US + "v" + GS + "v" + US + FS)},+ {"rs_in_value", with_digest("k" + US + "v" + RS + "v" + US + FS)},+ {"nul_in_key", with_digest("k"s + '\0' + US + "v" + US + FS)},+ {"nul_in_value", with_digest("k" + US + "v"s + '\0' + US + FS)},+ {"fs_in_reserved_block", with_digest("k" + RS + "zz" + FS)},+ {"duplicate_leaf", with_digest("k" + US + "1" + US + "k" + US + "2" + US + FS)},+ {"duplicate_nested_map", with_digest("M" + GS + GS + "M" + GS + GS + FS)},+ {"leaf_then_map_with_same_key", with_digest("M" + US + "1" + US + "M" + GS + GS + FS)},+ {"map_then_leaf_with_same_key", with_digest("M" + GS + GS + "M" + US + "1" + US + FS)},+ {"duplicate_leaf_in_nested_map", with_digest("M" + GS + "k" + US + "1" + US + "k" + US + "2" + US + GS + FS)},+ };+ for (size_t size = 1; size < empty_map_digest.size(); ++size) {+ cases.push_back({"digest_cut_to_" + std::to_string(size) + "_bytes", FS + empty_map_digest.substr(0, size)});+ }+ return cases;+}++std::vector<MalformedCase> malformed_multi_chunk_cases() {+ std::vector<MalformedCase> cases;+ for (const size_t offset : {chunk_size - 1, chunk_size, chunk_size + 1}) {+ const auto suffix = "_at_" + std::to_string(offset);+ const auto value_prefix = "k" + US + std::string(offset - 2, 'v');+ using pairs = std::initializer_list<std::pair<const char*, std::string>>;+ for (const auto& [name, illegal] : pairs{{"NUL", "\0"s}, {"GS", GS}, {"RS", RS}, {"FS", FS}}) {+ cases.push_back({"illegal_value_byte_"s + name + suffix, with_digest(value_prefix + illegal + US + FS)});+ }++ const auto pad_to_offset = [offset](const std::string& entry) {+ return entry + "r" + RS + std::string(offset - entry.size() - 3, 'x') + RS;+ };+ const auto leaf_prefix = pad_to_offset("k" + US + "1" + US);+ const auto map_prefix = pad_to_offset("k" + GS + GS);+ cases.push_back({"duplicate_leaf" + suffix, with_digest(leaf_prefix + "k" + US + "2" + US + FS)});+ cases.push_back({"duplicate_map" + suffix, with_digest(map_prefix + "k" + GS + GS + FS)});+ cases.push_back({"leaf_then_map" + suffix, with_digest(leaf_prefix + "k" + GS + GS + FS)});+ cases.push_back({"map_then_leaf" + suffix, with_digest(map_prefix + "k" + US + "2" + US + FS)});+ cases.push_back({"extra_top_level_gs" + suffix, with_digest(leaf_prefix + GS + FS)});+ cases.push_back(+ {"fs_in_nested_map" + suffix, with_digest("M" + GS + "k" + US + std::string(offset - 5, 'v') + US + FS)});++ cases.push_back({"truncated_key" + suffix, std::string(offset, 'k')});+ cases.push_back({"truncated_value" + suffix, value_prefix});+ cases.push_back({"truncated_reserved_block" + suffix, "r" + RS + std::string(offset - 2, 'x')});+ }+ return cases;+}+} // namespace++using HsmCompileOptionsDecodeMalformedTest = ::testing::TestWithParam<MalformedCase>;++TEST_P(HsmCompileOptionsDecodeMalformedTest, decode_rejects) {+ expect_rejected(GetParam().bytes);+}++INSTANTIATE_TEST_SUITE_P(HsmCompileOptions,+ HsmCompileOptionsDecodeMalformedTest,+ ::testing::ValuesIn(malformed_cases()),+ case_name<MalformedCase>);++INSTANTIATE_TEST_SUITE_P(HsmCompileOptionsMultiChunk,+ HsmCompileOptionsDecodeMalformedTest,+ ::testing::ValuesIn(malformed_multi_chunk_cases()),+ case_name<MalformedCase>);++TEST(HsmCompileOptionsDecodeTest, decoded_strings_convert_to_property_types) {+ const auto decoded = decode_buffer(typed_case.bytes());++ ASSERT_TRUE(decoded);+ EXPECT_EQ(decoded->at(ov::hint::performance_mode.name()).as<ov::hint::PerformanceMode>(),+ ov::hint::PerformanceMode::THROUGHPUT);+ EXPECT_EQ(decoded->at(ov::hint::inference_precision.name()).as<ov::element::Type>(), ov::element::f16);+ EXPECT_TRUE(decoded->at(ov::enable_profiling.name()).as<bool>());+ EXPECT_EQ(decoded->at(ov::hint::num_requests.name()).as<uint32_t>(), 4u);+}++TEST(HsmCompileOptionsDecodeTest, decoded_numbers_restore_exact_values) {+ const auto decoded = decode_buffer(numeric_case.bytes());++ ASSERT_TRUE(decoded);+ EXPECT_EQ(decoded->at("D").as<double>(), 0.1);+ EXPECT_EQ(decoded->at("F").as<float>(), 0.1f);+ EXPECT_EQ(decoded->at("I").as<int64_t>(), int64_t{-9000000000});+ EXPECT_EQ(decoded->at("N").as<uint32_t>(), 1234u);+}++TEST(HsmCompileOptionsDecodeTest, unreadable_section_is_rejected) {+ const auto bytes = single_string_case.bytes();+ std::stringstream stream{bytes.substr(0, bytes.size() - 1)};++ EXPECT_FALSE(hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 0}));+}++TEST(HsmCompileOptionsDecodeTest, stream_read_exception_returns_nullopt) {+ const auto bytes = single_string_case.bytes();+ std::stringstream stream{bytes.substr(0, bytes.size() - 1)};+ stream.exceptions(std::ios_base::failbit | std::ios_base::badbit);++ EXPECT_FALSE(hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 0}));+ EXPECT_TRUE(stream.fail());+ EXPECT_TRUE(stream.eof());+}++TEST(HsmCompileOptionsDecodeTest, stream_seek_exception_returns_nullopt) {+ const auto bytes = single_string_case.bytes();+ NonSeekableStringBuf buffer{bytes};+ std::istream stream{&buffer};+ stream.exceptions(std::ios_base::failbit | std::ios_base::badbit);++ EXPECT_FALSE(hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 0}));+ EXPECT_TRUE(stream.fail());+ EXPECT_FALSE(stream.eof());+}++// --- Decoding: sizes around the decoder's read chunk, no limits ---++TEST(HsmCompileOptionsDecodeTest, payload_ending_around_the_chunk_boundary_is_decoded) {+ for (size_t length = chunk_size - 26; length <= chunk_size + 14; ++length) {+ SCOPED_TRACE(length);+ const std::string value(length, 'x');+ expect_decoded(with_digest("k" + US + value + US + FS), {{"k", value}});+ }+}++TEST(HsmCompileOptionsDecodeTest, key_and_value_larger_than_a_chunk_are_decoded) {+ const std::string key(chunk_size + 100, 'k');+ const std::string value(25 * chunk_size, 'v');++ expect_decoded(with_digest(key + US + value + US + FS), {{key, value}});+}++TEST(HsmCompileOptionsDecodeTest, reserved_block_larger_than_a_chunk_is_skipped) {+ const std::string content(2 * chunk_size + 300, 'z');++ expect_decoded(with_digest("r" + RS + content + RS + "k" + US + "v" + US + FS), {{"k", "v"}});+}++TEST(HsmCompileOptionsDecodeTest, stream_truncated_after_first_chunk_is_rejected) {+ const auto bytes = with_digest("k" + US + std::string(chunk_size + 3, 'v') + US + FS);+ std::stringstream stream{bytes.substr(0, chunk_size)};++ EXPECT_FALSE(hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 0}));+ EXPECT_TRUE(stream.fail());+ EXPECT_TRUE(stream.eof());+ EXPECT_EQ(stream.gcount(), 0);+}++TEST(HsmCompileOptionsDecodeTest, stream_missing_digest_after_full_chunk_is_rejected) {+ const auto prefix = "k" + US;+ const auto suffix = US + FS;+ const auto entries = prefix + std::string(chunk_size - prefix.size() - suffix.size(), 'v') + suffix;+ ASSERT_EQ(entries.size(), chunk_size);+ const auto bytes = with_digest(entries);+ std::stringstream stream{entries};++ EXPECT_FALSE(hsm::decode_compile_options(hsm::Section{make_entry(bytes.size()), stream, 0}));+ EXPECT_TRUE(stream.fail());+ EXPECT_TRUE(stream.eof());+ EXPECT_EQ(stream.gcount(), 0);+}++// --- Round trip of generated options ---++TEST(HsmCompileOptionsRoundTripTest, integer_limits_are_preserved) {+ for (const auto value : {std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max()}) {+ SCOPED_TRACE(value);+ expect_value_roundtrip(value, std::to_string(value));+ }+ for (const auto value : {uint64_t{0}, std::numeric_limits<uint64_t>::max()}) {+ SCOPED_TRACE(value);+ expect_value_roundtrip(value, std::to_string(value));+ }+}++template <typename Value>+class HsmCompileOptionsFloatingPointTest : public ::testing::Test {};++using CompileOptionsFloatingPointTypes = ::testing::Types<float, double, long double>;+TYPED_TEST_SUITE(HsmCompileOptionsFloatingPointTest, CompileOptionsFloatingPointTypes);++TYPED_TEST(HsmCompileOptionsFloatingPointTest, finite_limits_roundtrip_exactly) {+ // min() can print slightly below the smallest normal value, causing stof/stold to report underflow on ARM64.+ // Test the next representable value above min() to avoid that libc conversion boundary.+ for (const auto value : {std::numeric_limits<TypeParam>::lowest(),+ std::numeric_limits<TypeParam>::max(),+ std::nextafter(std::numeric_limits<TypeParam>::min(), TypeParam{1}),+ std::nextafter(TypeParam{1}, TypeParam{2})}) {+ SCOPED_TRACE(value);+ expect_value_roundtrip(value);+ }+}++TYPED_TEST(HsmCompileOptionsFloatingPointTest, signed_zero_is_preserved) {+ expect_value_roundtrip(TypeParam{0});+ expect_value_roundtrip(-TypeParam{0});+}++TEST(HsmCompileOptionsRoundTripTest, vector_is_restored_from_a_string_leaf) {+ expect_value_roundtrip(std::vector<int>{-2, 0, 3}, "-2 0 3");+}++TEST(HsmCompileOptionsRoundTripTest, set_is_restored_from_a_string_leaf) {+ expect_value_roundtrip(std::set<std::string>{"a", "b"}, "a b");+}++TEST(HsmCompileOptionsRoundTripTest, printable_map_is_restored_from_a_string_leaf) {+ expect_value_roundtrip(std::map<std::string, int>{{"a", 1}, {"b", -2}}, "{a:1,b:-2}");+}++TEST(HsmCompileOptionsRoundTripTest, boolean_false_is_restored_from_no) {+ expect_value_roundtrip(false, "NO");+}++TEST(HsmCompileOptionsRoundTripTest, deeply_nested_options_are_restored) {+ // Far deeper than real options: exercises encoder recursion and the decoder's heap level stack.+ constexpr size_t depth = 100;+ ov::AnyMap options{{"level", "0"}};+ for (size_t level = 1; level <= depth; ++level) {+ options = ov::AnyMap{{"level", std::to_string(level)}, {"next", std::move(options)}};+ }++ expect_decoded(encode(options), options);+}++} // namespace ov::testdiff --git a/src/inference/tests/unit/hsm_deferred_writer.cpp b/src/inference/tests/unit/hsm_deferred_writer.cppindex e0c65898415..9b0bf983656 100644--- a/src/inference/tests/unit/hsm_deferred_writer.cpp+++ b/src/inference/tests/unit/hsm_deferred_writer.cpp@@ -1013,14 +1013,14 @@ TEST(HsmDeferredWriterTest, handler_based_add_section_reuses_one_handler_for_sev}TEST(HsmDeferredWriterTest, handler_forwards_to_a_named_member_function_instead_of_inlining_logic_in_the_lambda) {- struct CompiledOptions {+ struct CompileOptions {uint32_t version;float scale;};class OptionsHandler : public hsm::ISectionWriterHandler {public:- explicit OptionsHandler(CompiledOptions options) : m_options(options) {}+ explicit OptionsHandler(CompileOptions options) : m_options(options) {}void handle_section(hsm::IWriter& writer) const override {// ForwardingEncoder is only a one-line forwarder; write_options() below is an ordinary@@ -1047,12 +1047,12 @@ TEST(HsmDeferredWriterTest, handler_forwards_to_a_named_member_function_instead_sink(ov::util::as_memory_view(m_options));}- CompiledOptions m_options;+ CompileOptions m_options;};std::stringstream stream;auto writer = open_writer(stream);- OptionsHandler handler(CompiledOptions{7, 0.5f});+ OptionsHandler handler(CompileOptions{7, 0.5f});writer.add_sections({&handler});ASSERT_EQ(writer.finalize(), std::error_code{});@@ -1061,7 +1061,7 @@ TEST(HsmDeferredWriterTest, handler_forwards_to_a_named_member_function_instead_const auto tag = hsm::SectionTag::make_device_tag(10, false);const auto section = find_entry(*container, fake_device_id, tag.id());ASSERT_NE(section, nullptr);- CompiledOptions decoded{};+ CompileOptions decoded{};std::memcpy(&decoded, container->bytes.data() + section->offset, sizeof(decoded));EXPECT_EQ(decoded.version, 7u);EXPECT_FLOAT_EQ(decoded.scale, 0.5f);diff --git a/src/inference/tests/unit/hsm_format.cpp b/src/inference/tests/unit/hsm_format.cppindex 5b015d90c4f..564a3167870 100644--- a/src/inference/tests/unit/hsm_format.cpp+++ b/src/inference/tests/unit/hsm_format.cpp@@ -135,7 +135,7 @@ constexpr std::array<uint32_t, 5> k_core_tag_ids{hsm::model_id,hsm::model,hsm::runtime_requirements,hsm::weights,- hsm::compiled_options};+ hsm::compile_options};// Every assigned device id, pinned the same way as k_core_tag_ids.constexpr std::array<hsm::DeviceId, 5> k_device_ids{hsm::any_device_id,@@ -218,8 +218,8 @@ TEST_F(HsmFormatLayoutCompatibilityTest, core_tags_have_fixed_mode) {static_assert(hsm::weights_tag.id() == hsm::weights, "weights_tag id");static_assert(hsm::weights_tag.is_pointer(), "weights_tag must always be pointer-mode");- static_assert(hsm::compiled_options_tag.id() == hsm::compiled_options, "compiled_options_tag id");- static_assert(hsm::compiled_options_tag.is_pointer(), "compiled_options_tag must always be pointer-mode");+ static_assert(hsm::compile_options_tag.id() == hsm::compile_options, "compile_options_tag id");+ static_assert(hsm::compile_options_tag.is_pointer(), "compile_options_tag must always be pointer-mode");SUCCEED();}@@ -246,7 +246,7 @@ TEST_F(HsmFormatLayoutCompatibilityTest, core_tag_values_are_pinned) {static_assert(static_cast<uint32_t>(hsm::Tags::runtime_requirements) == 3,"Tags::runtime_requirements value changed");static_assert(static_cast<uint32_t>(hsm::Tags::weights) == 4, "Tags::weights value changed");- static_assert(static_cast<uint32_t>(hsm::Tags::compiled_options) == 5, "Tags::compiled_options value changed");+ static_assert(static_cast<uint32_t>(hsm::Tags::compile_options) == 5, "Tags::compile_options value changed");SUCCEED();}diff --git a/src/inference/tests/unit/hsm_reader.cpp b/src/inference/tests/unit/hsm_reader.cppindex 561aaf7b240..6ee57dedb31 100644--- a/src/inference/tests/unit/hsm_reader.cpp+++ b/src/inference/tests/unit/hsm_reader.cpp@@ -397,27 +397,27 @@ TEST(HsmReaderTest, device_overrides_core_tag_by_reusing_it_under_its_own_deviceconstexpr hsm::DeviceId other_device_id = fake_device_id + 1;const auto blob = make_container({- {make_pointer_entry(hsm::any_device_id, hsm::compiled_options_tag), "shared-options"},- {make_pointer_entry(fake_device_id, hsm::compiled_options_tag), "device-options"},+ {make_pointer_entry(hsm::any_device_id, hsm::compile_options_tag), "shared-options"},+ {make_pointer_entry(fake_device_id, hsm::compile_options_tag), "device-options"},});const auto reader = hsm::Reader::open(blob.data(), blob.size());ASSERT_TRUE(reader.has_value());// One tag id, two entries - they stay distinct because lookup is always by (device, tag), never tag alone.- const auto shared = reader->section(hsm::Tags::compiled_options);+ const auto shared = reader->section(hsm::Tags::compile_options);ASSERT_TRUE(shared.has_value());EXPECT_EQ(to_string(*shared), "shared-options");- const auto overridden = reader->section(fake_device_id, hsm::Tags::compiled_options);+ const auto overridden = reader->section(fake_device_id, hsm::Tags::compile_options);ASSERT_TRUE(overridden.has_value());EXPECT_EQ(to_string(*overridden), "device-options");- EXPECT_EQ(reader->count(hsm::Tags::compiled_options), 1U);- EXPECT_EQ(reader->count(fake_device_id, hsm::Tags::compiled_options), 1U);+ EXPECT_EQ(reader->count(hsm::Tags::compile_options), 1U);+ EXPECT_EQ(reader->count(fake_device_id, hsm::Tags::compile_options), 1U);// A device that published no override of its own finds nothing under its id because section(device, tag)// performs an exact (device, tag) lookup; callers that want shared content must explicitly query any_device_id.- EXPECT_FALSE(reader->section(other_device_id, hsm::Tags::compiled_options).has_value());+ EXPECT_FALSE(reader->section(other_device_id, hsm::Tags::compile_options).has_value());}TEST(HsmReaderTest, section_returns_only_the_first_of_several_matching_entries) {diff --git a/src/plugins/template/src/hsm_common.hpp b/src/plugins/template/src/hsm_common.hppindex 3521355cf23..83a301f8b94 100644--- a/src/plugins/template/src/hsm_common.hpp+++ b/src/plugins/template/src/hsm_common.hpp@@ -35,7 +35,7 @@ inline constexpr SectionId model_id{runtime::hsm::any_device_id, runtime::hsm::minline constexpr SectionId runtime_requirements{runtime::hsm::any_device_id, runtime::hsm::runtime_requirements_tag};inline constexpr SectionId model_struct{device_id, runtime::hsm::model_tag};inline constexpr SectionId weights{device_id, runtime::hsm::weights_tag};-inline constexpr SectionId compiled_options{device_id, runtime::hsm::compiled_options_tag};+inline constexpr SectionId compile_options{device_id, runtime::hsm::compile_options_tag};// TEMPLATE-specific: layout version and feature flags, no common equivalent.inline constexpr SectionId blob_info{device_id, runtime::hsm::SectionTag::make_device_tag(3, /*is_inline=*/true)};diff --git a/src/plugins/template/src/hsm_reader_handler.cpp b/src/plugins/template/src/hsm_reader_handler.cppindex 56604ff0af6..1fed2106449 100644--- a/src/plugins/template/src/hsm_reader_handler.cpp+++ b/src/plugins/template/src/hsm_reader_handler.cpp@@ -40,8 +40,8 @@ std::shared_ptr<ov::AlignedBuffer> decode_buffer(const HsmReaderHandler& handler}}-// Inverse of encode_compiled_options() in hsm_writer_handler.cpp - one `key=value` per line, split on the first '='.-ov::AnyMap decode_compiled_options(std::string_view encoded) {+// Inverse of encode_compile_options() in hsm_writer_handler.cpp - one `key=value` per line, split on the first '='.+ov::AnyMap decode_compile_options(std::string_view encoded) {ov::AnyMap options;while (!encoded.empty()) {const auto line_end = std::min(encoded.find('\n'), encoded.size());@@ -72,8 +72,8 @@ void set_weights(HsmReaderHandler& handler, const runtime::hsm::Section& sectionhandler.m_weights = section.size() == 0 ? nullptr : decode_buffer(handler, section);}-void set_compiled_options(HsmReaderHandler& handler, const runtime::hsm::Section& section) {- handler.m_compiled_options = decode_compiled_options(decode_string(section).value_or(""));+void set_compile_options(HsmReaderHandler& handler, const runtime::hsm::Section& section) {+ handler.m_compile_options = decode_compile_options(decode_string(section).value_or(""));}void set_blob_info(HsmReaderHandler& handler, const runtime::hsm::Section& section) {@@ -90,7 +90,7 @@ const std::map<uint32_t, HsmReaderHandler::Decoder> HsmReaderHandler::s_decoders{hsm::section_key(hsm::runtime_requirements), set_runtime_requirements},{hsm::section_key(hsm::model_struct), set_model},{hsm::section_key(hsm::weights), set_weights},- {hsm::section_key(hsm::compiled_options), set_compiled_options},+ {hsm::section_key(hsm::compile_options), set_compile_options},{hsm::section_key(hsm::blob_info), set_blob_info},};diff --git a/src/plugins/template/src/hsm_reader_handler.hpp b/src/plugins/template/src/hsm_reader_handler.hppindex 1df89c08c0d..9735d908511 100644--- a/src/plugins/template/src/hsm_reader_handler.hpp+++ b/src/plugins/template/src/hsm_reader_handler.hpp@@ -33,7 +33,7 @@ public:std::shared_ptr<ov::AlignedBuffer> m_model;std::shared_ptr<ov::AlignedBuffer> m_weights;std::optional<hsm::BlobInfo> m_blob_info;- ov::AnyMap m_compiled_options;+ ov::AnyMap m_compile_options;private:using Decoder = void (*)(HsmReaderHandler&, const runtime::hsm::Section&);diff --git a/src/plugins/template/src/hsm_writer_handler.cpp b/src/plugins/template/src/hsm_writer_handler.cppindex a7f1fcd68fb..480ce89a5ff 100644--- a/src/plugins/template/src/hsm_writer_handler.cpp+++ b/src/plugins/template/src/hsm_writer_handler.cpp@@ -135,15 +135,15 @@ private:// Cache-relevant options plus the weights path, which a weightless blob needs on import; restored through// Configuration.-ov::AnyMap get_compiled_options(const Configuration& cfg, ov::AnyMap cache_options) {+ov::AnyMap get_compile_options(const Configuration& cfg, ov::AnyMap cache_options) {if (!cfg.weights_path.empty()) {cache_options.emplace(ov::weights_path.name(), cfg.weights_path.string());}return cache_options;}-// One `key=value` per line; inverse of decode_compiled_options() in hsm_reader_handler.cpp.-std::string encode_compiled_options(const ov::AnyMap& options) {+// One `key=value` per line; inverse of decode_compile_options() in hsm_reader_handler.cpp.+std::string encode_compile_options(const ov::AnyMap& options) {std::string encoded;for (const auto& [key, value] : options) {encoded.append(key).append(1, '=').append(value.as<std::string>()).append(1, '\n');@@ -199,9 +199,9 @@ HsmWriterHandler::HsmWriterHandler(const std::shared_ptr<ov::Model>& model,hsm::section_key(hsm::runtime_requirements),Slot{hsm::runtime_requirements, std::make_shared<BytesEncoder>(std::string(runtime_requirements))});m_encoders.emplace(- hsm::section_key(hsm::compiled_options),- Slot{hsm::compiled_options,- std::make_shared<BytesEncoder>(encode_compiled_options(get_compiled_options(cfg, cache_options)))});+ hsm::section_key(hsm::compile_options),+ Slot{hsm::compile_options,+ std::make_shared<BytesEncoder>(encode_compile_options(get_compile_options(cfg, cache_options)))});const auto serializer = std::make_shared<ModelSerializer>(model);m_encoders.emplace(hsm::section_key(hsm::model_struct),diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cppindex 03c1ddb9f8b..900f9ba672f 100644--- a/src/plugins/template/src/plugin.cpp+++ b/src/plugins/template/src/plugin.cpp@@ -140,7 +140,7 @@ std::pair<std::shared_ptr<ov::Model>, Configuration> read_hsm_blob(*requirements);}- auto config = Configuration{properties, Configuration{handler.m_compiled_options, default_cfg, false}};+ auto config = Configuration{properties, Configuration{handler.m_compile_options, default_cfg, false}};const bool weightless = handler.m_blob_info->flags & ov::template_plugin::hsm::BlobInfo::weightless;auto weights = handler.m_weights;diff --git a/src/plugins/template/tests/functional/hsm_blob_test.cpp b/src/plugins/template/tests/functional/hsm_blob_test.cppindex 5b3aeadab09..92ef42298ec 100644--- a/src/plugins/template/tests/functional/hsm_blob_test.cpp+++ b/src/plugins/template/tests/functional/hsm_blob_test.cpp@@ -400,7 +400,7 @@ TEST_F(TemplateHsmBlobTest, generated_blob_is_imported_from_file_via_tensor) {utils::compare(reference, infer(imported));}-TEST_F(TemplateHsmBlobTest, import_restores_compiled_options) {+TEST_F(TemplateHsmBlobTest, import_restores_compile_options) {std::stringstream stream(export_hsm({ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)}));auto imported = core.import_model(stream, device);@@ -409,12 +409,12 @@ TEST_F(TemplateHsmBlobTest, import_restores_compiled_options) {utils::compare(reference, infer(imported));}-TEST_F(TemplateHsmBlobTest, compiled_options_hold_the_cache_relevant_properties) {+TEST_F(TemplateHsmBlobTest, compile_options_hold_the_cache_relevant_properties) {// A non-default value, so a persisted option can be told apart from the plugin default.std::stringstream stream(export_hsm({ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)}));const auto reader = hsm::Reader::open(stream);ASSERT_TRUE(reader);- const auto section = reader->section(template_device_id, hsm::compiled_options);+ const auto section = reader->section(template_device_id, hsm::compile_options);ASSERT_TRUE(section);const auto bytes = section->to_bytes();ASSERT_TRUE(bytes);@@ -454,7 +454,7 @@ TEST_F(TemplateHsmBlobTest, exported_blob_has_all_sections) {EXPECT_EQ(reader->count(hsm::any_device_id, hsm::runtime_requirements), 1u);EXPECT_EQ(reader->count(template_device_id, hsm::model), 1u);EXPECT_EQ(reader->count(template_device_id, hsm::weights), 1u);- EXPECT_EQ(reader->count(template_device_id, hsm::compiled_options), 1u);+ EXPECT_EQ(reader->count(template_device_id, hsm::compile_options), 1u);EXPECT_EQ(reader->count(template_device_id, blob_info_tag.id()), 1u);}@@ -490,7 +490,7 @@ TEST_F(TemplateHsmBlobTest, weightless_blob_is_imported_with_weights_path_hint)utils::compare(reference, infer(imported));}-TEST_F(TemplateHsmBlobTest, weightless_blob_restores_weights_path_from_compiled_options) {+TEST_F(TemplateHsmBlobTest, weightless_blob_restores_weights_path_from_compile_options) {const auto weights_path = save_weights(export_hsm());std::stringstream stream(export_hsm({ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE), ov::weights_path(weights_path)}));