MCPcopy Create free account
hub / github.com/BICLab/SpikingBrain-7B / from_legacy_cache

Method from_legacy_cache

hf_7B_model/cache.py:128–139  ·  view source on GitHub ↗

Converts a cache in the legacy cache format into an equivalent `Cache`.

(
        cls,
        past_key_values: Optional[Tuple[torch.Tensor]] = None,
        seen_tokens: int = 0
    )

Source from the content-addressed store, hash-verified

126
127 @classmethod
128 def from_legacy_cache(
129 cls,
130 past_key_values: Optional[Tuple[torch.Tensor]] = None,
131 seen_tokens: int = 0
132 ) -> Cache:
133 """Converts a cache in the legacy cache format into an equivalent `Cache`."""
134
135 cache = cls(seen_tokens)
136 if past_key_values is not None:
137 for layer_idx in range(len(past_key_values)):
138 cache.states.append(past_key_values[layer_idx])
139 return cache

Callers 2

forwardMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected