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
6a89a6c9
Unverified
Commit
6a89a6c9
authored
Nov 07, 2023
by
Dhruv Nair
Committed by
GitHub
Nov 07, 2023
Browse files
Update custom diffusion attn processor (#5663)
update custom diffusion attn processor
parent
9bafef34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
src/diffusers/models/attention_processor.py
src/diffusers/models/attention_processor.py
+6
-2
No files found.
src/diffusers/models/attention_processor.py
View file @
6a89a6c9
...
@@ -1361,6 +1361,7 @@ class CustomDiffusionXFormersAttnProcessor(nn.Module):
...
@@ -1361,6 +1361,7 @@ class CustomDiffusionXFormersAttnProcessor(nn.Module):
hidden_states
=
attn
.
to_out
[
0
](
hidden_states
)
hidden_states
=
attn
.
to_out
[
0
](
hidden_states
)
# dropout
# dropout
hidden_states
=
attn
.
to_out
[
1
](
hidden_states
)
hidden_states
=
attn
.
to_out
[
1
](
hidden_states
)
return
hidden_states
return
hidden_states
...
@@ -1433,8 +1434,11 @@ class CustomDiffusionAttnProcessor2_0(nn.Module):
...
@@ -1433,8 +1434,11 @@ class CustomDiffusionAttnProcessor2_0(nn.Module):
encoder_hidden_states
=
attn
.
norm_encoder_hidden_states
(
encoder_hidden_states
)
encoder_hidden_states
=
attn
.
norm_encoder_hidden_states
(
encoder_hidden_states
)
if
self
.
train_kv
:
if
self
.
train_kv
:
key
=
self
.
to_k_custom_diffusion
(
encoder_hidden_states
)
key
=
self
.
to_k_custom_diffusion
(
encoder_hidden_states
.
to
(
self
.
to_k_custom_diffusion
.
weight
.
dtype
))
value
=
self
.
to_v_custom_diffusion
(
encoder_hidden_states
)
value
=
self
.
to_v_custom_diffusion
(
encoder_hidden_states
.
to
(
self
.
to_v_custom_diffusion
.
weight
.
dtype
))
key
=
key
.
to
(
attn
.
to_q
.
weight
.
dtype
)
value
=
value
.
to
(
attn
.
to_q
.
weight
.
dtype
)
else
:
else
:
key
=
attn
.
to_k
(
encoder_hidden_states
)
key
=
attn
.
to_k
(
encoder_hidden_states
)
value
=
attn
.
to_v
(
encoder_hidden_states
)
value
=
attn
.
to_v
(
encoder_hidden_states
)
...
...
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