From f5b3fcc6cf7cc2dd426952127de99ac334dc0c44 Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Mon, 5 Feb 2024 13:33:27 -0800 Subject: [PATCH] Update rng.py --- modules/rng.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/rng.py b/modules/rng.py index 8934d39b..a781aa8d 100644 --- a/modules/rng.py +++ b/modules/rng.py @@ -10,6 +10,11 @@ def randn(seed, shape, generator=None): manual_seed(seed) + if generator is not None: + # if generator is not none, we must generate a noise with and without + # generator together to avoid future 'randn_like' get same noise again + torch.randn(shape, device=devices.device) + if shared.opts.randn_source == "NV": return torch.asarray((generator or nv_rng).randn(shape), device=devices.device)