Skip to content

Commit

Permalink
[OV] Fixed performance properties
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sidorova committed Sep 23, 2024
1 parent cf6adb8 commit 22569bf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/inference/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

try:
from openvino.runtime import Core, Tensor, PartialShape
import openvino.properties as props
import openvino.properties.hint as hints
_ov_runtime_supported = True
except ImportError:
_ov_runtime_supported = False
Expand Down Expand Up @@ -84,21 +86,23 @@ def set_property(core, devices, nthreads, nstreams, dump, mode):
for device in device_list:
if device == 'CPU':
if nthreads:
core.set_property('CPU', {'CPU_THREADS_NUM': str(nthreads)})
core.set_property('CPU', {props.inference_num_threads: nthreads})
if 'MULTI' in devices and 'GPU' in devices:
core.set_property({'CPU_BIND_THREAD': 'NO'}, 'CPU')
if mode == 'async':
cpu_throughput = {'CPU_THROUGHPUT_STREAMS': 'CPU_THROUGHPUT_AUTO'}
core.set_property('CPU', {hints.performance_mode: hints.PerformanceMode.THROUGHPUT})
cpu_throughput = {props.num_streams: props.streams.Num.AUTO}
if device in streams_dict.keys() and streams_dict[device]:
cpu_throughput['CPU_THROUGHPUT_STREAMS'] = streams_dict['CPU']
cpu_throughput[props.num_streams] = streams_dict['CPU']
core.set_property('CPU', cpu_throughput)
if device == 'GPU':
if 'MULTI' in devices and 'СPU' in devices:
core.set_property('GPU', {'GPU_QUEUE_THROTTLE': '1'})
if mode == 'async':
gpu_throughput = {'GPU_THROUGHPUT_STREAMS': 'GPU_THROUGHPUT_AUTO'}
core.set_property('GPU', {hints.performance_mode: hints.PerformanceMode.THROUGHPUT})
gpu_throughput = {props.num_streams: props.streams.Num.AUTO}
if device in streams_dict.keys() and streams_dict[device]:
gpu_throughput['GPU_THROUGHPUT_STREAMS'] = streams_dict['GPU']
gpu_throughput[props.num_streams] = streams_dict['GPU']
core.set_property('GPU', gpu_throughput)
if dump:
if 'HETERO' in devices:
Expand Down

0 comments on commit 22569bf

Please sign in to comment.