diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index b78ad486d9f..6b85e125f86 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -472,39 +472,58 @@ int main(int argc, char* argv[]) { const auto input_precision = FLAGS_ip.empty() ? ov::element::undefined : getPrecision2(FLAGS_ip); const auto output_precision = FLAGS_op.empty() ? ov::element::undefined : getPrecision2(FLAGS_op); - for (auto& item : model->inputs()) { - // if precision for input set by user, then set it to app_inputs - const auto& name = item.get_any_name(); - if (user_precisions_map.count(name)) { - const auto precision = getPrecision2(user_precisions_map.at(name)); - for (auto& info : app_inputs_info) { - info.at(name).type = precision; - } - } else if (input_precision != ov::element::undefined) { - for (auto& info : app_inputs_info) { - info.at(name).type = input_precision; - } - } else if (app_inputs_info[0].at(name).isImage()) { - // image input, set U8 - for (auto& info : app_inputs_info) { - info.at(name).type = ov::element::u8; - } + const auto& inputs = model->inputs(); + for (int i = 0; i < inputs.size(); i++) { + const auto& item = inputs[i]; + auto iop_precision = ov::element::undefined; + auto type_to_set = ov::element::undefined; + 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. + name = item.get_any_name(); + iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name())); + } catch (...) { } - auto& in = preproc.input(name); - in.tensor().set_element_type(app_inputs_info[0].at(name).type); - // Explicitly set inputs layout. - in.model().set_layout(app_inputs_info[0].at(name).layout); + if (iop_precision != ov::element::undefined) { + type_to_set = iop_precision; + } else if (input_precision != ov::element::undefined) { + type_to_set = input_precision; + } else if (!name.empty() && app_inputs_info[0].at(name).isImage()) { + // image input, set U8 + type_to_set = ov::element::u8; + } + + auto& in = preproc.input(item.get_index()); + if (type_to_set != ov::element::undefined) { + in.tensor().set_element_type(type_to_set); + + if (!name.empty()) { + for (auto& info : app_inputs_info) { + info.at(name).type = type_to_set; + } + } + // Explicitly set inputs layout. + in.model().set_layout(app_inputs_info[0].at(name).layout); + } } - for (auto& item : model->outputs()) { - // if precision for input set by user, then set it to app_inputs - const auto& name = item.get_any_name(); - if (user_precisions_map.count(name)) { - const auto precision = getPrecision2(user_precisions_map.at(name)); - preproc.output(name).tensor().set_element_type(precision); + const auto& outs = model->outputs(); + for (int i = 0; i < outs.size(); i++) { + const auto& item = outs[i]; + auto iop_precision = ov::element::undefined; + 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())); + } catch (...) { + } + + if (iop_precision != ov::element::undefined) { + preproc.output(i).tensor().set_element_type(iop_precision); } else if (output_precision != ov::element::undefined) { - preproc.output(name).tensor().set_element_type(output_precision); + preproc.output(i).tensor().set_element_type(output_precision); } } diff --git a/samples/cpp/benchmark_app/utils.cpp b/samples/cpp/benchmark_app/utils.cpp index 0757bd8c9e5..6f8022bac52 100644 --- a/samples/cpp/benchmark_app/utils.cpp +++ b/samples/cpp/benchmark_app/utils.cpp @@ -477,7 +477,7 @@ std::vector getInputsInfo(const std::string& shape_st } if (info_maps.empty()) { // Show warnings only for 1st test case config, as for other test cases // they will be the same - slog::warn << item.get_node()->get_friendly_name() << ": layout is not set explicitly" + slog::warn << item.get_any_name() << ": layout is not set explicitly" << (newLayout != "" ? std::string(", so it is defaulted to ") + newLayout : "") << ". It is STRONGLY recommended to set layout manually to avoid further issues." << slog::endl; @@ -563,8 +563,7 @@ std::vector getInputsInfo(const std::string& shape_st })) { throw std::logic_error("Not enough information in shape and image to determine tensor shape " "automatically autmatically. Input: " + - item.get_node()->get_friendly_name() + - ", File name: " + namesVector[fileIdx - 1]); + item.get_any_name() + ", File name: " + namesVector[fileIdx - 1]); } } else if (info.partialShape.is_static()) { @@ -595,7 +594,7 @@ std::vector getInputsInfo(const std::string& shape_st reshape_required = true; } } else { - slog::warn << "Input '" << item.get_node()->get_friendly_name() + slog::warn << "Input '" << item.get_any_name() << "' doesn't have batch dimension in layout. -b option will be ignored for this input." << slog::endl; } diff --git a/samples/cpp/common/utils/src/args_helper.cpp b/samples/cpp/common/utils/src/args_helper.cpp index 02a2dc979e2..f330ad953a0 100644 --- a/samples/cpp/common/utils/src/args_helper.cpp +++ b/samples/cpp/common/utils/src/args_helper.cpp @@ -250,15 +250,15 @@ bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) { void printInputAndOutputsInfoShort(const ov::Model& network) { std::cout << "Network inputs:" << std::endl; - for (auto&& param : network.get_parameters()) { - auto l = param->get_layout(); - std::cout << " " << param->get_friendly_name() << " : " << param->get_element_type() << " / " - << param->get_layout().to_string() << std::endl; + for (auto&& input : network.inputs()) { + std::cout << " " << input.get_any_name() << " : " << input.get_element_type() << " / " + << ov::layout::get_layout(input).to_string() << std::endl; } + std::cout << "Network outputs:" << std::endl; - for (auto&& result : network.get_results()) { - std::cout << " " << result->get_friendly_name() << " : " << result->get_element_type() << " / " - << result->get_layout().to_string() << std::endl; + for (auto&& output : network.outputs()) { + std::cout << " " << output.get_any_name() << " : " << output.get_element_type() << " / " + << ov::layout::get_layout(output).to_string() << std::endl; } }