reducers

codegen.reducers

General resolver: lower a declarative streaming-reducer spec to backend source.

A :class:~tvbo.codegen.streaming_reducers.StreamingReducerSpec authors a windowed reducer as symbolic assignment recurrences (strings). This module parses each RHS to sympy against the reducer’s vocabulary and prints it with the target :mod:tvbo.codegen.code printer, so the SAME spec emits jax / numpy / julia. There is no reducer-specific logic here — the concrete recipe lives in the spec (metadata); the algorithm template emits the resolved assignments into a backend-shaped scaffolding. Verified byte-identical to compute_fc including a large DC baseline (scratchpad/proto_general.py).

Functions

Name Description
resolve_streaming_reducer Lower a declarative reducer spec to printed per-assignment source for fmt.

resolve_streaming_reducer

codegen.reducers.resolve_streaming_reducer(spec, fmt='jax')

Lower a declarative reducer spec to printed per-assignment source for fmt.

Returns {"state": [...], "add": [(lhs, rhs_src), ...], "evict": ..., "resync": ..., "resync_masked": ..., "emit": rhs_src}. The reducer’s symbolic vocabulary is the state variables plus the per-step sample v, the window x, and the masked-resync mask m / count L; each assignment’s lhs joins the vocabulary so later RHS may reference it (sequential data flow). State-var symbols win over same-named array functions (e.g. a state mean shadows the mean reducer).