MCPcopy Create free account
hub / github.com/EverMind-AI/MSA / get_seq_length

Method get_seq_length

src/utils/cache.py:282–298  ·  view source on GitHub ↗

返回缓存状态的序列长度 Args: layer_idx: 可选的层索引 Returns: int: 序列长度

(self, layer_idx=0)

Source from the content-addressed store, hash-verified

280 return keys_to_return, values_to_return
281
282 def get_seq_length(self, layer_idx=0) -> int:
283 """
284 返回缓存状态的序列长度
285
286 Args:
287 layer_idx: 可选的层索引
288
289 Returns:
290 int: 序列长度
291 """
292 is_empty_layer = (
293 len(self._quantized_key_cache) == 0 # no cache in any layer
294 or len(self._quantized_key_cache) <= layer_idx # skipped `layer_idx` and hasn't run a layer with cache after it
295 or not self._quantized_key_cache[layer_idx].numel() # the layer has no cache
296 )
297 layer_seq_length = self._quantized_key_cache[layer_idx].shape[-2] if not is_empty_layer else 0
298 return layer_seq_length
299
300 def clear_query(self):
301 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected