py/benchmark_app: fix -hint (#16511)

* py/benchmark_app: fix -hint

Don't warn about values which are explicitly set in -hint.
That aligns C++ and Python implementations.

Ticket 106544

* Remove extra throw

* Fix code style
This commit is contained in:
Zlobin Vladimir 2023-03-24 10:24:08 +04:00 committed by GitHub
parent 8518a3a8e8
commit 69cec4a5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View File

@ -126,17 +126,17 @@ ov::hint::PerformanceMode get_performance_hint(const std::string& device, const
supported_properties.end()) {
if (FLAGS_hint != "") {
if (FLAGS_hint == "throughput" || FLAGS_hint == "tput") {
slog::warn << "Device(" << device << ") performance hint is set to THROUGHPUT" << slog::endl;
ov_perf_hint = ov::hint::PerformanceMode::THROUGHPUT;
} else if (FLAGS_hint == "latency") {
slog::warn << "Device(" << device << ") performance hint is set to LATENCY" << slog::endl;
ov_perf_hint = ov::hint::PerformanceMode::LATENCY;
} else if (FLAGS_hint == "cumulative_throughput" || FLAGS_hint == "ctput") {
slog::warn << "Device(" << device << ") performance hint is set to CUMULATIVE_THROUGHPUT" << slog::endl;
ov_perf_hint = ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT;
} else if (FLAGS_hint == "none") {
slog::warn << "No device(" << device << ") performance hint is set" << slog::endl;
ov_perf_hint = ov::hint::PerformanceMode::UNDEFINED;
} else {
throw std::logic_error(
"Incorrect performance hint. Please set -hint option to"
"`throughput`(tput), `latency', 'cumulative_throughput'(ctput) value or 'none'.");
}
} else {
ov_perf_hint =

View File

@ -113,11 +113,17 @@ def main():
supported_properties = benchmark.core.get_property(device, properties.supported_properties())
if properties.hint.performance_mode() in supported_properties:
if is_flag_set_in_command_line('hint'):
if args.perf_hint=='none':
logger.warning(f"No device {device} performance hint is set.")
if args.perf_hint == "throughput" or args.perf_hint == "tput":
perf_hint = properties.hint.PerformanceMode.THROUGHPUT
elif args.perf_hint == "latency":
perf_hint = properties.hint.PerformanceMode.LATENCY
elif args.perf_hint == "cumulative_throughput" or args.perf_hint == "ctput":
perf_hint = properties.hint.PerformanceMode.CUMULATIVE_THROUGHPUT
elif args.perf_hint=='none':
perf_hint = properties.hint.PerformanceMode.UNDEFINED
else:
perf_hint = properties.hint.PerformanceMode(args.perf_hint.upper())
raise RuntimeError("Incorrect performance hint. Please set -hint option to"
"`throughput`(tput), `latency', 'cumulative_throughput'(ctput) value or 'none'.")
else:
perf_hint = properties.hint.PerformanceMode.THROUGHPUT if benchmark.api_type == "async" else properties.hint.PerformanceMode.LATENCY
logger.warning(f"Performance hint was not explicitly specified in command line. " +

View File

@ -60,7 +60,7 @@ def parse_args():
'Default value is CPU. Use \'-d HETERO:<comma separated devices list>\' format to specify HETERO plugin. '
'Use \'-d MULTI:<comma separated devices list>\' format to specify MULTI plugin. '
'The application looks for a suitable plugin for the specified device.')
args.add_argument('-hint', '--perf_hint', type=str, required=False, default='', choices=['throughput', 'cumulative_throughput', 'latency', 'none'],
args.add_argument('-hint', '--perf_hint', type=str, required=False, default='', choices=('throughput', 'tput', 'cumulative_throughput', 'ctput', 'latency', 'none'),
help='Optional. Performance hint (latency or throughput or cumulative_throughput or none). Performance hint allows the OpenVINO device to select the right model-specific settings.\n'
'\'throughput\': device performance mode will be set to THROUGHPUT. \n'
'\'cumulative_throughput\': device performance mode will be set to CUMULATIVE_THROUGHPUT. \n'