aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrkirch <brkirch@users.noreply.github.com>2022-10-10 04:38:55 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-10 05:04:52 +0000
commit8acc901ba3a252dc6ab4fabcb41644cf64d1774c (patch)
treec4251d6534c6cbbeee40b22bcbe8f15d0178e010
parent45fbd1c5fec887988ab555aac75a999d4f3aff40 (diff)
downloadstable-diffusion-webui-gfx803-8acc901ba3a252dc6ab4fabcb41644cf64d1774c.tar.gz
stable-diffusion-webui-gfx803-8acc901ba3a252dc6ab4fabcb41644cf64d1774c.tar.bz2
stable-diffusion-webui-gfx803-8acc901ba3a252dc6ab4fabcb41644cf64d1774c.zip
Newer versions of PyTorch use TypedStorage instead
Pytorch 1.13 and later will rename _TypedStorage to TypedStorage, so check for TypedStorage and use _TypedStorage if it is not available. Currently this is needed so that nightly builds of PyTorch work correctly.
-rw-r--r--modules/safe.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/safe.py b/modules/safe.py
index 4d06f2a5..05917463 100644
--- a/modules/safe.py
+++ b/modules/safe.py
@@ -12,6 +12,10 @@ import _codecs
import zipfile
+# PyTorch 1.13 and later have _TypedStorage renamed to TypedStorage
+TypedStorage = torch.storage.TypedStorage if hasattr(torch.storage, 'TypedStorage') else torch.storage._TypedStorage
+
+
def encode(*args):
out = _codecs.encode(*args)
return out
@@ -20,7 +24,7 @@ def encode(*args):
class RestrictedUnpickler(pickle.Unpickler):
def persistent_load(self, saved_id):
assert saved_id[0] == 'storage'
- return torch.storage._TypedStorage()
+ return TypedStorage()
def find_class(self, module, name):
if module == 'collections' and name == 'OrderedDict':