Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type instability in ldexp with Float32 arguments #88

Closed
ptiede opened this issue Nov 2, 2022 · 1 comment
Closed

Type instability in ldexp with Float32 arguments #88

ptiede opened this issue Nov 2, 2022 · 1 comment

Comments

@ptiede
Copy link
Contributor

ptiede commented Nov 2, 2022

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.

@ptiede
Copy link
Contributor Author

ptiede commented Nov 10, 2022

Closed because of #89

@ptiede ptiede closed this as completed Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant