Ejemplo n.º 1
0
def main():
    while len(sys.argv) > 1:
        util.get_log().info("Single command mode.")
        function_key = sys.argv[1]
        cmd_line = sys.argv[2] if len(sys.argv) > 2 else None
        if function_key in function_list:
            return function_list[function_key](cmd_line)
        precision_tool = PrecisionTool()
        return precision_tool.single_cmd(sys.argv)
    _run_interactive_cli()
Ejemplo n.º 2
0
def _run_interactive_cli(cli=None):
    """ Run precision_tool in interactive mode
    :param cli:
    :return:
    """
    util.get_log().info("Interactive command mode.")
    if cli is None:
        cli = InteractiveCli()
    try:
        cli.cmdloop(intro="Enjoy!")
    except KeyboardInterrupt:
        util.get_log().info("Bye.......")
Ejemplo n.º 3
0
def _run_npu_dump(cmd):
    """Deprecate function."""
    _unset_flags()
    log = util.get_log()
    os.environ[cfg.PRECISION_TOOL_DUMP_FLAG] = 'True'
    log.info("Start run NPU script with dump data.")
    ret = util.execute_command(cmd)
    log.info("Finish run NPU script with dump data. ret [%s]", ret)
    _unset_flags()
Ejemplo n.º 4
0
def _run_npu_overflow(cmd):
    """Deprecate function."""
    _unset_flags()
    log = util.get_log()
    os.environ[cfg.PRECISION_TOOL_OVERFLOW_FLAG] = 'True'
    log.info("Start run NPU script with overflow check process....")
    ret = util.execute_command(cmd)
    log.info("Finish run NPU script with overflow check process. ret [%s]",
             ret)
    precision_tool = PrecisionTool()
    precision_tool.prepare()
    precision_tool.do_check_overflow()
    _unset_flags()
Ejemplo n.º 5
0
    cfg.DATA_ROOT_DIR = data_path
    _run_interactive_cli()


function_list = {
    'tf_dump': _run_tf_dbg_dump,
    'npu_dump': _run_npu_dump,
    'npu_overflow': _run_npu_overflow,
    'infer': _run_infer_adapter,
    'data': _run_cli_with_data
}


def main():
    while len(sys.argv) > 1:
        util.get_log().info("Single command mode.")
        function_key = sys.argv[1]
        cmd_line = sys.argv[2] if len(sys.argv) > 2 else None
        if function_key in function_list:
            return function_list[function_key](cmd_line)
        precision_tool = PrecisionTool()
        return precision_tool.single_cmd(sys.argv)
    _run_interactive_cli()


if __name__ == '__main__':
    try:
        main()
    except PrecisionToolException as pte:
        util.get_log().error(pte.error_info)