Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
d8bc1a4e
Unverified
Commit
d8bc1a4e
authored
Jul 27, 2023
by
Patrick von Platen
Committed by
GitHub
Jul 27, 2023
Browse files
[Torch.compile] Fixes torch compile graph break (#4315)
* fix torch compile * Fix all * make style
parent
80c10d82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/diffusers/models/lora.py
src/diffusers/models/lora.py
+4
-1
No files found.
src/diffusers/models/lora.py
View file @
d8bc1a4e
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
typing
import
Optional
from
typing
import
Optional
import
torch.nn.functional
as
F
from
torch
import
nn
from
torch
import
nn
...
@@ -91,7 +92,9 @@ class LoRACompatibleConv(nn.Conv2d):
...
@@ -91,7 +92,9 @@ class LoRACompatibleConv(nn.Conv2d):
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
if
self
.
lora_layer
is
None
:
if
self
.
lora_layer
is
None
:
return
super
().
forward
(
x
)
# make sure to the functional Conv2D function as otherwise torch.compile's graph will break
# see: https://github.com/huggingface/diffusers/pull/4315
return
F
.
conv2d
(
x
,
self
.
weight
,
self
.
bias
,
self
.
stride
,
self
.
padding
,
self
.
dilation
,
self
.
groups
)
else
:
else
:
return
super
().
forward
(
x
)
+
self
.
lora_layer
(
x
)
return
super
().
forward
(
x
)
+
self
.
lora_layer
(
x
)
...
...
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