Skip to content

Commit 194b117

Browse files
committed
Add a copy with bytearray for non-writable buffers
1 parent 253a6ca commit 194b117

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/datasets/mnist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def read_sn3_pascalvincent_tensor(path: str, strict: bool = True) -> torch.Tenso
513513
assert 8 <= ty <= 14
514514
torch_type = SN3_PASCALVINCENT_TYPEMAP[ty]
515515
s = [get_int(data[4 * (i + 1) : 4 * (i + 2)]) for i in range(nd)]
516-
parsed = torch.frombuffer(data, dtype=torch_type, offset=(4 * (nd + 1)))
516+
parsed = torch.frombuffer(bytearray(data), dtype=torch_type, offset=(4 * (nd + 1)))
517517
assert parsed.shape[0] == np.prod(s) or not strict
518518
return parsed.view(*s)
519519

0 commit comments

Comments
 (0)