MCPcopy Create free account
hub / github.com/pytorch/executorch / _install_cache

Function _install_cache

backends/mlx/llm/source_transformation.py:129–141  ·  view source on GitHub ↗
(attr_name)

Source from the content-addressed store, hash-verified

127 )
128
129 def _install_cache(attr_name):
130 setattr(module, attr_name, mlx_cache)
131 for i, (cache_layer, layer_cache) in enumerate(
132 zip(mlx_cache.layers, mlx_cache.kv_cache)
133 ):
134 setattr(module, f"key_cache_{i}", layer_cache.k_cache)
135 setattr(module, f"value_cache_{i}", layer_cache.v_cache)
136 if hasattr(cache_layer, "cumulative_length"):
137 setattr(
138 module,
139 f"cumulative_length_{i}",
140 cache_layer.cumulative_length,
141 )
142
143 if hasattr(module, "static_cache"):
144 assert isinstance(

Calls

no outgoing calls

Tested by

no test coverage detected