diff options
author | unknown <mcgpapu@gmail.com> | 2023-01-30 11:12:31 +0000 |
---|---|---|
committer | unknown <mcgpapu@gmail.com> | 2023-01-30 11:12:31 +0000 |
commit | 21766a0898fd9cc344c5d100396280fa8b0c4e74 (patch) | |
tree | 2a365bb6bc60c9916004e67c04f3816880366edf /modules/devices.py | |
parent | e79b7db4b47a33889551b9266ee3277879d4f560 (diff) | |
parent | aa4688eb8345de583070ca9ddb4c6f585f06762b (diff) | |
download | stable-diffusion-webui-gfx803-21766a0898fd9cc344c5d100396280fa8b0c4e74.tar.gz stable-diffusion-webui-gfx803-21766a0898fd9cc344c5d100396280fa8b0c4e74.tar.bz2 stable-diffusion-webui-gfx803-21766a0898fd9cc344c5d100396280fa8b0c4e74.zip |
Merge branch 'master' of github.com:AUTOMATIC1111/stable-diffusion-webui into gamepad
Diffstat (limited to 'modules/devices.py')
-rw-r--r-- | modules/devices.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/devices.py b/modules/devices.py index 4687944e..655ca1d3 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -87,6 +87,14 @@ dtype_unet = torch.float16 unet_needs_upcast = False +def cond_cast_unet(input): + return input.to(dtype_unet) if unet_needs_upcast else input + + +def cond_cast_float(input): + return input.float() if unet_needs_upcast else input + + def randn(seed, shape): torch.manual_seed(seed) if device.type == 'mps': @@ -199,6 +207,3 @@ if has_mps(): cumsum_needs_bool_fix = not torch.BoolTensor([True,True]).to(device=torch.device("mps"), dtype=torch.int64).equal(torch.BoolTensor([True,False]).to(torch.device("mps")).cumsum(0)) torch.cumsum = lambda input, *args, **kwargs: ( cumsum_fix(input, orig_cumsum, *args, **kwargs) ) torch.Tensor.cumsum = lambda self, *args, **kwargs: ( cumsum_fix(self, orig_Tensor_cumsum, *args, **kwargs) ) - orig_narrow = torch.narrow - torch.narrow = lambda *args, **kwargs: ( orig_narrow(*args, **kwargs).clone() ) - |