-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix epsilon for Float16 #190
Conversation
src/rules.jl
Outdated
η, ρ, ϵ = T(o.eta), T(o.rho), T(o.epsilon) | ||
ϵ = max(ϵ, eps(T(0))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this does the right thing:
julia> eps(Float32) # roughly what we hard-code now
1.1920929f-7
julia> eps(0f0) # what this PR uses
1.0f-45
I think a better pattern is this:
η, ρ, ϵ = T(o.eta), T(o.rho), T(o.epsilon) | |
ϵ = max(ϵ, eps(T(0))) | |
η, ρ, ϵ = T(o.eta), T(o.rho), max(T(o.epsilon), eps(T)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose eps(T(0))
because i didn't want to change the current behavior eps=1f-8
for Float32
but do the minimal change needed for Float16
julia> eps(Float16)
Float16(0.000977)
julia> eps(Float16(0))
Float16(6.0e-8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. How broadly is 6e-8 big enough for this purpose? It seems a little random... maybe I'd be happier to hard-code an obviously chosen number, which is what 1e-8
is... like _eps(::Type{Float16}, e) = max(1e-7, e)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Fix #167 adding
ϵ = max(ϵ, eps(T(0)))
.Also fix #189