run: cargo test --verbose
- name: Run No-STD Tests
- run: cargo test --no-default-features --features alloc --verbose
+ run: cargo test --no-default-features --verbose
- name: Run Audit
# RUSTSEC-2021-0145 is criterion so only within benchmarks
the JSON header refers the `dtype` the `shape` and `data_offsets` which are the offsets
for the values in the rest of the file.
"""
-exclude = [ "rust-toolchain", "target/*", "Cargo.lock"]
+exclude = ["rust-toolchain", "target/*", "Cargo.lock"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-hashbrown = { version = "0.15.4", features = ["serde"], optional = true }
-serde = { version = "1.0", default-features = false, features = ["derive"] }
-serde_json = { version = "1.0", default-features = false }
+serde = { version = "1.0", default-features = false, features = [
+ "derive",
+ "alloc",
+] }
+serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
+hashbrown = { version = "0.15.4", features = ["serde"] }
[dev-dependencies]
criterion = "0.6"
[features]
default = ["std"]
std = ["serde/default", "serde_json/default"]
-alloc = ["serde/alloc", "serde_json/alloc", "hashbrown"]
+# Kept for backward compatibility - no-op since alloc is always available
+alloc = []
[[bench]]
name = "benchmark"
pub use tensor::serialize_to_file;
pub use tensor::{serialize, Dtype, SafeTensorError, SafeTensors, View};
-#[cfg(feature = "alloc")]
+#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;
-#[cfg(all(feature = "std", feature = "alloc"))]
-compile_error!("must choose either the `std` or `alloc` feature, but not both.");
-#[cfg(all(not(feature = "std"), not(feature = "alloc")))]
-compile_error!("must choose either the `std` or `alloc` feature");
-
/// A facade around all the types we need from the `std`, `core`, and `alloc`
/// crates. This avoids elaborate import wrangling having to happen in every
/// module.