Fix: pth files don't load on Windows (#1661)

* Don't treat zip path as OS path

* Add a test case

* Add code to generate test pth data
This commit is contained in:
Roma Klapaukh
2024-02-06 18:50:55 +11:00
committed by GitHub
parent 982722019b
commit 1ba11f22d6
4 changed files with 15 additions and 3 deletions

8
candle-core/tests/pth.py Normal file
View File

@ -0,0 +1,8 @@
import torch
from collections import OrderedDict
# Write a trivial tensor to a pt file
a= torch.tensor([[1,2,3,4], [5,6,7,8]])
o = OrderedDict()
o["test"] = a
torch.save(o, "test.pt")

View File

@ -0,0 +1,6 @@
/// Regression test for pth files not loading on Windows.
#[test]
fn test_pth() {
let tensors = candle_core::pickle::PthTensors::new("tests/test.pt").unwrap();
tensors.get("test").unwrap().unwrap();
}

BIN
candle-core/tests/test.pt Normal file

Binary file not shown.