mirror of
https://github.com/hanzoai/ml.git
synced 2026-11-20 23:08:29 +00:00
31 lines
902 B
Rust
31 lines
902 B
Rust
/// Regression test for pth files not loading on Windows.
|
|
#[test]
|
|
fn test_pth() {
|
|
let tensors = hanzo_ml::pickle::PthTensors::new("tests/test.pt", None).unwrap();
|
|
tensors.get("test").unwrap().unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn test_pth_with_key() {
|
|
let tensors =
|
|
hanzo_ml::pickle::PthTensors::new("tests/test_with_key.pt", Some("model_state_dict"))
|
|
.unwrap();
|
|
tensors.get("test").unwrap().unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn test_pth_fortran_contiguous() {
|
|
let tensors = hanzo_ml::pickle::PthTensors::new("tests/fortran_tensor_3d.pth", None).unwrap();
|
|
let tensor = tensors.get("tensor_fortran").unwrap().unwrap();
|
|
|
|
assert_eq!(tensor.dims3().unwrap(), (2, 3, 4));
|
|
|
|
assert_eq!(
|
|
tensor.to_vec3::<i64>().unwrap(),
|
|
[
|
|
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],
|
|
[[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]
|
|
]
|
|
);
|
|
}
|