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
5786b0e2
Unverified
Commit
5786b0e2
authored
Nov 08, 2022
by
Suraj Patil
Committed by
GitHub
Nov 08, 2022
Browse files
handle dtype xformers attention (#1196)
handle dtype xformers
parent
32b0736d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
src/diffusers/models/attention.py
src/diffusers/models/attention.py
+2
-0
No files found.
src/diffusers/models/attention.py
View file @
5786b0e2
...
@@ -492,6 +492,8 @@ class CrossAttention(nn.Module):
...
@@ -492,6 +492,8 @@ class CrossAttention(nn.Module):
# attention, what we cannot get enough of
# attention, what we cannot get enough of
if
self
.
_use_memory_efficient_attention_xformers
:
if
self
.
_use_memory_efficient_attention_xformers
:
hidden_states
=
self
.
_memory_efficient_attention_xformers
(
query
,
key
,
value
)
hidden_states
=
self
.
_memory_efficient_attention_xformers
(
query
,
key
,
value
)
# Some versions of xformers return output in fp32, cast it back to the dtype of the input
hidden_states
=
hidden_states
.
to
(
query
.
dtype
)
else
:
else
:
if
self
.
_slice_size
is
None
or
query
.
shape
[
0
]
//
self
.
_slice_size
==
1
:
if
self
.
_slice_size
is
None
or
query
.
shape
[
0
]
//
self
.
_slice_size
==
1
:
hidden_states
=
self
.
_attention
(
query
,
key
,
value
)
hidden_states
=
self
.
_attention
(
query
,
key
,
value
)
...
...
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