Fix -api sync for single -data_shape (#18463)

* Fix -api sync for single -data_shape

Tickets 111187 and 111185

I wasn’t able to find C++ equivalent of Python’s `info.original_shape.is_static`. Later I realized that it shouldn’t be considered because -shape cmd arg should have higher priority for shape inference than model’s shape. So I removed it from Python.

Replace

`if benchmark.inference_only and batch_size.is_dynamic:`

with

`if allow_inference_only_or_sync and batch_size.is_dynamic:`

to reset batch_size to static in case of dynamic shape with single -data_shape

* Check only app_input_info.size() == 1 because if it's gretaer than 1, input shape is dynamic and there are more that one static shapes. Apply TODO
This commit is contained in:
Zlobin Vladimir authored and GitHub committed 2023-07-14 15:21:55 +00:00
1 parent 9973feda74
commit ce8f164fea
5 files changed
+14 -18

No files matched your search

+5 -3
View File
@@ -811,16 +811,18 @@ int main(int argc, char* argv[]) {
}
}
if (isDynamicNetwork && FLAGS_api == "sync") {
bool allow_inference_only_or_sync = can_measure_as_static(app_inputs_info);
if (!allow_inference_only_or_sync && FLAGS_api == "sync") {
throw std::logic_error("Benchmarking of the model with dynamic shapes is available for async API only. "
"Please use -api async -nstreams 1 -nireq 1 to emulate sync behavior");
"Please use -api async -hint latency -nireq 1 to emulate sync behavior");
}
// Defining of benchmark mode
// for static models inference only mode is used as default one
bool inferenceOnly = FLAGS_inference_only;
if (isDynamicNetwork) {
if (isFlagSetInCommandLine("inference_only") && inferenceOnly && app_inputs_info.size() != 1) {
if (isFlagSetInCommandLine("inference_only") && inferenceOnly && !allow_inference_only_or_sync) {
throw std::logic_error(
"Dynamic models with different input data shapes must be benchmarked only in full mode.");
}
+4
View File
@@ -108,6 +108,10 @@ std::vector<float> split_float(const std::string& s, char delim) {
return result;
}
bool can_measure_as_static(const std::vector<benchmark_app::InputsInfo>& app_input_info) {
return app_input_info.size() == 1;
}
static const std::vector<std::string> meta_plugins{"MULTI", "HETERO", "AUTO"};
bool is_virtual_device(const std::string& device_name) {
return std::find(meta_plugins.begin(), meta_plugins.end(), device_name) != meta_plugins.end();
+1
View File
@@ -58,6 +58,7 @@ using InputsInfo = std::map<std::string, InputInfo>;
using PartialShapes = std::map<std::string, ngraph::PartialShape>;
} // namespace benchmark_app
bool can_measure_as_static(const std::vector<benchmark_app::InputsInfo>& app_input_info);
bool is_virtual_device(const std::string& device_name);
bool is_virtual_device_found(const std::vector<std::string>& device_names);
void update_device_properties_setting(const std::string& device_name,