Parcourir la source

Avoid exceptions to be silenced

Kohaku-Blueleaf il y a 1 an
Parent
commit
4a66d2fb22
1 fichiers modifiés avec 5 ajouts et 6 suppressions
  1. 5 6
      modules/devices.py

+ 5 - 6
modules/devices.py

@@ -178,12 +178,11 @@ def manual_cast(target_dtype):
     try:
     try:
         yield None
         yield None
     finally:
     finally:
-        if not applied:
-            return
-        for module_type in patch_module_list:
-            if hasattr(module_type, "org_forward"):
-                module_type.forward = module_type.org_forward
-                delattr(module_type, "org_forward")
+        if applied:
+            for module_type in patch_module_list:
+                if hasattr(module_type, "org_forward"):
+                    module_type.forward = module_type.org_forward
+                    delattr(module_type, "org_forward")
 
 
 
 
 def autocast(disable=False):
 def autocast(disable=False):