コード例 #1
0
def validate_simrd_config(config_dir):
    config = read_config(config_dir)
    return check_config(config, {
            "log_dest": "~/dtr_nightly_logs",
            "save_logs" : True,
            "simrd_config" : "sim_conf.json",
            "models": {
                "lstm",
                "resnet32",
                "treelstm",
                "densenet100",
                "unet",
                "resnet1202"
            },
            "simrd_experiments" : {
                "pareto",
                "ablation",
                "banishing"
            },
            "dtr_torch_cmd": "~/dtr_venv/bin/python3",
            "dry_run": 10,
            "n_inputs": 1,
            "n_reps": 50,
        }, {
            'models': MODELS
        }, {
            'dtr_torch_cmd': string_cond(),
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond(),
            'save_logs': bool_cond(),
            'log_dest': string_cond()
        })
コード例 #2
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)

    config, msg = check_config(config, {
        'n_times_per_input': 4,
        'num_reps': 3,
        'timeout': 300
    }, {
        'models': {'resnet18_v1'},
        'devices': {'vta', 'arm_cpu'},
        'targets': {'pynq', 'sim', 'tsim'}
    }, {
        'tracker_host': string_cond(),
        'tracker_port': non_negative_cond(),
        'n_times_per_input': non_negative_cond(),
        'num_reps': non_negative_cond(),
        'timeout': non_negative_cond()
    })

    return config, msg
コード例 #3
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)

    # turn passes into tuples so they are hashable
    # turn strings into singletons for consistency
    if 'passes' in config:
        passes = []
        for pass_entry in config['passes']:
            opt_level = 0
            pass_list = ()
            if isinstance(pass_entry, list):
                if len(pass_entry) > 0:
                    opt_level = pass_entry[0]
                if len(pass_entry) > 1:
                    list_entry = pass_entry[1]
                    if isinstance(list_entry, str) and list_entry != '':
                        pass_list = (list_entry,)
                    if isinstance(list_entry, list):
                        pass_list = tuple(list_entry)
            new_entry = (opt_level, pass_list)
            passes.append(new_entry)
        config['passes'] = passes

    return check_config(
        config,
        {
            'devices': {'cpu', 'gpu'},
            'dry_run': 8,
            'n_inputs': 3,
            'n_times_per_input': 10,
            'batch_sizes': {1},
            'networks': {'resnet-18', 'mobilenet', 'nature-dqn', 'vgg-16'},
            'passes': {(3, pass_name) for pass_name in VALID_PASSES},
            'set_seed': False,
            'seed': 0
        },
        {
            'devices': {'cpu', 'gpu'},
            'networks': {'resnet-18', 'mobilenet', 'nature-dqn', 'vgg-16'}
        },
        {
            'passes': valid_pass_spec_cond(),
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'batch_sizes': non_negative_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond()
        }
    )
コード例 #4
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)
    ret, msg = check_config(
        config, {
            'dry_run': 8,
            'n_inputs': 1,
            'n_times_per_input': 100,
            'inputs': [string.ascii_uppercase],
            'devices': ['cpu'],
            'hidden_sizes': [16],
            'frameworks': {'pt', 'relay'},
            'relay_methods': {'intp', 'aot'},
            'relay_configs': {'loop', 'cell'},
            'languages': {
                'Arabic', 'Chinese', 'Czech', 'Dutch', 'English', 'French',
                'German', 'Greek', 'Irish', 'Italian', 'Japanese', 'Korean',
                'Polish', 'Portuguese', 'Russian', 'Scottish', 'Spanish',
                'Vietnamese'
            },
            'set_seed': False,
            'seed': 0
        }, {
            'devices': {'cpu'},
            'frameworks': {'pt', 'relay'},
            'relay_methods': {'intp', 'aot'},
            'relay_configs': {'loop', 'cell'},
            'languages': {
                'Arabic', 'Chinese', 'Czech', 'Dutch', 'English', 'French',
                'German', 'Greek', 'Irish', 'Italian', 'Japanese', 'Korean',
                'Polish', 'Portuguese', 'Russian', 'Scottish', 'Spanish',
                'Vietnamese'
            }
        }, {
            'hidden_sizes': non_negative_cond(),
            'inputs': string_cond(),
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond()
        })

    # also must ensure that if relay is enabled that a method and config is specified
    if ret is not None and 'relay' in ret['frameworks']:
        if not ret['relay_methods'] or not ret['relay_configs']:
            return None, 'If Relay is enabled, then at least one method or config must be specified'

    return ret, msg
