1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

fix incorrect attention head dimension in AttnProcessor2_0 (#4154)

fix inner_dim
This commit is contained in:
Allen Zhang
2023-07-20 08:40:50 -07:00
committed by GitHub
parent 6b1abba18d
commit 930c8fdcb7

View File

@@ -1096,7 +1096,6 @@ class AttnProcessor2_0:
batch_size, sequence_length, _ = (
hidden_states.shape if encoder_hidden_states is None else encoder_hidden_states.shape
)
inner_dim = hidden_states.shape[-1]
if attention_mask is not None:
attention_mask = attn.prepare_attention_mask(attention_mask, sequence_length, batch_size)
@@ -1117,6 +1116,7 @@ class AttnProcessor2_0:
key = attn.to_k(encoder_hidden_states)
value = attn.to_v(encoder_hidden_states)
inner_dim = key.shape[-1]
head_dim = inner_dim // attn.heads
query = query.view(batch_size, -1, attn.heads, head_dim).transpose(1, 2)