Skip to main content

py_sc_forward_packed

Function py_sc_forward_packed 

Source
pub(crate) fn py_sc_forward_packed<'py>(
    py: Python<'py>,
    weights_packed: PyReadonlyArray1<'py, u64>,
    n_out: usize,
    n_in: usize,
    n_words: usize,
    input_probs: PyReadonlyArray1<'py, f64>,
    length: usize,
    seed: u64,
) -> PyResult<Bound<'py, PyArray1<f64>>>
Expand description

Stochastic forward pass over caller-owned packed weight bitstreams.

Parity contract with sc_neurocore.accel.sc_forward: this Rust path and the NumPy fallback return bit-identical results for a fixed seed because the input encoder is the deterministic 16-bit LFSR comparator.

weights_packed is row-major n_out * n_in * n_words (n_words = ceil(length / 64)); input_probs is n_in float64 in [0, 1]. Returns an n_out float64 array, the AND-then-popcount estimate of weights @ input_probs divided by length.