Rust API
ptwm_core
Pure-Rust core for lossless neural-network weight compression.
ptwm_core
Pure-Rust core for lossless neural-network weight compression.
ptwm_core
crates/ptwm-core/src/lib.rs:1mod ptwm_corePure-Rust core for lossless neural-network weight compression.
No Python dependency lives here; the sibling `ptwm-py` crate carries the
PyO3 bindings. The modules below implement the `.ptwm` container format
(header, prelude, index, tensor / plane records, compressor, container
reader) and the codec plus preprocessing utilities the container and the
Python CLI share.
# API stability
The stable, supported entry point to PTWM is the **Python package**
(`pip install ptwm`). This crate's API is intended for the
sibling [`ptwm-py`] bindings and may change in any minor release.
External Rust consumers should pin an exact version.
[`ptwm-py`]: https://crates.io/crates/ptwm-py
ptwm_core::buffer_sizes_for_chunk
crates/ptwm-core/src/lib.rs:148pub fn buffer_sizes_for_chunk(chunk_len: usize, num_buf: usize, bytes_mode: i32) -> Vec<usize>Compute per-buffer sizes for a chunk of `chunk_len` bytes.
ptwm_core::combine_chunk
crates/ptwm-core/src/lib.rs:118pub fn combine_chunk(planes: &[Vec<u8>], out: &mut [u8], num_buf: usize, bits_mode: i32, bytes_mode: i32)Inverse of [`split_chunk`]. Reassembles `planes` into the output buffer.
`out` must be sized to the original uncompressed chunk length (before
splitting). `planes.len()` must equal `num_buf`.
ptwm_core::split_chunk
crates/ptwm-core/src/lib.rs:99pub fn split_chunk(data: &[u8], num_buf: usize, bits_mode: i32, bytes_mode: i32) -> Vec<Vec<u8>>Split a single chunk's data into `num_buf` buffers based on dtype.
ptwm_core::validate_modes
crates/ptwm-core/src/lib.rs:63pub fn validate_modes(num_buf: usize, bits_mode: i32, bytes_mode: i32) -> Result<(), PtwmCoreError>Validate `bits_mode` / `bytes_mode` for the given `num_buf`.
ptwm_core::validate_num_buf
crates/ptwm-core/src/lib.rs:55pub fn validate_num_buf(num_buf: u32) -> Result<usize, PtwmCoreError>Validate `num_buf` and return it as a `usize`.