def silu_finish

stelliferous@0.0.2.0 · math_fp32.bend:38

import stelliferous@0.0.2.0/math_fp32.bend as MathFp32
import Base

38# Above 18 SiLU rounds to x. Pass x through, including positive infinity;
39# the negative tail uses the clamped input before the final underflow.
40def silu_finish(+x: F32,value: F32) -> F32:
41  +word = F32.bits(x)
42  +positive = U32.not((0 - U32.shrn(word,31n) : U32))
43  +large = U32.and(positive,(0 - U32.shrn((1099956224 - word : U32),31n) : U32))
44  selected(large,x,value)

Uses (8)

Used by (1)