Ensure fixed arguments for a model are the same for the input arguments and the one retreived frm checkpoint.
(checkpoint_args)
| 40 | return _CHECKPOINT_VERSION |
| 41 | |
| 42 | def check_checkpoint_args(checkpoint_args): |
| 43 | """Ensure fixed arguments for a model are the same for the input |
| 44 | arguments and the one retreived frm checkpoint.""" |
| 45 | args = get_args() |
| 46 | |
| 47 | def _compare(arg_name): |
| 48 | checkpoint_value = getattr(checkpoint_args, arg_name) |
| 49 | args_value = getattr(args, arg_name) |
| 50 | error_message = '{} value from checkpoint ({}) is not equal to the ' \ |
| 51 | 'input argument value ({}).'.format( |
| 52 | arg_name, checkpoint_value, args_value) |
| 53 | assert checkpoint_value == args_value, error_message |
| 54 | |
| 55 | _compare('num_layers') |
| 56 | _compare('hidden_size') |
| 57 | _compare('num_attention_heads') |
| 58 | _compare('max_position_embeddings') |
| 59 | _compare('make_vocab_size_divisible_by') |
| 60 | _compare('padded_vocab_size') |
| 61 | _compare('tokenizer_type') |
| 62 | _compare('model_parallel_size') |
| 63 | |
| 64 | |
| 65 | def ensure_directory_exists(filename): |
no test coverage detected