benchmark_app: reuse shapes string representation (#13783)

This commit is contained in:
Zlobin Vladimir
2022-11-23 13:19:26 +04:00
committed by GitHub
parent 779aac9de8
commit 8d5df45d9f
5 changed files with 8 additions and 49 deletions

View File

@@ -209,12 +209,6 @@ size_t get_batch_size(const benchmark_app::InputsInfo& inputs_info) {
return batch_size;
}
std::string get_shape_string(const ov::Shape& shape) {
std::stringstream ss;
ss << shape;
return ss.str();
}
std::string get_shapes_string(const benchmark_app::PartialShapes& shapes) {
std::stringstream ss;
for (auto& shape : shapes) {
@@ -264,36 +258,6 @@ std::map<std::string, std::vector<float>> parse_scale_or_mean(const std::string&
return return_value;
}
std::vector<ngraph::Dimension> parse_partial_shape(const std::string& partial_shape) {
std::vector<ngraph::Dimension> shape;
for (auto& dim : split(partial_shape, ',')) {
if (dim == "?" || dim == "-1") {
shape.push_back(ngraph::Dimension::dynamic());
} else {
const std::string range_divider = "..";
size_t range_index = dim.find(range_divider);
if (range_index != std::string::npos) {
std::string min = dim.substr(0, range_index);
std::string max = dim.substr(range_index + range_divider.length());
shape.push_back(ngraph::Dimension(min.empty() ? 0 : std::stoi(min),
max.empty() ? ngraph::Interval::s_max : std::stoi(max)));
} else {
shape.push_back(std::stoi(dim));
}
}
}
return shape;
}
ov::Shape parse_data_shape(const std::string& dataShapeStr) {
std::vector<size_t> shape;
for (auto& dim : split(dataShapeStr, ',')) {
shape.push_back(std::stoi(dim));
}
return shape;
}
std::pair<std::string, std::vector<std::string>> parse_input_files(const std::string& file_paths_string) {
auto search_string = file_paths_string;
std::string input_name = "";
@@ -486,7 +450,7 @@ std::vector<benchmark_app::InputsInfo> get_inputs_info(const std::string& shape_
}
std::vector<benchmark_app::InputsInfo> info_maps;
for (size_t i = 0; i < min_size; ++i) {
for (size_t input_id = 0; input_id < min_size; ++input_id) {
benchmark_app::InputsInfo info_map;
bool is_there_at_least_one_batch_dim = false;
@@ -501,7 +465,6 @@ std::vector<benchmark_app::InputsInfo> get_inputs_info(const std::string& shape_
"layout command line parameter doesn't support multiple layouts for one input.");
}
info.layout = ov::Layout(layout_map.at(name)[0]);
// reshape_required = true;
} else {
info.layout = dynamic_cast<const ov::op::v0::Parameter&>(*item.get_node()).get_layout();
}
@@ -544,7 +507,7 @@ std::vector<benchmark_app::InputsInfo> get_inputs_info(const std::string& shape_
throw std::logic_error(
"shape command line parameter doesn't support multiple shapes for one input.");
}
info.partialShape = parse_partial_shape(shape_map.at(name)[0]);
info.partialShape = shape_map.at(name)[0];
reshape_required = true;
} else {
info.partialShape = item.get_partial_shape();
@@ -557,7 +520,7 @@ std::vector<benchmark_app::InputsInfo> get_inputs_info(const std::string& shape_
// Tensor Shape
if (info.partialShape.is_dynamic() && data_shapes_map.count(name)) {
info.dataShape = parse_data_shape(data_shapes_map.at(name)[i % data_shapes_map.at(name).size()]);
info.dataShape = data_shapes_map.at(name)[input_id % data_shapes_map.at(name).size()];
} else if (info.partialShape.is_dynamic() && fileNames.count(filesInputName) && info.is_image()) {
auto& namesVector = fileNames.at(filesInputName);
if (contains_binaries(namesVector)) {