(
self,
input_ids: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
past_key_values: Optional[Tuple[torch.FloatTensor]] = None,
return_last_logit: Optional[bool] = False,
**kw_args
)
| 104 | } |
| 105 | |
| 106 | def forward( |
| 107 | self, |
| 108 | input_ids: Optional[torch.Tensor] = None, |
| 109 | position_ids: Optional[torch.Tensor] = None, |
| 110 | attention_mask: Optional[torch.Tensor] = None, |
| 111 | past_key_values: Optional[Tuple[torch.FloatTensor]] = None, |
| 112 | return_last_logit: Optional[bool] = False, |
| 113 | **kw_args |
| 114 | ): |
| 115 | outputs = self.model( |
| 116 | input_ids=input_ids, |
| 117 | position_ids=position_ids, |
| 118 | attention_mask=attention_mask, |
| 119 | past_key_values=past_key_values, |
| 120 | ) |
| 121 | |
| 122 | lm_logits = outputs[0] |
| 123 | if return_last_logit: |
| 124 | lm_logits = lm_logits[:, -1:] |
| 125 | past_key_values = [x['past_key_values'] for x in outputs[1:]] |
| 126 | |
| 127 | return CausalLMOutputWithPast( |
| 128 | logits=lm_logits, |
| 129 | past_key_values=past_key_values |
| 130 | ) |
| 131 | |
| 132 | @staticmethod |
| 133 | def _reorder_cache( |
nothing calls this directly
no outgoing calls
no test coverage detected