mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
20 lines
471 B
Python
20 lines
471 B
Python
|
import types
|
||
|
|
||
|
import pytest
|
||
|
import torch
|
||
|
|
||
|
from modules.torch_utils import get_param
|
||
|
|
||
|
|
||
|
@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 = get_param(mod)
|
||
|
assert p.dtype == torch.float16
|
||
|
assert p.device == cpu
|