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
OpenDAS
diffusers
Commits
dd3cae33
Unverified
Commit
dd3cae33
authored
Feb 01, 2023
by
Asad Memon
Committed by
GitHub
Feb 01, 2023
Browse files
Pass LoRA rank to LoRALinearLayer (#2191)
parent
f73d0b6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/diffusers/models/cross_attention.py
src/diffusers/models/cross_attention.py
+8
-8
No files found.
src/diffusers/models/cross_attention.py
View file @
dd3cae33
...
@@ -296,10 +296,10 @@ class LoRACrossAttnProcessor(nn.Module):
...
@@ -296,10 +296,10 @@ class LoRACrossAttnProcessor(nn.Module):
def
__init__
(
self
,
hidden_size
,
cross_attention_dim
=
None
,
rank
=
4
):
def
__init__
(
self
,
hidden_size
,
cross_attention_dim
=
None
,
rank
=
4
):
super
().
__init__
()
super
().
__init__
()
self
.
to_q_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
)
self
.
to_q_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
,
rank
)
self
.
to_k_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
)
self
.
to_k_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
,
rank
)
self
.
to_v_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
)
self
.
to_v_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
,
rank
)
self
.
to_out_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
)
self
.
to_out_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
,
rank
)
def
__call__
(
def
__call__
(
self
,
attn
:
CrossAttention
,
hidden_states
,
encoder_hidden_states
=
None
,
attention_mask
=
None
,
scale
=
1.0
self
,
attn
:
CrossAttention
,
hidden_states
,
encoder_hidden_states
=
None
,
attention_mask
=
None
,
scale
=
1.0
...
@@ -408,10 +408,10 @@ class LoRAXFormersCrossAttnProcessor(nn.Module):
...
@@ -408,10 +408,10 @@ class LoRAXFormersCrossAttnProcessor(nn.Module):
def
__init__
(
self
,
hidden_size
,
cross_attention_dim
,
rank
=
4
):
def
__init__
(
self
,
hidden_size
,
cross_attention_dim
,
rank
=
4
):
super
().
__init__
()
super
().
__init__
()
self
.
to_q_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
)
self
.
to_q_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
,
rank
)
self
.
to_k_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
)
self
.
to_k_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
,
rank
)
self
.
to_v_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
)
self
.
to_v_lora
=
LoRALinearLayer
(
cross_attention_dim
or
hidden_size
,
hidden_size
,
rank
)
self
.
to_out_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
)
self
.
to_out_lora
=
LoRALinearLayer
(
hidden_size
,
hidden_size
,
rank
)
def
__call__
(
def
__call__
(
self
,
attn
:
CrossAttention
,
hidden_states
,
encoder_hidden_states
=
None
,
attention_mask
=
None
,
scale
=
1.0
self
,
attn
:
CrossAttention
,
hidden_states
,
encoder_hidden_states
=
None
,
attention_mask
=
None
,
scale
=
1.0
...
...
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