Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def validate(self, entry, field_uri=None):
if entry is None:
return
field_uri = field_uri or self.field_uri
import platform
import numpy as np
from cpuinfo import get_cpu_info
import openvino.inference_engine as ie
from ..config import ConfigError, NumberField, PathField, StringField, DictField, ListField, BoolField
from ..logging import warning
from ..utils import read_yaml, contains_all, get_path, contains_any
from .launcher import Launcher, LauncherConfig
from .model_conversion import convert_model, FrameworkParameters
from ..logging import print_info
HETERO_KEYWORD = 'HETERO:'
FPGA_COMPILER_MODE_VAR = 'CL_CONTEXT_COMPILER_MODE_INTELFPGA'
DEVICE_REGEX = r"(?:^{hetero}(?P(?:{devices})(?:,(?:{devices}))*)$)|(?:^(?P{devices})$)".format(
hetero=HETERO_KEYWORD, devices="|".join(plugin for plugin in ie.known_plugins)
)
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)
def validate(self, entry, field_uri=None):
if entry is None:
return
field_uri = field_uri or self.field_uri
validation_entry = ''
try: