aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_torch_utils.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-01-01 14:01:06 +0000
committerGitHub <noreply@github.com>2024-01-01 14:01:06 +0000
commit7ba02e0b7cfc85d5d237eba71ab4d66564857d55 (patch)
treeb317227a0e63c42aa8c4b06147761dfd37ae24fc /test/test_torch_utils.py
parentbe31e7e71a08dc27543d31aa6e6532463ccbf20f (diff)
parent15156cde18844f459ba101b1356d162aa7f39c47 (diff)
downloadstable-diffusion-webui-gfx803-7ba02e0b7cfc85d5d237eba71ab4d66564857d55.tar.gz
stable-diffusion-webui-gfx803-7ba02e0b7cfc85d5d237eba71ab4d66564857d55.tar.bz2
stable-diffusion-webui-gfx803-7ba02e0b7cfc85d5d237eba71ab4d66564857d55.zip
Merge branch 'dev' into finer-settings-freezing-control
Diffstat (limited to 'test/test_torch_utils.py')
-rw-r--r--test/test_torch_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_torch_utils.py b/test/test_torch_utils.py
new file mode 100644
index 00000000..23ccb93a
--- /dev/null
+++ b/test/test_torch_utils.py
@@ -0,0 +1,19 @@
+import types
+
+import pytest
+import torch
+
+from modules import torch_utils
+
+
+@pytest.mark.parametrize("wrapped", [True, False])
+def test_get_param(wrapped):
+ mod = torch.nn.Linear(1, 1)
+ cpu = torch.device("cpu")
+ mod.to(dtype=torch.float16, device=cpu)
+ if wrapped:
+ # more or less how spandrel wraps a thing
+ mod = types.SimpleNamespace(model=mod)
+ p = torch_utils.get_param(mod)
+ assert p.dtype == torch.float16
+ assert p.device == cpu