Inserts key-value pairs into the cache using the selected caching policy algorithm to remove old key-value pairs if it is full. Parameters ---------- keys : Tensor The keys to insert to the cache. values : Tensor The values to insert t
(self, keys, values, offsets=None, offset=0)
| 150 | return values |
| 151 | |
| 152 | def replace(self, keys, values, offsets=None, offset=0): |
| 153 | """Inserts key-value pairs into the cache using the selected caching |
| 154 | policy algorithm to remove old key-value pairs if it is full. |
| 155 | |
| 156 | Parameters |
| 157 | ---------- |
| 158 | keys : Tensor |
| 159 | The keys to insert to the cache. |
| 160 | values : Tensor |
| 161 | The values to insert to the cache. |
| 162 | offsets : Tensor, optional |
| 163 | The partition offsets of the keys. |
| 164 | offset : int |
| 165 | The offset to be added to the keys. Default is 0. |
| 166 | """ |
| 167 | positions, pointers, offsets = self._policy.replace( |
| 168 | keys, offsets, offset |
| 169 | ) |
| 170 | self._cache.replace(positions, values) |
| 171 | self._policy.writing_completed(pointers, offsets) |
| 172 | |
| 173 | @property |
| 174 | def miss_rate(self): |
no outgoing calls