BendMlTensorGpu.rng_ln_w: def of bend-ml-tensor-gpu@0.1.5.1 Import: import bend-ml-tensor-gpu@0.1.5.1/main.bend as BendMlTensorGpu Lines 630-635 of bend-ml-tensor-gpu@0.1.5.1/main.bend: https://jend.leeeet.dev/read.txt?path=bend-ml-tensor-gpu@0.1.5.1/main.bend&start_line=630&end_line=635 import Base # ln x for a positive normal x: x = m * 2^ex with m in [sqrt(1/2), sqrt(2)) read from the bits (a mantissa above # sqrt(2)'s, 0x3504F3, is halved and the exponent raised by one); ex * ln 2 in two parts, the first exact def rng_ln_w(+w: U32) -> F32: +big = U32.is_lt(3474675, U32.and(w, 8388607)) +mb = U32.or(U32.and(w, 8388607), Bool.pick(U32, big, 1056964608, 1065353216)) rng_ln_m((U32.to_f32(U32.shrn(w, 23n)) - Bool.pick(F32, big, 126.0, 127.0) : F32), rng_f32(mb)) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shrn https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_f32 https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-gpu@0.1.5.1/main.bend&name=rng_f32 https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-gpu@0.1.5.1/main.bend&name=rng_ln_m