Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
b6cc0502
Commit
b6cc0502
authored
Apr 07, 2023
by
William Berman
Committed by
Will Berman
Apr 09, 2023
Browse files
fix simple attention processor encoder hidden states ordering
parent
0cbefefa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
4 deletions
+3
-4
src/diffusers/models/attention_processor.py
src/diffusers/models/attention_processor.py
+0
-2
src/diffusers/pipelines/unclip/text_proj.py
src/diffusers/pipelines/unclip/text_proj.py
+2
-2
tests/pipelines/unclip/test_unclip_image_variation.py
tests/pipelines/unclip/test_unclip_image_variation.py
+1
-0
No files found.
src/diffusers/models/attention_processor.py
View file @
b6cc0502
...
...
@@ -400,7 +400,6 @@ class AttnAddedKVProcessor:
residual
=
hidden_states
hidden_states
=
hidden_states
.
view
(
hidden_states
.
shape
[
0
],
hidden_states
.
shape
[
1
],
-
1
).
transpose
(
1
,
2
)
batch_size
,
sequence_length
,
_
=
hidden_states
.
shape
encoder_hidden_states
=
encoder_hidden_states
.
transpose
(
1
,
2
)
attention_mask
=
attn
.
prepare_attention_mask
(
attention_mask
,
sequence_length
,
batch_size
)
...
...
@@ -627,7 +626,6 @@ class SlicedAttnAddedKVProcessor:
def
__call__
(
self
,
attn
:
"Attention"
,
hidden_states
,
encoder_hidden_states
=
None
,
attention_mask
=
None
):
residual
=
hidden_states
hidden_states
=
hidden_states
.
view
(
hidden_states
.
shape
[
0
],
hidden_states
.
shape
[
1
],
-
1
).
transpose
(
1
,
2
)
encoder_hidden_states
=
encoder_hidden_states
.
transpose
(
1
,
2
)
batch_size
,
sequence_length
,
_
=
hidden_states
.
shape
...
...
src/diffusers/pipelines/unclip/text_proj.py
View file @
b6cc0502
...
...
@@ -77,10 +77,10 @@ class UnCLIPTextProjModel(ModelMixin, ConfigMixin):
# extra tokens of context that are concatenated to the sequence of outputs from the GLIDE text encoder"
clip_extra_context_tokens
=
self
.
clip_extra_context_tokens_proj
(
image_embeddings
)
clip_extra_context_tokens
=
clip_extra_context_tokens
.
reshape
(
batch_size
,
-
1
,
self
.
clip_extra_context_tokens
)
clip_extra_context_tokens
=
clip_extra_context_tokens
.
permute
(
0
,
2
,
1
)
text_encoder_hidden_states
=
self
.
encoder_hidden_states_proj
(
text_encoder_hidden_states
)
text_encoder_hidden_states
=
self
.
text_encoder_hidden_states_norm
(
text_encoder_hidden_states
)
text_encoder_hidden_states
=
text_encoder_hidden_states
.
permute
(
0
,
2
,
1
)
text_encoder_hidden_states
=
torch
.
cat
([
clip_extra_context_tokens
,
text_encoder_hidden_states
],
dim
=
2
)
text_encoder_hidden_states
=
torch
.
cat
([
clip_extra_context_tokens
,
text_encoder_hidden_states
],
dim
=
1
)
return
text_encoder_hidden_states
,
additive_clip_time_embeddings
tests/pipelines/unclip/test_unclip_image_variation.py
View file @
b6cc0502
...
...
@@ -54,6 +54,7 @@ class UnCLIPImageVariationPipelineFastTests(PipelineTesterMixin, unittest.TestCa
"decoder_num_inference_steps"
,
"super_res_num_inference_steps"
,
]
test_xformers_attention
=
False
@
property
def
text_embedder_hidden_size
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment