Skip to content

Commit

Permalink
fix a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gante committed Jan 13, 2025
1 parent 1e73aae commit cf263b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/cache_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ def get_seq_length(self, layer_idx: Optional[int] = None) -> int:
The sequence length of the cached state.
"""
if layer_idx is None:
if len(self) > 0:
return max([self.get_seq_length(layer_idx) for layer_idx in range(len(self))])
if len(self.key_cache) > 0:
return max([self.get_seq_length(layer_idx) for layer_idx in range(len(self.key_cache))])
else:
return 0

Expand Down

0 comments on commit cf263b8

Please sign in to comment.