Hi,
This is a cross-post with JuliaDiff/ForwardDiff.jl#604.
The rule for ldexp(x,y) always returns a Float64 regardless of the type of the first argument x.
This is because the rule is given by
@define_diffrule Base.ldexp(x, y) = :( exp2($y) ), :NaN
and since y is an Int exp2 by default return a Float64. @mcabbott pointed out that if we change the rule to
@define_diffrule Base.ldexp(x, y) = :( oftype(float($x), exp2($y) ), :NaN
then we should maintain the Float32 type throughout the computation.