paleo/simulation.py
def _profile_for_batch_size(layer_list,
                            direction,
                            device,
                            batch_size,
                            use_only_gemm,
                            ppp_comp,
                            ppp_comm,
                            cross_device_bandwidth=None):
    """Use flops profiler to estiamte execution with under the given spec."""
    logger.debug('Profile for\n  pass: %s\n  device: %s\n  batch size: %s' %
                 (direction, device.name, batch_size))
    times = []
    params_in_bytes = 0

    # Estimate forward time for each layer.
    for layer_spec in layer_list:
        layer = layer_spec.layer_op
        if batch_size:
            layer.batch_size = batch_size

        options = profilers.ProfilerOptions()
        options.direction = direction
        options.gradient_wrt = None
        if use_only_gemm:
            options.use_cudnn_heuristics = False
        # FIXME: we don't include bias and activation for simplicity.
        options.include_bias_and_activation = False
        options.ppp_comp = ppp_comp
        options.ppp_comm = ppp_comm
        flops_profiler = profilers.FlopsProfiler(options, device)

        layer_time = flops_profiler.profile(
            layer, layer_spec.device_id,
            [p.device_id for p in layer_spec.parents], cross_device_bandwidth)
        params_in_bytes += layer.weights_in_bytes
        times.append(layer_time)

    return times, params_in_bytes
Use flops profiler to estiamte execution with under the given spec.
Use flops profiler to estiamte execution with under the given spec.
Use flops profiler to estiamte execution with under the given spec .
def _profile_for_batch_size(layer_list,
                            direction,
                            device,
                            batch_size,
                            use_only_gemm,
                            ppp_comp,
                            ppp_comm,
                            cross_device_bandwidth=None):
    logger.debug('Profile for\n  pass: %s\n  device: %s\n  batch size: %s' %
                 (direction, device.name, batch_size))
    times = []
    params_in_bytes = 0
    for layer_spec in layer_list:
        layer = layer_spec.layer_op
        if batch_size:
            layer.batch_size = batch_size
        options = profilers.ProfilerOptions()
        options.direction = direction
        options.gradient_wrt = None
        if use_only_gemm:
            options.use_cudnn_heuristics = False
        options.include_bias_and_activation = False
        options.ppp_comp = ppp_comp
        options.ppp_comm = ppp_comm
        flops_profiler = profilers.FlopsProfiler(options, device)
        layer_time = flops_profiler.profile(
            layer, layer_spec.device_id,
            [p.device_id for p in layer_spec.parents], cross_device_bandwidth)
        params_in_bytes += layer.weights_in_bytes
        times.append(layer_time)
    return times, params_in_bytes
def _profile_for_batch_size ( layer_list , direction , device , batch_size , use_only_gemm , ppp_comp , ppp_comm , cross_device_bandwidth = None ) : logger . debug ( 'Profile for\n  pass: %s\n  device: %s\n  batch size: %s' % ( direction , device . name , batch_size ) ) times = [ ] params_in_bytes = 0 for layer_spec in layer_list : layer = layer_spec . layer_op if batch_size : layer . batch_size = batch_size options = profilers . ProfilerOptions ( ) options . direction = direction options . gradient_wrt = None if use_only_gemm : options . use_cudnn_heuristics = False options . include_bias_and_activation = False options . ppp_comp = ppp_comp options . ppp_comm = ppp_comm flops_profiler = profilers . FlopsProfiler ( options , device ) layer_time = flops_profiler . profile ( layer , layer_spec . device_id , [ p . device_id for p in layer_spec . parents ] , cross_device_bandwidth ) params_in_bytes += layer . weights_in_bytes times . append ( layer_time ) return times , params_in_bytes
Use flops profiler to estiamte execution with under the given spec.
Use flops profiler to estiamte execution with under the given spec .
"""Use flops profiler to estiamte execution with under the given spec.""" # Estimate forward time for each layer. # FIXME: we don't include bias and activation for simplicity.
layer_list
direction
device
batch_size
use_only_gemm
ppp_comp
ppp_comm
cross_device_bandwidth