Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
num_requests = get_or_parse_value(num_requests, casting_type=int)
if len(num_requests) != 1:
raise ConfigError('Several values for _num_requests specified')
self._num_requests = num_requests[0]
if self._num_requests != 1 and not self.async_mode:
warning('{} infer requests in sync mode is not supported. Only 1 infer request will be used.')
self._num_requests = 1
elif not self.async_mode:
self._num_requests = 1
else:
self._num_requests = self.auto_num_requests()
if hasattr(self, 'plugin'):
del self.plugin
if log:
print_info('IE version: {}'.format(ie.get_version()))
if self._is_multi():
self._create_multi_device_plugin(log)
else:
self.plugin = ie.IEPlugin(self._device)
self.async_mode = self.get_value_from_config('async_mode')
set_nireq()
if log:
print_info('Loaded {} plugin version: {}'.format(self.plugin.device, self.plugin.version))
if self._device_ids:
correct_id = [device_id for device_id in self._device_ids if device_id is not None]
if correct_id:
self.plugin.set_config({'DEVICE_ID': correct_id[0]})
cpu_extensions = self.config.get('cpu_extensions')
if cpu_extensions and 'CPU' in self._devices_list():
selection_mode = self.config.get('_cpu_extensions_mode')
def get_version_info(self) -> str:
logger.info('InferenceEngine:\n{: <9}{:.<24} {}'.format('', 'API version', get_version()))
version_string = 'Device info\n'
for device, version in self.ie.get_versions(self.device).items():
version_string += '{: <9}{}\n'.format('', device)
version_string += '{: <9}{:.<24}{} {}.{}\n'.format('', version.description, ' version', version.major,
version.minor)
version_string += '{: <9}{:.<24} {}\n'.format('', 'Build', version.build_number)
return version_string
def _create_ie_plugin(self, log=True):
if hasattr(self, 'plugin'):
del self.plugin
self.plugin = ie.IEPlugin(self._device)
if log:
print_info('IE version: {}'.format(ie.get_version()))
print_info('Loaded {} plugin version: {}'.format(self.plugin.device, self.plugin.version))
cpu_extensions = self.config.get('cpu_extensions')
if cpu_extensions and 'CPU' in self._devices_list():
selection_mode = self.config.get('_cpu_extensions_mode')
cpu_extensions = DLSDKLauncher.get_cpu_extension(cpu_extensions, selection_mode)
self.plugin.add_cpu_extension(str(cpu_extensions))
gpu_extensions = self.config.get('gpu_extensions')
if gpu_extensions and 'GPU' in self._devices_list():
self.plugin.set_config('CONFIG_FILE', str(gpu_extensions))
if self._is_vpu():
log_level = self.config.get('_vpu_log_level')
if log_level:
self.plugin.set_config({'VPU_LOG_LEVEL': log_level})