Skip to main content

Module act_quant

Module act_quant 

Source
Expand description

The activation quantizer (crate::spatial::decode_engine::numerics::quantize) as Verilog: a block of 32 f32 values to its 4-bit-significand scale and its codes.

The scale has a closed form in the block’s largest magnitude S·2^(E−23) (S its 24-bit significand): with m₁ = ⌈⌈S/2¹³⌉/127⌉, the scale is m₁·2^(E−10) when m₁ ≤ 15, else ⌈⌈S/2¹⁴⌉/127⌉·2^(E−9), a significand of 8 or 9 (closed_form_scale, held to block_scale over every significand). A code is the exact quotient of its value by the scale, carried with 32 fraction bits and a remainder, rounded to nearest with ties to even.

Constants§

WIDE_SCALE_P_LATENCY
Clocks from logos_wide_scale_p’s operands to their scale.

Functions§

act_quant_verilog
logos_act_block(x, two) -> (m, e, codes): 32 f32 values packed little-end first in x; two selects the two-word codes; codes packs 32 signed 16-bit codes; e is the scale’s exponent, signed. logos_act_wide #(LANES) is the per-block quantizer over a block of LANES values: the same ports, its m eight bits. logos_act_stream #(LANES) is logos_act_wide over a block arriving sixteen values a beat, with sixteen code units: one quantizer for every block length up to LANES, its beats held in block RAM. logos_wide_scale_p is logos_wide_scale for the user clock, its scale WIDE_SCALE_P_LATENCY clocks after its operands.
closed_form_scale
The block scale’s closed form, for a normal amax with significand s (24 bits) and unbiased exponent e.
closed_form_wide_scale
The per-block scale’s closed form (crate::spatial::decode_engine::numerics::wide_scale, an 8-bit significand), for a normal amax with significand s (24 bits) and unbiased exponent e: with m₁ = ⌈⌈S/2⁹⌉/127⌉, the scale is m₁·2^(e−14) when m₁ ≤ 255, else ⌈⌈S/2¹⁰⌉/127⌉·2^(e−13), a significand of 128 to 130.