MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / reorder_cache

Method reorder_cache

deepspeed/utils/static_cache.py:186–191  ·  view source on GitHub ↗
(self, beam_idx: torch.LongTensor)

Source from the content-addressed store, hash-verified

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
194class DeepSpeedStaticCache:

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected