"git@developer.sourcefind.cn:OpenDAS/torch-harmonics.git" did not exist on "89fb38df3c47b3a2979e1e731229e2fc74fa8b39"
Unverified Commit 2a2c135b authored by twaka's avatar twaka Committed by GitHub
Browse files

Fix loading error when safetensors contains empty tensor (#1687)

parent 65ea2ddf
...@@ -258,7 +258,12 @@ def convert_pyslice_to_tensor(x: Any) -> torch.Tensor: ...@@ -258,7 +258,12 @@ def convert_pyslice_to_tensor(x: Any) -> torch.Tensor:
tensor first. tensor first.
""" """
if not isinstance(x, torch.Tensor): if not isinstance(x, torch.Tensor):
x = x[:] try:
x = x[:]
except IndexError:
# IndexError happens when the tensor is empty.
# transformer.h.0.attn.masked_bias is empty in some gpt2 models.
return torch.Tensor()
return x return x
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment