Benchmarkapp: Added processing of inputs/outputs by index (#9703)
* Added processing of inputs/outputs by index * fix * All tensor's get_friendly_name are replaced with get_any_name * stylefix
This commit is contained in:
parent
96e7ee58e1
commit
14f8614da6
@ -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 input_precision = FLAGS_ip.empty() ? ov::element::undefined : getPrecision2(FLAGS_ip);
|
||||||
const auto output_precision = FLAGS_op.empty() ? ov::element::undefined : getPrecision2(FLAGS_op);
|
const auto output_precision = FLAGS_op.empty() ? ov::element::undefined : getPrecision2(FLAGS_op);
|
||||||
|
|
||||||
for (auto& item : model->inputs()) {
|
const auto& inputs = model->inputs();
|
||||||
// if precision for input set by user, then set it to app_inputs
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
const auto& name = item.get_any_name();
|
const auto& item = inputs[i];
|
||||||
if (user_precisions_map.count(name)) {
|
auto iop_precision = ov::element::undefined;
|
||||||
const auto precision = getPrecision2(user_precisions_map.at(name));
|
auto type_to_set = ov::element::undefined;
|
||||||
for (auto& info : app_inputs_info) {
|
std::string name;
|
||||||
info.at(name).type = precision;
|
try {
|
||||||
}
|
// Some tensors might have no names, get_any_name will throw exception in that case.
|
||||||
} else if (input_precision != ov::element::undefined) {
|
// -iop option will not work for those tensors.
|
||||||
for (auto& info : app_inputs_info) {
|
name = item.get_any_name();
|
||||||
info.at(name).type = input_precision;
|
iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name()));
|
||||||
}
|
} catch (...) {
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
auto& in = preproc.input(name);
|
|
||||||
in.tensor().set_element_type(app_inputs_info[0].at(name).type);
|
|
||||||
|
|
||||||
// Explicitly set inputs layout.
|
if (iop_precision != ov::element::undefined) {
|
||||||
in.model().set_layout(app_inputs_info[0].at(name).layout);
|
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()) {
|
const auto& outs = model->outputs();
|
||||||
// if precision for input set by user, then set it to app_inputs
|
for (int i = 0; i < outs.size(); i++) {
|
||||||
const auto& name = item.get_any_name();
|
const auto& item = outs[i];
|
||||||
if (user_precisions_map.count(name)) {
|
auto iop_precision = ov::element::undefined;
|
||||||
const auto precision = getPrecision2(user_precisions_map.at(name));
|
try {
|
||||||
preproc.output(name).tensor().set_element_type(precision);
|
// 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) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ std::vector<benchmark_app::InputsInfo> getInputsInfo(const std::string& shape_st
|
|||||||
}
|
}
|
||||||
if (info_maps.empty()) { // Show warnings only for 1st test case config, as for other test cases
|
if (info_maps.empty()) { // Show warnings only for 1st test case config, as for other test cases
|
||||||
// they will be the same
|
// 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 : "")
|
<< (newLayout != "" ? std::string(", so it is defaulted to ") + newLayout : "")
|
||||||
<< ". It is STRONGLY recommended to set layout manually to avoid further issues."
|
<< ". It is STRONGLY recommended to set layout manually to avoid further issues."
|
||||||
<< slog::endl;
|
<< slog::endl;
|
||||||
@ -563,8 +563,7 @@ std::vector<benchmark_app::InputsInfo> getInputsInfo(const std::string& shape_st
|
|||||||
})) {
|
})) {
|
||||||
throw std::logic_error("Not enough information in shape and image to determine tensor shape "
|
throw std::logic_error("Not enough information in shape and image to determine tensor shape "
|
||||||
"automatically autmatically. Input: " +
|
"automatically autmatically. Input: " +
|
||||||
item.get_node()->get_friendly_name() +
|
item.get_any_name() + ", File name: " + namesVector[fileIdx - 1]);
|
||||||
", File name: " + namesVector[fileIdx - 1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (info.partialShape.is_static()) {
|
} else if (info.partialShape.is_static()) {
|
||||||
@ -595,7 +594,7 @@ std::vector<benchmark_app::InputsInfo> getInputsInfo(const std::string& shape_st
|
|||||||
reshape_required = true;
|
reshape_required = true;
|
||||||
}
|
}
|
||||||
} else {
|
} 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."
|
<< "' doesn't have batch dimension in layout. -b option will be ignored for this input."
|
||||||
<< slog::endl;
|
<< slog::endl;
|
||||||
}
|
}
|
||||||
|
@ -250,15 +250,15 @@ bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) {
|
|||||||
|
|
||||||
void printInputAndOutputsInfoShort(const ov::Model& network) {
|
void printInputAndOutputsInfoShort(const ov::Model& network) {
|
||||||
std::cout << "Network inputs:" << std::endl;
|
std::cout << "Network inputs:" << std::endl;
|
||||||
for (auto&& param : network.get_parameters()) {
|
for (auto&& input : network.inputs()) {
|
||||||
auto l = param->get_layout();
|
std::cout << " " << input.get_any_name() << " : " << input.get_element_type() << " / "
|
||||||
std::cout << " " << param->get_friendly_name() << " : " << param->get_element_type() << " / "
|
<< ov::layout::get_layout(input).to_string() << std::endl;
|
||||||
<< param->get_layout().to_string() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Network outputs:" << std::endl;
|
std::cout << "Network outputs:" << std::endl;
|
||||||
for (auto&& result : network.get_results()) {
|
for (auto&& output : network.outputs()) {
|
||||||
std::cout << " " << result->get_friendly_name() << " : " << result->get_element_type() << " / "
|
std::cout << " " << output.get_any_name() << " : " << output.get_element_type() << " / "
|
||||||
<< result->get_layout().to_string() << std::endl;
|
<< ov::layout::get_layout(output).to_string() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user