|
| void | setInverse (bool inverse) override |
| void | execute (fz::stream_t stream, MemoryPool *pool, const std::vector< void * > &inputs, const std::vector< void * > &outputs, const std::vector< size_t > &sizes) override |
| void | postStreamSync (fz::stream_t stream) override |
| std::string | getName () const override |
| void | setChunkSize (size_t bytes) |
|
size_t | getRequiredInputAlignment () const override |
| | Chunked mode needs whole chunks; the pipeline zero-pads the input to suit.
|
| size_t | estimateScratchBytes (const std::vector< size_t > &input_sizes) const override |
| std::vector< size_t > | estimateOutputSizes (const std::vector< size_t > &input_sizes) const override |
| std::unordered_map< std::string, size_t > | getActualOutputSizesByName () const override |
| size_t | getActualOutputSize (int index) const override |
| uint16_t | getStageTypeId () const override |
| uint8_t | getOutputDataType (size_t output_index) const override |
| uint8_t | getInputDataType (size_t) const override |
| size_t | serializeHeader (size_t output_index, uint8_t *header_buffer, size_t max_size) const override |
| void | deserializeHeader (const uint8_t *header_buffer, size_t size) override |
| size_t | getMaxHeaderSize (size_t output_index) const override |
| virtual std::vector< std::string > | getOutputNames () const |
| int | getOutputIndex (const std::string &name) const |
| virtual void | saveState () |
| virtual std::vector< std::string > | getRunNotes () const |
| virtual void | setDims (const std::array< size_t, 3 > &dims) |
| virtual void | onFinalize (size_t, MemoryPool *) |
| virtual size_t | estimateDeviceFootprintBytes (size_t) const |
| virtual size_t | estimatePinnedFootprintBytes (size_t) const |
| virtual void | setTerminalOutput (bool terminal) |
| virtual FusionSpec | getFusionSpec () const |
| virtual FusedOpDecl | getFusedOp () const |
| virtual FusionSpec | getInverseFusionSpec () const |
| virtual FusedOpDecl | getInverseFusedOp () const |
| virtual size_t | getFusedInverseElementCount () const |
| virtual double | getFusedForwardQuantStep () const |
| virtual double | getFusedInverseDequantStep () const |
| virtual EncodingOracleDecl | getEncodingOracle () const |
| virtual bool | bindDownstreamEncodingOracle (const EncodingOracleDecl &) |
| virtual std::vector< FusedAuxOutputDecl > | getFusedAuxOutputs () const |
| virtual void | primeFusedForwardState (const FusedPrimeContext &) |
| virtual void | setFusedArchiveResult (size_t, size_t) |
| virtual void | setFusedInverseResult (size_t) |
| virtual void | setFusedSideOutput (int, size_t) |
template<typename T = uint16_t>
class fz::RLEStage< T >
Run-Length Encoding stage. Lossless; effective when data has long runs of identical values (e.g. quantized codes).
Forward wire format: [num_runs:u32][pad to alignof(T)][values:T×n (4B-aligned)][lengths:u32×n] The header-to-values pad is 0 bytes for T ≤ 4 bytes, 4 bytes for 8-byte T.
Chunked mode (setChunkSize(bytes), opt-in)
With a non-zero chunk size the input is cut into independent chunks of chunk_size / sizeof(T) elements, each encoded by a single thread block with a block-local scan. This removes the device-wide CUB scan and the serialising dependency chain of the global path (5 kernels + a full-length scan collapse to 2 kernels + a scan over num_chunks elements), which is where the throughput comes from; the cost is a forced run boundary at every chunk start plus a 4 × (num_chunks + 1) byte offset table, so the compression ratio drops slightly as chunks get smaller.
Chunked wire format: [num_chunks:u32][run_offsets:u32×(num_chunks+1)][pad to alignof(T)] [values:T×total_runs (4B-aligned)][lengths:u32×total_runs] where run_offsets[c] is the index of chunk c's first run and run_offsets[num_chunks] == total_runs.
Chunked decode needs no device-to-host readback at all (the element count and chunk size both come from the serialized stage header); the global path's inverse reads the run count back to the host.
Worst-case output is 2× input + 4 bytes (no repeated values), so RLE should follow a predictor/quantizer stage that creates repetition.
- Template Parameters
-
| T | Element type (uint8_t/uint16_t/uint32_t/uint64_t, int8_t/int16_t/int32_t/int64_t — full 1/2/4/8-byte word-size coverage, matching the LC framework's RLE_1/2/4/8). Run counts are always uint32_t. |
template<typename T = uint16_t>
| void fz::RLEStage< T >::execute |
( |
fz::stream_t | stream, |
|
|
MemoryPool * | pool, |
|
|
const std::vector< void * > & | inputs, |
|
|
const std::vector< void * > & | outputs, |
|
|
const std::vector< size_t > & | sizes ) |
|
overridevirtual |
Execute the stage. Inputs, outputs, and sizes are device pointers/bytes.
Stages may call cudaStreamSynchronize(stream) or issue blocking D2H copies when the algorithm requires it (e.g. Huffman histogram readback for codebook construction, ANS renormalization tables). Such stages must document the sync points.
Note: the DAG dispatches sibling nodes (same topological level) via a sequential CPU loop, each enqueuing to its own stream. A sync inside execute() blocks the CPU from dispatching subsequent siblings until the synced stream is idle — this delays parallel branches in wide DAGs. In a linear pipeline there are no siblings and no extra cost.
Implements fz::Stage.