aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-12-31 19:33:32 +0000
committerGitHub <noreply@github.com>2023-12-31 19:33:32 +0000
commitbe5f1acc8f6e5bfc7f8234fd570d663b2fde9c27 (patch)
treea07510354ce2dddf0afaf37ba256eba6d820900d /modules/devices.py
parentf3af8c8d04d6be58ddb3b55f77d8006241dca8f6 (diff)
parent5768afc776a66bb94e77a9c1daebeea58fa731d5 (diff)
downloadstable-diffusion-webui-gfx803-be5f1acc8f6e5bfc7f8234fd570d663b2fde9c27.tar.gz
stable-diffusion-webui-gfx803-be5f1acc8f6e5bfc7f8234fd570d663b2fde9c27.tar.bz2
stable-diffusion-webui-gfx803-be5f1acc8f6e5bfc7f8234fd570d663b2fde9c27.zip
Merge pull request #14478 from akx/dtype-inspect
Add utility to inspect a model's dtype/device
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/devices.py b/modules/devices.py
index c956207f..bd6bd579 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -4,6 +4,7 @@ from functools import lru_cache
import torch
from modules import errors, shared
+from modules.torch_utils import get_param
if sys.platform == "darwin":
from modules import mac_specific
@@ -131,7 +132,7 @@ patch_module_list = [
def manual_cast_forward(self, *args, **kwargs):
- org_dtype = next(self.parameters()).dtype
+ org_dtype = get_param(self).dtype
self.to(dtype)
args = [arg.to(dtype) if isinstance(arg, torch.Tensor) else arg for arg in args]
kwargs = {k: v.to(dtype) if isinstance(v, torch.Tensor) else v for k, v in kwargs.items()}