PTWM
ptwm_core

ptwm_core::compressor

PPG compressor entry point.

ptwm_core::compressor

PPG compressor entry point.

rsmod

ptwm_core::compressor

crates/ptwm-core/src/compressor.rs:1
mod compressor

PPG compressor entry point.

`compress_model` takes per-tensor candidate `Chain`s, runs each forward DAG via [`forward_chain`], routes every terminal plane through the capability-keyed [`dispatch`] menu, fits Pass-2 shared state on the chosen terminals, and writes a chain-registry-backed `.ptwm` container.
rsfn

ptwm_core::compressor::compress_model

crates/ptwm-core/src/compressor.rs:658
pub fn compress_model(writer: W, inputs: &[InputTensor<'_>], opts: CompressorOptions) -> Result<Vec<u16>, PtwmCoreError>

PPG entry point. Each input tensor carries one or more candidate [`Chain`]s; the compressor selects the chain that produces the smallest total compressed payload (multi-chain trial-encode), then writes a chain-registry-backed `.ptwm` container.

Returns the per-tensor chosen chain *registry index* (after dedup) for audit. The order matches the input slice. **Pass-2 ordering note.** Shared-state fitting is performed *after* Pass-1 multi-chain selection. This means the multi-chain ranker sees only inline trial-encode payloads. For monotone shared-state codecs (PGC, O1SAC), Inline is the lower bound on what the chain can achieve, so the multi-chain ranking remains correct; per-terminal final encoding may later switch to a `Shared` variant if it wins the re-trial.
rstype

ptwm_core::compressor::CompressorOptions

crates/ptwm-core/src/compressor.rs:91
pub struct CompressorOptions

Compressor options.

rstype

ptwm_core::compressor::InputTensor

crates/ptwm-core/src/compressor.rs:71
pub struct InputTensor

Per-tensor input for the compressor. The caller supplies one or more candidate [`Chain`]s; the compressor runs each forward+trial-encode and keeps the chain with the smallest output (multi-chain trial-encode).

rsfn

ptwm_core::compressor::source_descriptor_for

crates/ptwm-core/src/compressor.rs:158
pub fn source_descriptor_for(dtype_code: u16, raw_byte_count: u64, shape: Option<&[u64]>) -> PlaneDescriptor

Build a default source `PlaneDescriptor` keyed on dtype code. The `element_width` follows the canonical mapping used elsewhere in the crate (see `transforms::source::bytes_per_element` and the byte-/word- aware transforms). `length_bytes` is the raw byte count; `Layout::Rows{row_len}` applies when `shape` is supplied, using the row-major last dimension.

Public so the PyO3 binding (`ptwm-py`) can build the same source descriptor without duplicating the dtype-code → element-width mapping.