ctx: [B, S_ctx, dim] —— 经过 text_embedding 之后的上下文
(self, ctx: torch.Tensor)
| 408 | |
| 409 | @torch.no_grad() |
| 410 | def init_cache(self, ctx: torch.Tensor): |
| 411 | """ctx: [B, S_ctx, dim] —— 经过 text_embedding 之后的上下文""" |
| 412 | self.cache_k = self.norm_k(self.k(ctx)) |
| 413 | self.cache_v = self.v(ctx) |
| 414 | |
| 415 | def clear_cache(self): |
| 416 | self.cache_k = None |