better caster (#1480)

related to mps/rocm/cpu casting for fp16 and etc on clip
This commit is contained in:
lllyasviel
2023-12-17 17:09:15 -08:00
committed by GitHub
parent 69a23c4d60
commit 0e1aa8d084
6 changed files with 63 additions and 64 deletions
+1 -8
View File
@@ -167,14 +167,7 @@ def preprocess(img, ip_adapter_path):
ldm_patched.modules.model_management.load_model_gpu(clip_vision.patcher)
pixel_values = clip_preprocess(numpy_to_pytorch(img).to(clip_vision.load_device))
if clip_vision.dtype != torch.float32:
precision_scope = torch.autocast
else:
precision_scope = lambda a, b: contextlib.nullcontext(a)
with precision_scope(ldm_patched.modules.model_management.get_autocast_device(clip_vision.load_device), torch.float32):
outputs = clip_vision.model(pixel_values=pixel_values, output_hidden_states=True)
outputs = clip_vision.model(pixel_values=pixel_values, output_hidden_states=True)
ip_adapter = entry['ip_adapter']
ip_layers = entry['ip_layers']