Beispiel #1
0
def output_table(table, args):
    fmt = ('tab' if args.output is None else args.output['fmt'])
    if fmt == "xls":
        table.render(ExcelRenderer(args.output['filename']))
    elif fmt == "csv":
        with open(args.output['filename'], "w") as file:
            table.render(CSVRenderer(file))
    else:
        renderer = TextTableRenderer(args.table_width)
        table.render(renderer)
        print(renderer.get_output())
Beispiel #2
0
def test_textable():
    tab = Tabular()
    tab.add_row([TabularColumn('test1'), TabularColumn('test2'), TabularColumn('test3', fmt="^d")])
    tab.add_row(["1", "2", 3])
    renderer = TextTableRenderer(maxwidth=80)
    tab.render(renderer)
    output = renderer.get_output()
    assert output == ('+-------+-------+-------+\n'
                      '| test1 | test2 | test3 |\n'
                      '+=======+=======+=======+\n'
                      '| 1     | 2     |   3   |\n'
                      '+-------+-------+-------+')
def test_temps_report_quantized(mnist_unfused_8bit_state):
    G = load_state(mnist_unfused_8bit_state)
    G.add_dimensions()
    stats_collector = TempsStatsCollector(qrecs=G.quantization)
    stats = stats_collector.collect_stats(G)
    report = TempsReporter().report(G, stats)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
def test_temps_report(mnist_graph):
    G = create_graph(mnist_graph, opts={"load_tensors": True})
    G.add_dimensions()
    stats_collector = TempsStatsCollector()
    stats = stats_collector.collect_stats(G)
    report = TempsReporter().report(G, stats)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
Beispiel #5
0
def test_filter_detailed_report(mnist_graph, mnist_images):
    G = create_graph(mnist_graph, opts={"load_tensors": True})
    G.add_dimensions()
    stats_collector = FilterDetailedStatsCollector()
    stats = stats_collector.collect_stats(G)
    report = FilterDetailedStatsReporter().report(G, stats)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
def test_activation_report(mnist_graph, mnist_images):
    G = create_graph(mnist_graph, opts={"load_tensors": True})
    G.add_dimensions()
    input_tensor = import_data(mnist_images[0],
                               height=28,
                               width=28,
                               offset=0,
                               divisor=255)
    input_tensor = input_tensor.reshape((28, 28, 1))
    stats_collector = ActivationStatsCollector()
    stats_collector.collect_stats(G, [input_tensor])
    report = ActivationReporter().report(G, stats_collector.reduce_stats())
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
def test_error_report(mnist_unfused_8bit_state, mnist_images):
    G = load_state(mnist_unfused_8bit_state)
    G.add_dimensions()
    input_tensor = import_data(mnist_images[0],
                               height=28,
                               width=28,
                               offset=0,
                               divisor=255)
    input_tensor = input_tensor.reshape((28, 28, 1))
    stats_collector = ErrorStatsCollector()
    stats_collector.collect_stats(G, [input_tensor])
    stats_collector.collect_stats(G, [input_tensor])
    report = ErrorReporter().report(G, stats_collector.reduce_stats())
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
Beispiel #8
0
def test_adjust7(concat_test_graph):
    tfi = TfliteImporter()
    G = tfi.create_graph(concat_test_graph, {'load_tensors': True})
    G.node('input_1').fixed_order = True
    G.node('output_1').fixed_order = True
    G.node('output_2').fixed_order = True
    G.add_dimensions()
    G.adjust_order()
    matcher = get_pow2_match_group()
    matcher.match(G)
    G.add_dimensions()
    report = GraphReporter().report(G, None)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
    report = GraphReporter(split_dims=True).report(G, None)
def test_simple_quantization(mnist_graph, mnist_images):
    G = create_graph(mnist_graph, opts={"load_tensors": True})
    G.add_dimensions()
    input_tensor = import_data(mnist_images[0],
                               height=28,
                               width=28,
                               offset=0,
                               divisor=255)
    input_tensor = input_tensor.reshape((28, 28, 1))
    stats_collector = ActivationStatsCollector()
    stats_collector.collect_stats(G, [input_tensor])
    astats = stats_collector.reduce_stats()
    stats_collector = FilterStatsCollector()
    fstats = stats_collector.collect_stats(G)
    quantizer = SymmetricQuantizer(astats, fstats, force_width=8)
    qrecs = quantizer.quantize(G)
    assert len(qrecs) == 11  # One more for saved quantizer
    report = QuantizationReporter().report(G, qrecs)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))
def test_graph_report(mnist_graph):
    G = create_graph(mnist_graph, opts={"load_tensors": True})
    G.add_dimensions()
    report = GraphReporter().report(G, None)
    renderer = TextTableRenderer(maxwidth=200)
    print(report.render(renderer))