(self, beam_idx: torch.LongTensor)
| 184 | self.values[:, :, -count:].zero_() |
| 185 | |
| 186 | def reorder_cache(self, beam_idx: torch.LongTensor) -> None: |
| 187 | if self.is_initialized: |
| 188 | self.keys = self.keys.index_select(0, beam_idx.to(self.keys.device)) |
| 189 | self.values = self.values.index_select(0, beam_idx.to(self.values.device)) |
| 190 | if self._write_position is not None and self._write_position.dim() == 1: |
| 191 | self._write_position = self._write_position.index_select(0, beam_idx.to(self._write_position.device)) |
| 192 | |
| 193 | |
| 194 | class DeepSpeedStaticCache: |