benchmark_app: reuse shapes string representation (#13783)
This commit is contained in:
1 parent
779aac9de8
commit
8d5df45d9f
5 files changed
+8
-49
No files matched your search
@@ -366,7 +366,7 @@ ov::Tensor get_random_tensor(const std::pair<std::string, benchmark_app::InputIn
|
||||
std::string get_test_info_stream_header(benchmark_app::InputInfo& inputInfo) {
|
||||
std::stringstream strOut;
|
||||
strOut << "(" << inputInfo.layout.to_string() << ", " << inputInfo.type.get_type_name() << ", "
|
||||
<< get_shape_string(inputInfo.dataShape) << ", ";
|
||||
<< inputInfo.dataShape << ", ";
|
||||
if (inputInfo.partialShape.is_dynamic()) {
|
||||
strOut << std::string("dyn:") << inputInfo.partialShape << "):\t";
|
||||
} else {
|
||||
|
||||
@@ -1179,7 +1179,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
std::string data_shapes_string = "";
|
||||
for (auto& item : app_inputs_info[i]) {
|
||||
data_shapes_string += item.first + get_shape_string(item.second.dataShape) + ",";
|
||||
data_shapes_string += item.first + item.second.dataShape.to_string() + ",";
|
||||
}
|
||||
data_shapes_string =
|
||||
data_shapes_string == "" ? "" : data_shapes_string.substr(0, data_shapes_string.size() - 1);
|
||||
@@ -1289,7 +1289,7 @@ int main(int argc, char* argv[]) {
|
||||
auto shape = item.second.dataShape;
|
||||
std::copy(shape.begin(), shape.end() - 1, std::ostream_iterator<size_t>(input_shape, ","));
|
||||
input_shape << shape.back();
|
||||
slog::info << " " << item.first << ": " << get_shape_string(item.second.dataShape);
|
||||
slog::info << " " << item.first << " : " << item.second.dataShape;
|
||||
}
|
||||
slog::info << slog::endl;
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -59,14 +59,11 @@ uint32_t device_default_device_duration_in_seconds(const std::string& device);
|
||||
std::map<std::string, std::string> parse_value_per_device(const std::vector<std::string>& devices,
|
||||
const std::string& values_string);
|
||||
void parse_value_for_virtual_device(const std::string& device, std::map<std::string, std::string>& values_string);
|
||||
std::string get_shape_string(const ov::Shape& shape);
|
||||
std::string get_shapes_string(const benchmark_app::PartialShapes& shapes);
|
||||
size_t get_batch_size(const benchmark_app::InputsInfo& inputs_info);
|
||||
std::vector<std::string> split(const std::string& s, char delim);
|
||||
std::map<std::string, std::vector<float>> parse_scale_or_mean(const std::string& scale_mean,
|
||||
const benchmark_app::InputsInfo& inputs_info);
|
||||
std::vector<ngraph::Dimension> parse_partial_shape(const std::string& partial_shape);
|
||||
ov::Shape parse_data_shape(const std::string& dataShapeStr);
|
||||
std::pair<std::string, std::vector<std::string>> parse_input_files(const std::string& file_paths_string);
|
||||
std::map<std::string, std::vector<std::string>> parse_input_arguments(const std::vector<std::string>& args);
|
||||
|
||||
|
||||
Reference in new issue
Block a user