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
chenpangpang
ComfyUI
Commits
0c2c9fbd
Commit
0c2c9fbd
authored
Jan 06, 2024
by
comfyanonymous
Browse files
Support attention mask in split attention.
parent
3ad0191b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
comfy/ldm/modules/attention.py
comfy/ldm/modules/attention.py
+6
-0
No files found.
comfy/ldm/modules/attention.py
View file @
0c2c9fbd
...
...
@@ -239,6 +239,12 @@ def attention_split(q, k, v, heads, mask=None):
else
:
s1
=
einsum
(
'b i d, b j d -> b i j'
,
q
[:,
i
:
end
],
k
)
*
scale
if
mask
is
not
None
:
if
len
(
mask
.
shape
)
==
2
:
s1
+=
mask
[
i
:
end
]
else
:
s1
+=
mask
[:,
i
:
end
]
s2
=
s1
.
softmax
(
dim
=-
1
).
to
(
v
.
dtype
)
del
s1
first_op_done
=
True
...
...
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