Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
e12a26c2
Commit
e12a26c2
authored
Dec 02, 2023
by
AUTOMATIC1111
Committed by
GitHub
Dec 02, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14046 from hidenorly/AddFP32FallbackSupportOnSdVaeApprox
Add FP32 fallback support on sd_vae_approx
parents
600036d1
81c00728
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
modules/mac_specific.py
modules/mac_specific.py
+15
-0
No files found.
modules/mac_specific.py
View file @
e12a26c2
import
logging
import
logging
import
torch
import
torch
from
torch
import
Tensor
import
platform
import
platform
from
modules.sd_hijack_utils
import
CondFunc
from
modules.sd_hijack_utils
import
CondFunc
from
packaging
import
version
from
packaging
import
version
...
@@ -51,6 +52,17 @@ def cumsum_fix(input, cumsum_func, *args, **kwargs):
...
@@ -51,6 +52,17 @@ def cumsum_fix(input, cumsum_func, *args, **kwargs):
return
cumsum_func
(
input
,
*
args
,
**
kwargs
)
return
cumsum_func
(
input
,
*
args
,
**
kwargs
)
# MPS workaround for https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14046
def
interpolate_with_fp32_fallback
(
orig_func
,
*
args
,
**
kwargs
)
->
Tensor
:
try
:
return
orig_func
(
*
args
,
**
kwargs
)
except
RuntimeError
as
e
:
if
"not implemented for"
in
str
(
e
)
and
"Half"
in
str
(
e
):
input_tensor
=
args
[
0
]
return
orig_func
(
input_tensor
.
to
(
torch
.
float32
),
*
args
[
1
:],
**
kwargs
)
.
to
(
input_tensor
.
dtype
)
else
:
print
(
f
"An unexpected RuntimeError occurred: {str(e)}"
)
if
has_mps
:
if
has_mps
:
if
platform
.
mac_ver
()[
0
]
.
startswith
(
"13.2."
):
if
platform
.
mac_ver
()[
0
]
.
startswith
(
"13.2."
):
# MPS workaround for https://github.com/pytorch/pytorch/issues/95188, thanks to danieldk (https://github.com/explosion/curated-transformers/pull/124)
# MPS workaround for https://github.com/pytorch/pytorch/issues/95188, thanks to danieldk (https://github.com/explosion/curated-transformers/pull/124)
...
@@ -77,6 +89,9 @@ if has_mps:
...
@@ -77,6 +89,9 @@ if has_mps:
# MPS workaround for https://github.com/pytorch/pytorch/issues/96113
# MPS workaround for https://github.com/pytorch/pytorch/issues/96113
CondFunc
(
'torch.nn.functional.layer_norm'
,
lambda
orig_func
,
x
,
normalized_shape
,
weight
,
bias
,
eps
,
**
kwargs
:
orig_func
(
x
.
float
(),
normalized_shape
,
weight
.
float
()
if
weight
is
not
None
else
None
,
bias
.
float
()
if
bias
is
not
None
else
bias
,
eps
)
.
to
(
x
.
dtype
),
lambda
_
,
input
,
*
args
,
**
kwargs
:
len
(
args
)
==
4
and
input
.
device
.
type
==
'mps'
)
CondFunc
(
'torch.nn.functional.layer_norm'
,
lambda
orig_func
,
x
,
normalized_shape
,
weight
,
bias
,
eps
,
**
kwargs
:
orig_func
(
x
.
float
(),
normalized_shape
,
weight
.
float
()
if
weight
is
not
None
else
None
,
bias
.
float
()
if
bias
is
not
None
else
bias
,
eps
)
.
to
(
x
.
dtype
),
lambda
_
,
input
,
*
args
,
**
kwargs
:
len
(
args
)
==
4
and
input
.
device
.
type
==
'mps'
)
# MPS workaround for https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14046
CondFunc
(
'torch.nn.functional.interpolate'
,
interpolate_with_fp32_fallback
,
None
)
# MPS workaround for https://github.com/pytorch/pytorch/issues/92311
# MPS workaround for https://github.com/pytorch/pytorch/issues/92311
if
platform
.
processor
()
==
'i386'
:
if
platform
.
processor
()
==
'i386'
:
for
funcName
in
[
'torch.argmax'
,
'torch.Tensor.argmax'
]:
for
funcName
in
[
'torch.argmax'
,
'torch.Tensor.argmax'
]:
...
...
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