| 7 | /// Abstraction over cosine and sine tables, kv-caching and attention masking. |
| 8 | #[derive(Debug, Clone)] |
| 9 | pub struct Cache { |
| 10 | cos: Tensor, |
| 11 | sin: Tensor, |
| 12 | |
| 13 | masks: HashMap<usize, Tensor>, |
| 14 | use_kv_cache: bool, |
| 15 | kvs: Vec<Option<(Tensor, Tensor)>>, |
| 16 | max_seq_len: usize, |
| 17 | |
| 18 | /// Recurrent state matrices for linear attention layers (Gated DeltaNet). |
| 19 | /// Shape per entry: (batch=1, num_heads, key_dim, value_dim). |
| 20 | recurrent_states: Vec<Option<Tensor>>, |
| 21 | /// Conv1d history for linear attention layers. |
| 22 | /// Shape per entry: (batch=1, channels, kernel_size-1). |
| 23 | conv_states: Vec<Option<Tensor>>, |
| 24 | |
| 25 | device: Device, |
| 26 | } |
| 27 | |
| 28 | impl Cache { |
| 29 | /// Creates a new cache instance with the provided configuration. |
nothing calls this directly
no outgoing calls
no test coverage detected