def __init__(self, input_sources): if utils.is_anystr(input_sources): input_sources = self._parse(input_sources) if isinstance(input_sources, dict): input_sources = self._resolve_multikey(input_sources) if input_sources is None: input_sources = DefaultInput() self.input_sources = input_sources
def load_configs(module_names="", load_standard=True): # type: (typing.Union[str, typing.List[str], None], bool)->typing.List[NNEFParserConfig] """ :param module_names: "package.module" or "p1.m1,p2.m2", or ["p1.m1", "p2.m2"] :param load_standard: Load the standard NNEF op definitions as well :return: parser configs """ if module_names is None: module_names = [] if utils.is_anystr(module_names): module_names = [name.strip() for name in module_names.split(',') ] if module_names.strip() else [] configs = [NNEFParserConfig.STANDARD_CONFIG] if load_standard else [] for module_name in module_names: config = NNEFParserConfig.load_config(module_name) if not config.empty: configs.append(config) return configs
def _normalize_types(arg): if utils.is_anyint(arg): return utils.anyint_to_int(arg) elif utils.is_anystr(arg): return utils.anystr_to_str(arg) elif isinstance(arg, np.ndarray): return arg.tolist() elif isinstance(arg, tf.TensorShape): if arg.dims is None: return None return [None if dim is None else int(dim) for dim in arg.as_list()] elif isinstance(arg, tf.Dimension): return arg.value elif isinstance(arg, tf.DType): return arg.name elif isinstance( arg, (np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64, np.float16, np.float32, np.float64, np.bool_)): return arg.item() else: return arg
def eval_functions(self): self.functions = [ self._eval_function(fun) if utils.is_anystr(fun) else fun for fun in self.functions ]