Skip to content

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

[COMMON] Reduce number of exceptions in Debug mode. (#30990)

Nikolay Shchegoleve6bddb1066c1
diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp
index 112d1a54819..0caec2d93fc 100644
--- a/samples/cpp/benchmark_app/main.cpp
+++ b/samples/cpp/benchmark_app/main.cpp
@@ -766,9 +766,13 @@ int main(int argc, char* argv[]) {
// Some tensors might have no names, get_any_name will throw exception in that case.
// -iop option will not work for those tensors.
name = item.get_any_name();
- iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name()));
} catch (...) {
}
+ const auto& prc = user_precisions_map.find(name);
+ if (prc != user_precisions_map.end()) {
+ iop_precision = getPrecision2(prc->second);
+ }
+
if (iop_precision != ov::element::dynamic) {
type_to_set = iop_precision;
} else if (input_precision != ov::element::dynamic) {
@@ -800,12 +804,18 @@ int main(int argc, char* argv[]) {
for (size_t i = 0; i < outs.size(); i++) {
const auto& item = outs[i];
auto iop_precision = ov::element::dynamic;
+ std::string name;
try {
// Some tensors might have no names, get_any_name will throw exception in that case.
// -iop option will not work for those tensors.
- iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name()));
+ name = item.get_any_name();
} catch (...) {
}
+ const auto& prc = user_precisions_map.find(name);
+ if (prc != user_precisions_map.end()) {
+ iop_precision = getPrecision2(prc->second);
+ }
+
if (iop_precision != ov::element::dynamic) {
preproc.output(i).tensor().set_element_type(iop_precision);
} else if (output_precision != ov::element::dynamic) {
diff --git a/src/core/src/pass/manager.cpp b/src/core/src/pass/manager.cpp
index c39a7b43c6c..b78fd314d0a 100644
--- a/src/core/src/pass/manager.cpp
+++ b/src/core/src/pass/manager.cpp
@@ -294,9 +294,9 @@ private:
static std::string gen_file_name(const std::string& model_name, const std::string& pass_name, const size_t idx) {
std::stringstream name;
// visualizations and serializations will be named after the outermost function
- const size_t num_digits_in_pass_index = 3;
std::string index_str = std::to_string(idx);
- index_str = std::string(num_digits_in_pass_index - index_str.length(), '0') + index_str;
+ const size_t num_digits_in_pass_index = index_str.length() > 2LU ? 0LU : (3LU - index_str.length());
+ index_str = std::string(num_digits_in_pass_index, '0') + index_str;
name << model_name << std::string("_") << index_str << std::string("_") << pass_name;
return name.str();