Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ie_network(self) -> ie.IENetwork:
if not self._ie_network:
self._ie_network = ie.IENetwork(self._model_path, self._weights_path)
return self._ie_network
def create_network(self) -> ie.IENetwork:
network = ie.IENetwork(self._configuration.model, self._configuration.weights)
if len(network.outputs) == 0:
raise ValueError("no outputs")
if len(network.inputs) == 0:
raise ValueError("no inputs")
return network
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})
def __init__(self, configuration: CalibratorConfiguration):
self._configuration = configuration
network = self.create_network()
self._input_layer_name = next(iter(network.inputs))
self._output_layer_name = next(iter(network.outputs))
self.plugin = ie.IEPlugin(self._configuration.device)
if self._configuration.cpu_extension and self._configuration.device == 'CPU':
self.plugin.add_cpu_extension(self._configuration.cpu_extension)
if self._configuration.gpu_extension and self._configuration.device == 'GPU':
self.plugin.set_config('CONFIG_FILE', self._configuration.gpu_extension)
warning(
"number requests already provided in device name specification. "
"'num_requests' option will be ignored."
)
else:
num_per_device_requests = get_or_parse_value(self.config.get('num_requests', 1), casting_type=int)
if len(num_per_device_requests) == 1:
num_per_device_requests = [num_per_device_requests[0]] * len(device_list)
if num_devices != len(num_per_device_requests):
raise ConfigError('num requests for all {} should be specified'.format(num_devices))
device_strings = [
'{device}({nreq})'.format(device=device, nreq=nreq)
for device, nreq in zip(device_list, num_per_device_requests)
]
self.plugin = ie.IEPlugin('MULTI:{}'.format(','.join(device_strings)))
self._num_requests = sum(num_per_device_requests)*2
if log:
print_info('Loaded {} plugin version: {}'.format(self.plugin.device, self.plugin.version))
print_info('Request number for each device:')
for device, nreq in zip(device_list, num_per_device_requests):
print_info(' {} - {}'.format(device, nreq))
get_parameter_value_from_config,
string_to_tuple,
get_or_parse_value
)
from .launcher import Launcher, LauncherConfigValidator
from .model_conversion import convert_model, FrameworkParameters
from ..logging import print_info
HETERO_KEYWORD = 'HETERO:'
MULTI_DEVICE_KEYWORD = 'MULTI:'
FPGA_COMPILER_MODE_VAR = 'CL_CONTEXT_COMPILER_MODE_INTELFPGA'
NIREQ_REGEX = r"(\(\d+\))"
MYRIAD_WITH_DEVICE_ID = r"MYRIAD\.*.*"
HETERO_MODE_REGEX = r"(?:^{hetero}(?P(?:{devices})(?:,(?:{devices}))*)$)".format(
hetero=HETERO_KEYWORD, devices="|".join(ie.known_plugins + [MYRIAD_WITH_DEVICE_ID])
)
MULTI_DEVICE_MODE_REGEX = r"(?:^{multi}(?P(?:{devices_ireq})(?:,(?:{devices_ireq}))*)$)".format(
multi=MULTI_DEVICE_KEYWORD, devices_ireq="{}?|".format(NIREQ_REGEX).join(ie.known_plugins + [MYRIAD_WITH_DEVICE_ID])
)
DEVICE_REGEX = r"(?:^(?P{devices})$)".format(devices="|".join(ie.known_plugins + [MYRIAD_WITH_DEVICE_ID]))
SUPPORTED_DEVICE_REGEX = r"{multi}|{hetero}|{regular}".format(
multi=MULTI_DEVICE_MODE_REGEX, hetero=HETERO_MODE_REGEX, regular=DEVICE_REGEX
)
VPU_PLUGINS = ('HDDL', "MYRIAD")
VPU_LOG_LEVELS = ('LOG_NONE', 'LOG_WARNING', 'LOG_INFO', 'LOG_DEBUG')
class CPUExtensionPathField(PathField):
def __init__(self, **kwargs):
super().__init__(is_directory=False, **kwargs)