コード例 #5
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)
    return check_config(
        config,
        {
            'dry_run': 8,
            'n_inputs': 3,
            'n_times_per_input': 100,
            'models': {'resnet32'},
            'batch_size': [8],
            'dtr_torch_cmd': 'python3',
            'methods': {'baseline'},
            'save_logs': False,
            'log_dest': '/dev/null',
            'report_errors': False,
            'set_seed': False,
            'seed': 0
        },
        {
            'models': {
                'resnet20', 'resnet32', 'resnet44', 'resnet56', 'resnet110', 'resnet1202',
                'densenet100',
                'unet', 'lstm_encoder', 'lstm', 'gru', 'gru_encoder', 'treelstm', 'treelstm_old', 'unroll_gan'},
            'methods': {'baseline', 'dtr'}
        },
        {
            'batch_size': non_negative_cond(),
            'dtr_torch_cmd': string_cond(),
            'methods': string_cond(),
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'report_errors': bool_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond(),
            'save_logs': bool_cond(),
            'log_dest': string_cond()
        }
    )
コード例 #6
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)
    return check_config(
        config, {
            'devices': {'cpu', 'gpu'},
            'dry_run': 8,
            'n_inputs': 3,
            'n_times_per_input': 10,
            'batch_sizes': {1},
            'opt_levels': {0, 1, 2, 3, 4},
            'networks': {'resnet-18', 'mobilenet', 'nature-dqn', 'vgg-16'},
            'set_seed': False,
            'seed': 0
        }, {
            'devices': {'cpu', 'gpu'},
            'opt_levels': {0, 1, 2, 3, 4},
            'networks': {'resnet-18', 'mobilenet', 'nature-dqn', 'vgg-16'}
        }, {
            'opt_levels': non_negative_cond(),
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'batch_sizes': non_negative_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond()
        })
コード例 #7
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)
    # need to turn into tuples so they are hashable
    config['datasets'] = [tuple(pair) for pair in config['datasets']]
    ret, msg = check_config(
        config, {
            'dry_run': 8,
            'n_inputs': 1,
            'n_times_per_input': 100,
            'devices': {'cpu'},
            'frameworks': {'pt', 'relay'},
            'relay_methods': {'intp', 'aot'},
            'set_seed': False,
            'seed': 0
        }, {
            'devices': {'cpu'},
            'frameworks': {'pt', 'relay'},
            'relay_methods': {'intp', 'aot'}
        }, {
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'datasets': valid_dataset_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond()
        })

    # also must ensure that if relay is enabled that a method is specified
    if ret is not None and 'relay' in ret['frameworks']:
        if not ret['relay_methods']:
            return None, 'Relay is enabled but no method is specified'

    return ret, msg
コード例 #8
0
def validate(config_dir):
    """
    Reads config.json in the config_dir and prepopulates with default values.
    Ensures that all configured values are of the appropriate types.

    Returns (config, message to report if error). Returns None if something
    is wrong with the config it read.
    """
    config = read_config(config_dir)
    ret, msg = check_config(
        config, {
            'dry_run': 8,
            'n_inputs': 1,
            'n_times_per_input': 100,
            'devices': {'cpu'},
            'frameworks': {'mxnet', 'relay'},
            'relay_methods': {'intp', 'aot'},
            'networks': {'rnn', 'lstm', 'gru'},
            'set_seed': False,
            'seed': 0
        }, {
            'devices': {'cpu'},
            'frameworks': {'mxnet', 'relay'},
            'relay_methods': {'intp', 'aot'},
            'networks': {'rnn', 'lstm', 'gru'}
        }, {
            'dry_run': non_negative_cond(),
            'n_inputs': non_negative_cond(),
            'n_times_per_input': non_negative_cond(),
            'set_seed': bool_cond(),
            'seed': non_negative_cond()
        })

    # also must ensure that if relay is enabled that a method is specified
    if ret is not None and 'relay' in ret['frameworks']:
        if not ret['relay_methods']:
            return None, 'If Relay is enabled, then at least one method must be specified'

    return ret, msg