Beispiel #1
0
def _run_single_process_loop(ms, load_model, single_chunk, solver_type,
                             solver_opts, debug_opts, out_opts):
    """
    Runs the main loop in single-CPU mode.

    Args:
        ms: 
        nworker: 
        nthread: 
        load_model: 
        single_chunk: 
        solver_type: 
        solver_opts: 
        debug_opts: 
        out_opts: output options from GD
    Returns:
        Stats dictionary
    """
    global tile_list

    stats_dict = {}

    for itile, tile in enumerate(tile_list):
        tile.load(load_model=load_model)
        processed = False
        for key in tile.get_chunk_keys():
            if not single_chunk or key == single_chunk:
                processed = True
                stats = solver.run_solver(solver_type, itile, key, solver_opts,
                                          debug_opts)
                stats_dict[tile.get_chunk_indices(key)] = stats

        if processed:
            only_save = ["output", "model", "weight", "flag", "bitflag"] if out_opts is None or out_opts["apply-solver-flags"] else \
                        ["output", "model", "weight"]
            tile.save(final=tile is tile_list[-1], only_save=only_save)
            for sd in tile.iterate_solution_chunks():
                solver.gm_factory.save_solutions(sd)
                solver.ifrgain_machine.accumulate(sd)
        else:
            print("  single-chunk {} not in this tile, skipping it.".format(
                single_chunk),
                  file=log(0))
        tile.release()
        # break out after single chunk is processed
        if processed and single_chunk:
            print(
                "single-chunk {} was processed in this tile. Will now finish".
                format(single_chunk),
                file=log(0, "red"))
            break
    solver.ifrgain_machine.save()
    solver.gm_factory.set_metas(ms)
    solver.gm_factory.close()

    return stats_dict
Beispiel #2
0
def _run_single_process_loop(ms, load_model, single_chunk, solver_type,
                             solver_opts, debug_opts):
    """
    Runs the main loop in single-CPU mode.

    Args:
        ms: 
        nworker: 
        nthread: 
        load_model: 
        single_chunk: 
        solver_type: 
        solver_opts: 
        debug_opts: 

    Returns:
        Stats dictionary
    """
    global tile_list

    stats_dict = {}

    for itile, tile in enumerate(tile_list):
        tile.load(load_model=load_model)
        processed = False
        for key in tile.get_chunk_keys():
            if not single_chunk or key == single_chunk:
                processed = True
                stats_dict[tile.get_chunk_indices(key)] = \
                    solver.run_solver(solver_type, itile, key, solver_opts, debug_opts)
        if processed:
            tile.save()
            for sd in tile.iterate_solution_chunks():
                solver.gm_factory.save_solutions(sd)
                solver.ifrgain_machine.accumulate(sd)
        else:
            print >> log(
                0), "  single-chunk {} not in this tile, skipping it.".format(
                    single_chunk)
        tile.release()
        # break out after single chunk is processed
        if processed and single_chunk:
            print >> log(
                0, "red"
            ), "single-chunk {} was processed in this tile. Will now finish".format(
                single_chunk)
            break
    solver.ifrgain_machine.save()
    solver.gm_factory.set_metas(ms)
    solver.gm_factory.close()

    return stats_dict