4 ms·
Don't have time to figure out the actual numbers myself, but here's an example doing the same for various transcendental functions: https://github.com/J-Montgom
by AlotOfReading 2y ago
Don't have time to figure out the actual numbers myself, but here's an example doing the same for various transcendental functions:
https://github.com/J-Montgomery/hacky_float_math/blob/623ee9f13da8343dda2af36c9a1bb9decca1fa04/softmax.cc#L34 https://github.com/J-Montgomery/hacky_float_math/blob/623ee9...
a*(1.xxx/b) = a*(-1*1.xxx*log2(b)), which means you should be able to do a*(fma(b, magic, constant)) with appropriate conversions on either side. Should work in 32 bits for u8s.