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
6908f9c9
"examples/vscode:/vscode.git/clone" did not exist on "97ee616971dd61526a4c7e071e9f88a183781037"
Commit
6908f9c9
authored
Apr 22, 2023
by
comfyanonymous
Browse files
This makes pytorch2.0 attention perform a bit faster.
parent
989acd76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
comfy/ldm/modules/attention.py
comfy/ldm/modules/attention.py
+2
-9
No files found.
comfy/ldm/modules/attention.py
View file @
6908f9c9
...
...
@@ -455,11 +455,7 @@ class CrossAttentionPytorch(nn.Module):
b
,
_
,
_
=
q
.
shape
q
,
k
,
v
=
map
(
lambda
t
:
t
.
unsqueeze
(
3
)
.
reshape
(
b
,
t
.
shape
[
1
],
self
.
heads
,
self
.
dim_head
)
.
permute
(
0
,
2
,
1
,
3
)
.
reshape
(
b
*
self
.
heads
,
t
.
shape
[
1
],
self
.
dim_head
)
.
contiguous
(),
lambda
t
:
t
.
view
(
b
,
-
1
,
self
.
heads
,
self
.
dim_head
).
transpose
(
1
,
2
),
(
q
,
k
,
v
),
)
...
...
@@ -468,10 +464,7 @@ class CrossAttentionPytorch(nn.Module):
if
exists
(
mask
):
raise
NotImplementedError
out
=
(
out
.
unsqueeze
(
0
)
.
reshape
(
b
,
self
.
heads
,
out
.
shape
[
1
],
self
.
dim_head
)
.
permute
(
0
,
2
,
1
,
3
)
.
reshape
(
b
,
out
.
shape
[
1
],
self
.
heads
*
self
.
dim_head
)
out
.
transpose
(
1
,
2
).
reshape
(
b
,
-
1
,
self
.
heads
*
self
.
dim_head
)
)
return
self
.
to_out
(
out
)
...
...
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