def __init__(self, args, nntool_workdir, *rest, **kwargs): self._nntool_workdir = nntool_workdir self._graph_idx = 0 self._graphs = [] self._settings = [] self._tensor_store = {} super(NNToolShellBase, self).__init__(*rest, **kwargs) self.py_locals['tensors'] = self._tensor_store if args and args.log_level is not None: self.settings['log_level'] = args.log_level.upper() self._graph_idx = 0 # settings overide graph file graph_file = self.settings['graph_file'] tensor_file = self.settings['tensor_file'] # command line overides that if args: if args.graph_file: graph_file = args.graph_file if args.tensor_file: tensor_file = args.tensor_file if args.template_file: self.settings['template_file'] = args.template_file if args.tf_quant: self.settings['load_quantization'] = args.tf_quant if args.dequant_tf: self.settings['load_dequantized'] = args.dequant_tf if 'log_level' not in self.settings: self.settings['log_level'] = "INFO" if graph_file: self._graphs = [] self._startup_commands.append( self.__build_open_graph( graph_file, tensor_file, self.load_quantization, load_dequantized=self.settings.get('load_dequantized'))) else: self._graphs = [NO_GRAPH.copy()] ExecutionProgress().listen(progress) LOG.propagate = False handler = NNToolShellLogHandler(self) formatter = logging.Formatter('%(module)s - %(message)s') handler.setFormatter(formatter) LOG.addHandler(handler) LOG.setLevel(self.settings['log_level'])
def __init__(self, *args, **kwargs): rest = args[1:] args = args[0] if args else None self._graph_idx = 0 self._graphs = [NO_GRAPH.copy()] self._cmd_history = [[]] self._history_stats = [] self._first_graph_open = False self._replaying_history = False self._settings = [] self._tensor_store = {} super(NNToolShellBase, self).__init__(*rest, **kwargs) self.feedback_to_output = True self.register_postcmd_hook(self._record_history) self.py_locals['tensors'] = self._tensor_store if args and args.log_level is not None: self._startup_commands.append( f'set log_level {args.log_level.upper()}') else: self._startup_commands.append('set log_level INFO') if args and args.anonymise: self._startup_commands.append(f'set anonymise true') self._graph_idx = 0 # settings overide graph file graph_file = self.settings['graph_file'] # command line overides that if args: if args.graph_file: graph_file = args.graph_file if args.template_file: self._startup_commands.append( f'set template_file {args.template_file}') if graph_file: self._startup_commands.append( self.__build_open_graph(graph_file, args)) if not self.LOG_HANDLER_SET: ExecutionProgress().listen(progress) LOG.propagate = False handler = NNToolShellLogHandler(self, LOG) formatter = logging.Formatter('%(module)s - %(message)s') handler.setFormatter(formatter) NNToolShellBase.LOG_HANDLER_SET = True self.py_locals['graphs'] = self._graphs