Skip to content

Commit 9620313

Browse files
committed
add docstring
1 parent 167cc6b commit 9620313

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/transformers/cache_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def __getitem__(self, key: int) -> List[Tuple[torch.Tensor]]:
2222
raise KeyError(f"Cache only supports 0 (key) and 1 (value) indexing, got {key}")
2323

2424
def __iter__(self):
25+
"""
26+
Support for backwards-compatible `past_key_value` iteration, e.g. `for x in past_key_value:` to iterate over
27+
keys and values
28+
"""
2529
yield self.key_cache
2630
yield self.value_cache
2731

0 commit comments

Comments
 (0)