From 2ca943a1c31581a8fa102cf269b67833fbc37d6f Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Tue, 20 Aug 2024 02:42:22 +0200 Subject: [PATCH] Hotfix for clip I'm sure this won't break a million other things --- ops.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ops.py b/ops.py index 5030e0d..d214fc6 100644 --- a/ops.py +++ b/ops.py @@ -32,6 +32,13 @@ class GGMLTensor(torch.Tensor): def detach(self, *args, **kwargs): return self + def copy_(self, *args, **kwargs): + # fixes .weight.copy_ in comfy/clip_model/CLIPTextModel + try: + return super().copy_(*args, **kwargs) + except Exception as e: + print(f"ignoring 'copy_' on tensor") + @property def shape(self): if not hasattr(self, "tensor_shape"): @@ -44,7 +51,7 @@ class GGMLLayer(torch.nn.Module): """ def __init__(self, *args, **kwargs): super().__init__() - self.weight = None + self.weight = GGMLTensor(1, tensor_type=None, tensor_shape=None) self.bias = None def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs): @@ -142,4 +149,4 @@ class GGMLOps(comfy.ops.manual_cast): if device: self.to(device) - return x \ No newline at end of file + return x