Expand description
SIMD-accelerated kernels for the pipeline’s two hot CPU loops: per-pixel image normalization and per-timestep CTC argmax decode. (Conv/matmul work lives in ONNX Runtime.)
Each kernel ships as a scalar reference (*_scalar, always compiled) and a
SIMD path (*_simd, behind the simd feature) built on wide and
runtime-dispatched via multiversion, so one binary selects AVX2/SSE/NEON
at runtime without target-cpu=native. Entry points pick the SIMD path when
the feature is on, else the scalar one.
The SIMD paths are bit-identical to the scalar reference: same
value * alpha + beta form (plain multiply-add, not FMA, which rounds
differently) and same “last index wins on ties” argmax. Parity tests at the
bottom of the module enforce this, so toggling simd never changes output.
Functions§
- argmax
- Returns the
(index, value)of the maximum element ofrow. - normalize_
chw_ into - Writes a normalized image in CHW (channel-major) layout into
out. - normalize_
crnn_ chw_ into - Fills a CRNN CHW input tensor from a resized RGB crop.
- normalize_
hwc_ into - Writes a normalized image in HWC (interleaved) layout into
out. - scale_
clamp_ bgr_ planes_ to_ rgb - Converts a BGR-ordered CHW float plane-triple into an interleaved RGB
u8image, computing(v * scale).clamp(0.0, 255.0) as u8per element.