Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Benchmark App] Reject -nireq > -niter when using sync API (#27460)

Valentin Rusu9ff42cde8951
diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp
index 2cfd15b77af..4dcc1e82924 100644
--- a/samples/cpp/benchmark_app/main.cpp
+++ b/samples/cpp/benchmark_app/main.cpp
@@ -60,6 +60,10 @@ bool parse_and_check_command_line(int argc, char* argv[]) {
if (FLAGS_api != "async" && FLAGS_api != "sync") {
throw std::logic_error("Incorrect API. Please set -api option to `sync` or `async` value.");
}
+ if (FLAGS_api == "sync" && FLAGS_nireq > FLAGS_niter) {
+ throw std::logic_error(
+ "Number of iterations should be greater than number of infer requests when using sync API.");
+ }
if (!FLAGS_hint.empty() && FLAGS_hint != "throughput" && FLAGS_hint != "tput" && FLAGS_hint != "latency" &&
FLAGS_hint != "cumulative_throughput" && FLAGS_hint != "ctput" && FLAGS_hint != "none") {
throw std::logic_error("Incorrect performance hint. Please set -hint option to"
diff --git a/tools/benchmark_tool/openvino/tools/benchmark/main.py b/tools/benchmark_tool/openvino/tools/benchmark/main.py
index ad2839d217f..c77b50a7fd4 100644
--- a/tools/benchmark_tool/openvino/tools/benchmark/main.py
+++ b/tools/benchmark_tool/openvino/tools/benchmark/main.py
@@ -49,6 +49,9 @@ def parse_and_check_command_line():
raise Exception("Cannot set precision for a compiled model. " \
"Please re-compile your model with required precision.")
+ if args.api_type == "sync" and args.number_infer_requests > args.number_iterations:
+ raise Exception("Number of infer requests should be less than or equal to number of iterations in sync mode.")
+
return args, is_network_compiled
def main():