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: Assure noexcept respectancy of model_id decoder (#39310)
Tomasz Jankowski5f9bf60be6d7
diff --git a/src/inference/dev_api/openvino/runtime/hsm_model_id_codec.hpp b/src/inference/dev_api/openvino/runtime/hsm_model_id_codec.hppindex 1fd4d0843d9..e64b740f80f 100644--- a/src/inference/dev_api/openvino/runtime/hsm_model_id_codec.hpp+++ b/src/inference/dev_api/openvino/runtime/hsm_model_id_codec.hpp@@ -26,7 +26,7 @@ inline namespace v1 {* @brief Reads the model id from a #model_id_tag section.* @note Layout: bytes [0, 8) hold the id as a native-byte-order `uint64_t`; the rest of the inline slot is* ignored.- * @param section Section to decode; its tag must be #model_id_tag (debug-asserted).+ * @param section Section to decode; its tag must be #model_id_tag.* @return `std::nullopt` if the read fails.*/OPENVINO_RUNTIME_API std::optional<uint64_t> decode_model_id(const Section& section) noexcept;diff --git a/src/inference/src/dev/hsm_model_id_codec.cpp b/src/inference/src/dev/hsm_model_id_codec.cppindex 75f908c9c69..54839b992c8 100644--- a/src/inference/src/dev/hsm_model_id_codec.cpp+++ b/src/inference/src/dev/hsm_model_id_codec.cpp@@ -12,9 +12,12 @@ namespace ov::runtime::hsm {inline namespace v1 {std::optional<uint64_t> decode_model_id(const Section& section) noexcept {- OPENVINO_DEBUG_ASSERT(section.tag().value == model_id_tag.value);uint64_t id{};- return section.read(0, sizeof(id), &id) ? std::optional{id} : std::nullopt;+ try {+ return section.read(0, sizeof(id), &id) ? std::optional{id} : std::nullopt;+ } catch (...) {+ return std::nullopt;+ }}} // namespace v1