(self, bsize, device, dtype, length:int=None)
| 366 | self.load_state_dict(checkpoint) |
| 367 | |
| 368 | def init_cache(self, bsize, device, dtype, length:int=None): |
| 369 | if self.cache_shape is None: |
| 370 | return |
| 371 | cache_shape = self.cache_shape.copy() |
| 372 | cache_shape[1] = length or cache_shape[1] |
| 373 | self.cache = T.full((bsize, *cache_shape), CACHE_FILL_VALUE, device=device, dtype=dtype).transpose(0, 1) |
| 374 | |
| 375 | def deinit_cache(self): |
| 376 | self.cache = [None] * len(self.cache) |