anima alternating prompts

This commit is contained in:
Haoming 2026-04-29 19:52:51 +08:00
parent a0233138a3
commit 8bb3db1875

View File

@ -78,13 +78,13 @@ class AnimaTextProcessingEngine:
def __call__(self, texts):
zs = []
cache = {}
cache: dict[str, tuple[torch.Tensor, torch.Tensor, torch.Tensor]] = {}
self.emphasis = emphasis.get_current_option(opts.emphasis)()
for line in texts:
if line in cache:
z = cache[line]
z, tok, mul = cache[line]
else:
chunks: list[PromptChunk] = self.tokenize_line(line)
assert len(chunks) == 1
@ -94,17 +94,14 @@ class AnimaTextProcessingEngine:
multipliers = chunk.qwen_multipliers
z: torch.Tensor = self.process_tokens([tokens], [multipliers])[0]
tok = torch.tensor(chunk.t5_tokens, dtype=torch.int)
mul = torch.tensor(chunk.t5_multipliers)
cache[line] = z
cache[line] = (z, tok, mul)
zs.append(
self.anima_preprocess(
z,
torch.tensor(chunk.t5_tokens, dtype=torch.int),
torch.tensor(chunk.t5_multipliers),
)
)
zs.append(self.anima_preprocess(z, tok, mul))
del cache
return zs
def anima_preprocess(self, cross_attn: torch.Tensor, t5xxl_ids: torch.Tensor, t5xxl_weights: torch.Tensor) -> torch.Tensor: