]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
convert : fix conversion of some BERT embedding models (#6937)
authorChristian Zhou-Zheng <redacted>
Mon, 29 Apr 2024 13:34:41 +0000 (09:34 -0400)
committerGitHub <redacted>
Mon, 29 Apr 2024 13:34:41 +0000 (16:34 +0300)
convert-hf-to-gguf.py

index 5763b6664e832e9d8345cf74fc3e5cfda5926b36..3b9fa264aa22ce7c3ccb5a15b7f8c51696ca6b65 100755 (executable)
@@ -2482,6 +2482,10 @@ class BertModel(Model):
                 print(f"Can not map tensor {name!r}")
                 sys.exit()
 
+            # convert any unsupported data types to float32
+            if data_torch.dtype not in (torch.float16, torch.float32):
+                data_torch = data_torch.to(torch.float32)
+
             data = data_torch.squeeze().numpy()
             n_dims = len(data.shape)
             new_dtype: type[np.floating[Any]]