@@ -54,29 +54,35 @@ def parse_value_per_device(devices: Set[str], values_string: str)-> Dict[str, in
54
54
55
55
56
56
def get_user_config (flags_d : str , flags_nstreams : str , flags_nthreads : int )-> Dict [str , str ]:
57
+ from openvino import Core , properties
57
58
config = {}
58
59
59
60
devices = set (parse_devices (flags_d ))
60
61
61
62
device_nstreams = parse_value_per_device (devices , flags_nstreams )
63
+ core = Core ()
62
64
for device in devices :
65
+ supported_properties = core .get_property (device , properties .supported_properties ())
63
66
if device == 'CPU' : # CPU supports a few special performance-oriented keys
64
67
# limit threading for CPU portion of inference
65
68
if flags_nthreads :
66
- config ['CPU_THREADS_NUM' ] = str (flags_nthreads )
67
-
68
- config ['CPU_BIND_THREAD' ] = 'NO'
69
-
70
- # for CPU execution, more throughput-oriented execution via streams
71
- config ['CPU_THROUGHPUT_STREAMS' ] = str (device_nstreams [device ]) \
72
- if device in device_nstreams else 'CPU_THROUGHPUT_AUTO'
69
+ config [device ]['CPU_THREADS_NUM' ] = str (flags_nthreads )
70
+
71
+ config [device ]['ENABLE_CPU_PINNING' ] = 'NO'
72
+ if "CPU_THROUGHPUT_STREAMS" in supported_properties :
73
+ # for CPU execution, more throughput-oriented execution via streams
74
+ config [device ]['CPU_THROUGHPUT_STREAMS' ] = str (device_nstreams .get (device , 'CPU_THROUGHPUT_AUTO' ))
75
+ else :
76
+ config [device ]["NUM_STREAMS" ] = str (device_nstreams .get (device , - 1 ))
73
77
elif device == 'GPU' :
74
- config ['GPU_THROUGHPUT_STREAMS' ] = str (device_nstreams [device ]) \
75
- if device in device_nstreams else 'GPU_THROUGHPUT_AUTO'
78
+ if "GPU_THROUGHPUT_STREAMS" in supported_properties :
79
+ config [device ]['GPU_THROUGHPUT_STREAMS' ] = str (device_nstreams .get (device , 'GPU_THROUGHPUT_AUTO' ))
80
+ else :
81
+ config [device ]["NUM_STREAMS" ] = str (device_nstreams .get (device , - 1 ))
76
82
if 'MULTI' in flags_d and 'CPU' in devices :
77
83
# multi-device execution with the CPU + GPU performs best with GPU throttling hint,
78
84
# which releases another CPU thread (that is otherwise used by the GPU driver for active polling)
79
- config ['GPU_PLUGIN_THROTTLE' ] = '1'
85
+ config [device ][ 'GPU_PLUGIN_THROTTLE' ] = '1'
80
86
return config
81
87
82
88
0 commit comments