From ed9d3d93cc17d4f909b36266975b16a973f598ef Mon Sep 17 00:00:00 2001 From: AI-Casanova <54461896+AI-Casanova@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:09:31 -0600 Subject: [PATCH] Fix Long Prompts `extend` to `repeat` Extend only works on singleton dimensions, mia culpa. --- modules/prompt_parser_diffusers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prompt_parser_diffusers.py b/modules/prompt_parser_diffusers.py index 1bb61c265..d30f95fb7 100644 --- a/modules/prompt_parser_diffusers.py +++ b/modules/prompt_parser_diffusers.py @@ -152,7 +152,7 @@ def pad_to_same_length(pipe, embeds): empty_embed = pipe.encode_prompt("", device, 1, False) max_token_count = max([embed.shape[1] for embed in embeds]) repeats = max_token_count - min([embed.shape[1] for embed in embeds]) - empty_batched = empty_embed[0].to(embeds[0].device).expand(embeds[0].shape[0], repeats, -1) + empty_batched = empty_embed[0].to(embeds[0].device).repeat(embeds[0].shape[0], repeats // empty_embed[0].shape[1], 1) for i, embed in enumerate(embeds): if embed.shape[1] < max_token_count: embed = torch.cat([embed, empty_batched], dim=1)