Sigmoid

The quantized sigmoid function is defined as follows:

σQ(x)=Q1+2x\sigma_Q(x) = \dfrac{Q}{1 + 2^{-x}}

where $Q$ is the quantization factor. We use $2$ instead of $e$ for convenience.

Implementation

The Sigmoid instruction is implemented as a virtual instruction. It is thus defined a sequence of virtual cycles, including:

  • Clamp inputs to [−8,8] to avoid overflow in $2^z$.

  • Materialisation of constants $(0, Q, Q²)$.

  • Computation of abs(z) using subtraction and Select.

  • Computation of $2^{|z|}$ via VirtualPow2.

  • Integer branches: $Q / 2^{|z|}$ and $Q * 2^{|z|}$.

  • Sign-dependent selection into intermediate a.

  • Final result: $c = Q² / (Q + a)$ moved into td.

Last updated