Skip to main content

Module bitstream

Module bitstream 

Source
Expand description

§Bitstream Operations

Core bitstream packing and logic primitives for stochastic computing. Probabilities are represented as packed Bernoulli bitstreams stored in u64 words.

Structs§

BitStreamTensor
Packed bitstream tensor with original bit length metadata.

Functions§

bernoulli_packed
Generate a packed Bernoulli bitstream directly into u64 words.
bernoulli_packed_fast
Fast packed Bernoulli generation using byte-threshold comparison.
bernoulli_packed_simd
SIMD-accelerated packed Bernoulli generation.
bernoulli_stream
Generate an unpacked Bernoulli bitstream from a probability.
bitwise_and
Compute bitwise-AND between two packed tensors.
encode_and_popcount
Fused encode+AND+popcount without materializing encoded input words.
encode_matrix_prob_to_packed
Encode a flat matrix of probabilities into packed Bernoulli bitstreams.
pack
Pack a 0/1 byte slice into u64 words.
pack_fast
Portable fast pack: processes 8 bytes into one output byte at a time.
popcount
Popcount of all bits set in a packed tensor.
popcount_words_portable
Portable popcount over a packed word slice.
simd_bernoulli_compare 🔒
Compare 64 bytes against a threshold and return a packed bit mask.
swar_popcount_word
Portable SWAR popcount for a single u64 word.
unpack
Unpack a packed tensor back into a 0/1 byte vector.