Skip to content

Commit

Permalink
py : fix scalar-tensor conversion [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Sep 17, 2024
1 parent 13e6d73 commit fbbb64f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions convert_hf_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,13 @@ def prepare_tensors(self):
bid = int(part)
break

for new_name, data in ((n, d.squeeze().numpy()) for n, d in self.modify_tensors(data_torch, name, bid)):
data: np.ndarray # type hint
for new_name, data_torch in (self.modify_tensors(data_torch, name, bid)):
data = data_torch.squeeze().numpy()

# if data ends up empty, it means data_torch was a scalar tensor -> restore
if len(data.shape) == 0:
data = data_torch.numpy()

n_dims = len(data.shape)
data_qtype: gguf.GGMLQuantizationType | bool = self.tensor_force_quant(name, new_name, bid, n_dims)

Expand Down

0 comments on commit fbbb64f

Please sign in to comment.