diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-13 21:49:58 +0300 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-13 21:49:58 +0300 |
commit | 9d40212485febe05a662dd0346e6def83e456288 (patch) | |
tree | c56b55041ae4513ea5762cf07215f377175440d2 /modules/devices.py | |
parent | 85b97cc49c4766cb47306e71e552871a0791ea29 (diff) |
first attempt to produce crrect seeds in batch
Diffstat (limited to 'modules/devices.py')
-rw-r--r-- | modules/devices.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/devices.py b/modules/devices.py index e4430e1a..07bb2339 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -48,3 +48,13 @@ def randn(seed, shape): torch.manual_seed(seed) return torch.randn(shape, device=device) + +def randn_without_seed(shape): + # Pytorch currently doesn't handle setting randomness correctly when the metal backend is used. + if device.type == 'mps': + generator = torch.Generator(device=cpu) + noise = torch.randn(shape, generator=generator, device=cpu).to(device) + return noise + + return torch.randn(shape, device=device) + |