summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Zhou-Zheng <59622928+christianazinn@users.noreply.github.com>2024-04-29 09:34:41 -0400
committerGitHub <noreply@github.com>2024-04-29 16:34:41 +0300
commit3055a4180557c6cbe29eacc8284c9e070ac10eab (patch)
treef4f0183ed720cc9b2a1f5eb3d2ac22d2b3f9e7a9
parent577277ffd203b190c3dc2ab3e737946dc432132c (diff)
convert : fix conversion of some BERT embedding models (#6937)
-rwxr-xr-xconvert-hf-to-gguf.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py
index 5763b666..3b9fa264 100755
--- a/convert-hf-to-gguf.py
+++ b/convert-hf-to-gguf.py
@@ -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]]