(self, num_tokentypes=0, parallel_output=True)
| 37 | """GPT-2 Language model.""" |
| 38 | |
| 39 | def __init__(self, num_tokentypes=0, parallel_output=True): |
| 40 | super(GPT2Model, self).__init__() |
| 41 | args = get_args() |
| 42 | |
| 43 | self.parallel_output = parallel_output |
| 44 | self.fp16_lm_cross_entropy = args.fp16_lm_cross_entropy |
| 45 | |
| 46 | self.language_model, self._language_model_key = get_language_model( |
| 47 | attention_mask_func=gpt2_attention_mask_func, |
| 48 | num_tokentypes=num_tokentypes, |
| 49 | add_pooler=False, |
| 50 | init_method=init_method_normal(args.init_method_std), |
| 51 | scaled_init_method=scaled_init_method_normal(args.init_method_std, |
| 52 | args.num_layers)) |
| 53 | |
| 54 | |
| 55 | def forward(self, input_ids, position_ids, attention_mask, labels=None, |
nothing calls this directly
no test coverage detected