Support for backwards-compatible `past_key_value` length, e.g. `len(past_key_value)`. This value corresponds to the number of layers in the model.
(self)
| 1316 | raise KeyError(f"Cache only has {len(self)} layers, attempted to access layer with index {layer_idx}") |
| 1317 | |
| 1318 | def __len__(self): |
| 1319 | """ |
| 1320 | Support for backwards-compatible `past_key_value` length, e.g. `len(past_key_value)`. This value corresponds |
| 1321 | to the number of layers in the model. |
| 1322 | """ |
| 1323 | return len(self.self_attention_cache) |
| 1324 | |
| 1325 | def to_legacy_cache(self) -> Tuple[Tuple[torch.Tensor], Tuple[torch.Tensor]]: |
| 1326 | """Converts the `EncoderDecoderCache` instance into its equivalent in the legacy cache format.""" |
nothing calls this directly
no outgoing calls
no test coverage detected