Skip to content

[Safetensors] Fix safetensors shape #8702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 3, 2024
4 changes: 2 additions & 2 deletions paddlenlp/utils/safetensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __getitem__(self, index):
span = self.bits
for i, (start, stop, step) in enumerate(zip(out_start[::-1], out_stop[::-1], out_step[::-1])):
if len(indices) == 0:
if start == 0 and stop == self.shape[i]:
if start == 0 and stop == self.shape[::-1][i]:
pass
# We haven't started to slice yet, just increase the span
else:
Expand All @@ -194,7 +194,7 @@ def __getitem__(self, index):
newindices.append((old_start + offset, old_stop + offset))
indices = newindices
assert len(indices) == capacity, f"error {capacity} {len(indices)}"
span *= self.shape[-(i + 1)]
span *= self.shape[::-1][i]

if len(indices) == 0:
indices.append((0, self.nbytes))
Expand Down
Loading