Benchmark_app: Command line args processing is modified to use both tensor and corresponding node names (#9968)
* Node/name conversions * stylefix
This commit is contained in:
parent
6845392aa6
commit
c848e55f5e
@ -397,6 +397,8 @@ int main(int argc, char* argv[]) {
|
||||
if (statistics)
|
||||
statistics->add_parameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"load network time (ms)", duration_ms}});
|
||||
|
||||
convert_io_names_in_map(inputFiles, compiledModel.inputs());
|
||||
app_inputs_info = get_inputs_info(FLAGS_shape,
|
||||
FLAGS_layout,
|
||||
batchSize,
|
||||
@ -432,6 +434,7 @@ int main(int argc, char* argv[]) {
|
||||
// ----------------- 5. Resizing network to match image sizes and given
|
||||
// batch ----------------------------------
|
||||
next_step();
|
||||
convert_io_names_in_map(inputFiles, std::const_pointer_cast<const ov::Model>(model)->inputs());
|
||||
// Parse input shapes if specified
|
||||
bool reshape = false;
|
||||
app_inputs_info = get_inputs_info(FLAGS_shape,
|
||||
@ -465,6 +468,9 @@ int main(int argc, char* argv[]) {
|
||||
std::map<std::string, std::string> user_precisions_map;
|
||||
if (!FLAGS_iop.empty()) {
|
||||
user_precisions_map = parseArgMap(FLAGS_iop);
|
||||
convert_io_names_in_map(user_precisions_map,
|
||||
std::const_pointer_cast<const ov::Model>(model)->inputs(),
|
||||
std::const_pointer_cast<const ov::Model>(model)->outputs());
|
||||
}
|
||||
|
||||
const auto input_precision = FLAGS_ip.empty() ? ov::element::undefined : getPrecision2(FLAGS_ip);
|
||||
@ -583,6 +589,7 @@ int main(int argc, char* argv[]) {
|
||||
statistics->add_parameters(StatisticsReport::Category::EXECUTION_RESULTS,
|
||||
{{"import network time (ms)", duration_ms}});
|
||||
|
||||
convert_io_names_in_map(inputFiles, compiledModel.inputs());
|
||||
app_inputs_info = get_inputs_info(FLAGS_shape,
|
||||
FLAGS_layout,
|
||||
FLAGS_b,
|
||||
|
@ -353,7 +353,7 @@ std::map<std::string, std::vector<std::string>> parse_input_parameters(
|
||||
input_name = search_string.substr(0, start_pos);
|
||||
auto input_value = search_string.substr(start_pos + 1, end_pos - start_pos - 1);
|
||||
if (!input_name.empty()) {
|
||||
return_value[input_name].push_back(input_value);
|
||||
return_value[parameter_name_to_tensor_name(input_name, input_info)].push_back(input_value);
|
||||
} else {
|
||||
for (auto& item : input_info) {
|
||||
return_value[item.get_any_name()].push_back(input_value);
|
||||
@ -797,3 +797,38 @@ std::vector<std::string> filter_files_by_extensions(const std::vector<std::strin
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
std::string parameter_name_to_tensor_name(const std::string& name,
|
||||
const std::vector<ov::Output<const ov::Node>>& inputs_info,
|
||||
const std::vector<ov::Output<const ov::Node>>& outputs_info) {
|
||||
if (std::any_of(inputs_info.begin(), inputs_info.end(), [name](const ov::Output<const ov::Node>& port) {
|
||||
try {
|
||||
return name == port.get_any_name();
|
||||
} catch (const ov::Exception&) {
|
||||
return false; // Some ports might have no names - so this is workaround
|
||||
}
|
||||
})) {
|
||||
return name;
|
||||
} else if (std::any_of(outputs_info.begin(), outputs_info.end(), [name](const ov::Output<const ov::Node>& port) {
|
||||
try {
|
||||
return name == port.get_any_name();
|
||||
} catch (const ov::Exception&) {
|
||||
return false; // Some ports might have no names - so this is workaround
|
||||
}
|
||||
})) {
|
||||
return name;
|
||||
} else {
|
||||
for (const auto& port : inputs_info) {
|
||||
if (name == port.get_node()->get_friendly_name()) {
|
||||
return port.get_any_name();
|
||||
}
|
||||
}
|
||||
for (const auto& port : outputs_info) {
|
||||
if (name == port.get_node()->get_input_node_ptr(0)->get_friendly_name()) {
|
||||
return port.get_any_name();
|
||||
}
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Provided I/O name \"" + name +
|
||||
"\" is not found neither in tensor names nor in nodes names.");
|
||||
}
|
@ -133,3 +133,21 @@ bool is_image_file(const std::string& filePath);
|
||||
bool contains_binaries(const std::vector<std::string>& filePaths);
|
||||
std::vector<std::string> filter_files_by_extensions(const std::vector<std::string>& filePaths,
|
||||
const std::vector<std::string>& extensions);
|
||||
|
||||
std::string parameter_name_to_tensor_name(
|
||||
const std::string& name,
|
||||
const std::vector<ov::Output<const ov::Node>>& inputs_info,
|
||||
const std::vector<ov::Output<const ov::Node>>& outputs_info = std::vector<ov::Output<const ov::Node>>());
|
||||
|
||||
template <class T>
|
||||
void convert_io_names_in_map(
|
||||
T& map,
|
||||
const std::vector<ov::Output<const ov::Node>>& inputs_info,
|
||||
const std::vector<ov::Output<const ov::Node>>& outputs_info = std::vector<ov::Output<const ov::Node>>()) {
|
||||
T new_map;
|
||||
for (auto& item : map) {
|
||||
new_map[item.first == "" ? "" : parameter_name_to_tensor_name(item.first, inputs_info, outputs_info)] =
|
||||
std::move(item.second);
|
||||
}
|
||||
map = new_map;
|
||||
}
|
@ -251,13 +251,27 @@ bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) {
|
||||
void printInputAndOutputsInfoShort(const ov::Model& network) {
|
||||
std::cout << "Network inputs:" << 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 << " " << input.get_any_name() << " (node: " << input.get_node()->get_friendly_name()
|
||||
<< ") : " << input.get_element_type() << " / " << ov::layout::get_layout(input).to_string()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Network outputs:" << std::endl;
|
||||
for (auto&& output : network.outputs()) {
|
||||
std::cout << " " << output.get_any_name() << " : " << output.get_element_type() << " / "
|
||||
std::string out_name = "***NO_NAME***";
|
||||
std::string node_name = "***NO_NAME***";
|
||||
|
||||
// Workaround for "tensor has no name" issue
|
||||
try {
|
||||
out_name = output.get_any_name();
|
||||
} catch (const ov::Exception&) {
|
||||
}
|
||||
try {
|
||||
node_name = output.get_node()->get_input_node_ptr(0)->get_friendly_name();
|
||||
} catch (const ov::Exception&) {
|
||||
}
|
||||
|
||||
std::cout << " " << out_name << " (node: " << node_name << ") : " << output.get_element_type() << " / "
|
||||
<< ov::layout::get_layout(output).to_string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user