OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Fix benchmark app empty device parsing (#38356)
Yug Shah72c577486315
diff --git a/samples/cpp/benchmark_app/utils.cpp b/samples/cpp/benchmark_app/utils.cppindex 690ba600839..a79fe97f62f 100644--- a/samples/cpp/benchmark_app/utils.cpp+++ b/samples/cpp/benchmark_app/utils.cpp@@ -173,6 +173,9 @@ std::vector<std::string> parse_devices(const std::string& device_string) {auto devices = split(comma_separated_devices, ',');for (auto&& device : devices) {+ device = trim(device);+ if (device.empty())+ continue;// e.g. in AUTO:-CPU,-GPUif (device.front() == '-')device.erase(device.begin());diff --git a/tests/samples_tests/smoke_tests/test_benchmark_app.py b/tests/samples_tests/smoke_tests/test_benchmark_app.pyindex c5423df8123..6098de693d1 100755--- a/tests/samples_tests/smoke_tests/test_benchmark_app.py+++ b/tests/samples_tests/smoke_tests/test_benchmark_app.py@@ -21,6 +21,7 @@ import pathlibimport pytestfrom common.samples_common_test_class import get_devices, get_cmd_output, prependfrom openvino import opset8 as opset+from openvino.tools.benchmark.utils.utils import parse_devicesimport openvino as ovdef get_executable(sample_language):@@ -116,6 +117,11 @@ def verify(sample_language, device, api=None, nireq=None, shape=None, data_shapedef test_benchmark_app_help(sample_language):get_cmd_output(get_executable(sample_language), '-h')+def test_parse_devices_with_empty_entries():+ assert parse_devices('MULTI:CPU,,GPU') == ['MULTI', 'CPU', 'GPU']+ assert parse_devices('MULTI:CPU, ,GPU') == ['MULTI', 'CPU', 'GPU']+ assert parse_devices('HETERO:CPU,') == ['HETERO', 'CPU']+@pytest.mark.parametrize('sample_language', ['C++', 'Python'])@pytest.mark.parametrize('api', ['sync', 'async'])diff --git a/tools/benchmark_tool/openvino/tools/benchmark/utils/utils.py b/tools/benchmark_tool/openvino/tools/benchmark/utils/utils.pyindex 9ad22632b2d..8565ba095cd 100644--- a/tools/benchmark_tool/openvino/tools/benchmark/utils/utils.py+++ b/tools/benchmark_tool/openvino/tools/benchmark/utils/utils.py@@ -290,6 +290,9 @@ def parse_devices(device_string):if device_string.find(":") != -1:hw_devices_str = device_string.partition(":")[-1]for hw_device in hw_devices_str.split(','):+ hw_device = hw_device.strip()+ if not hw_device:+ continueif hw_device[0] == '-':hw_device = hw_device[1:]result.append(hw_device)