aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mac_specific.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-05-13 05:16:37 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-05-13 05:16:37 +0000
commitb08500cec8a791ef20082628b49b17df833f5dda (patch)
tree2d09f3ca93139f082b88463f3a2a43a4ac45526f /modules/mac_specific.py
parent5ab7f213bec2f816f9c5644becb32eb72c8ffb89 (diff)
parent231562ea13e4f697953bdbabd6b76b22a88c587b (diff)
downloadstable-diffusion-webui-gfx803-b08500cec8a791ef20082628b49b17df833f5dda.tar.gz
stable-diffusion-webui-gfx803-b08500cec8a791ef20082628b49b17df833f5dda.tar.bz2
stable-diffusion-webui-gfx803-b08500cec8a791ef20082628b49b17df833f5dda.zip
Merge branch 'release_candidate'
Diffstat (limited to 'modules/mac_specific.py')
-rw-r--r--modules/mac_specific.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/mac_specific.py b/modules/mac_specific.py
index 6fe8dea0..40ce2101 100644
--- a/modules/mac_specific.py
+++ b/modules/mac_specific.py
@@ -54,6 +54,11 @@ if has_mps:
CondFunc('torch.cumsum', cumsum_fix_func, None)
CondFunc('torch.Tensor.cumsum', cumsum_fix_func, None)
CondFunc('torch.narrow', lambda orig_func, *args, **kwargs: orig_func(*args, **kwargs).clone(), None)
- if version.parse(torch.__version__) == version.parse("2.0"):
+
# 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 *args, **kwargs: len(args) == 6)
+ 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/pytorch/pytorch/issues/92311
+ if platform.processor() == 'i386':
+ for funcName in ['torch.argmax', 'torch.Tensor.argmax']:
+ CondFunc(funcName, lambda _, input, *args, **kwargs: torch.max(input.float() if input.dtype == torch.int64 else input, *args, **kwargs)[1], lambda _, input, *args, **kwargs: input.device.type == 'mps') \ No newline at end of file