paleo/simulation.py
def _sum_with_parallel(layer_dependencies, layer_list, times):
    """This function sums the time but allows parallel execution.
    Layer dependencies and layer_list are LayerSpec objects.
    Here we only need name. need refactor later.
    """
    assert len(layer_list) == len(times)
    layers_to_times = dict()
    for i, l in enumerate(layer_list):
        t = times[i]
        if isinstance(t, TimeMeasure):
            t = t.total_time
        layers_to_times[l.name] = t

    lower_bound, upper_bound = 0, 0
    for block in layer_dependencies:
        if isinstance(block, tuple):
            # Parallel nodes, each element in the tuple shall be a list.
            parallel_times = []
            for sequence in block:
                sum_of_time = sum(
                    [layers_to_times.get(l.name, 0) for l in sequence])
                parallel_times.append(sum_of_time)
            lower_bound += max(parallel_times)
            upper_bound += sum(parallel_times)
        else:
            lower_bound += layers_to_times.get(block.name, 0)
            upper_bound += layers_to_times.get(block.name, 0)

    return lower_bound, upper_bound
This function sums the time but allows parallel execution.
    Layer dependencies and layer_list are LayerSpec objects.
    Here we only need name. need refactor later.
    
This function sums the time but allows parallel execution.
Layer dependencies and layer_list are LayerSpec objects.
Here we only need name. need refactor later.
This function sums the time but allows parallel execution . Layer dependencies and layer_list are LayerSpec objects . Here we only need name . need refactor later .
def _sum_with_parallel(layer_dependencies, layer_list, times):
    assert len(layer_list) == len(times)
    layers_to_times = dict()
    for i, l in enumerate(layer_list):
        t = times[i]
        if isinstance(t, TimeMeasure):
            t = t.total_time
        layers_to_times[l.name] = t
    lower_bound, upper_bound = 0, 0
    for block in layer_dependencies:
        if isinstance(block, tuple):
            parallel_times = []
            for sequence in block:
                sum_of_time = sum(
                    [layers_to_times.get(l.name, 0) for l in sequence])
                parallel_times.append(sum_of_time)
            lower_bound += max(parallel_times)
            upper_bound += sum(parallel_times)
        else:
            lower_bound += layers_to_times.get(block.name, 0)
            upper_bound += layers_to_times.get(block.name, 0)
    return lower_bound, upper_bound
def _sum_with_parallel ( layer_dependencies , layer_list , times ) : assert len ( layer_list ) == len ( times ) layers_to_times = dict ( ) for i , l in enumerate ( layer_list ) : t = times [ i ] if isinstance ( t , TimeMeasure ) : t = t . total_time layers_to_times [ l . name ] = t lower_bound , upper_bound = 0 , 0 for block in layer_dependencies : if isinstance ( block , tuple ) : parallel_times = [ ] for sequence in block : sum_of_time = sum ( [ layers_to_times . get ( l . name , 0 ) for l in sequence ] ) parallel_times . append ( sum_of_time ) lower_bound += max ( parallel_times ) upper_bound += sum ( parallel_times ) else : lower_bound += layers_to_times . get ( block . name , 0 ) upper_bound += layers_to_times . get ( block . name , 0 ) return lower_bound , upper_bound
This function sums the time but allows parallel execution.
This function sums the time but allows parallel execution .
"""This function sums the time but allows parallel execution.
    Layer dependencies and layer_list are LayerSpec objects.
    Here we only need name. need refactor later.
    """ # Parallel nodes, each element in the tuple shall be a list.
layer_dependencies
layer_list
times