-
Notifications
You must be signed in to change notification settings - Fork 146
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
f(x::Real) = f(float(x))
leads to stackoverflow
#366
Comments
I did not realize this was being discussed elsewhere |
This is a known limitation of ForwardDiff.jl:
http://www.juliadiff.org/ForwardDiff.jl/latest/user/limitations.html
The only ways around this that I can think of will come from either
Cassette.jl/Capstan.jl or Zygote.jl.
…On Tue, Oct 9, 2018 at 10:39 Jorge Fernandez-de-Cossio-Diaz < ***@***.***> wrote:
Many definitions follow this pattern:
f(x::AbstractFloat) = 2x # any computation here
f(x::Real) = f(float(x))
But then:
julia> ForwardDiff.derivative(f, 1.)
ERROR: StackOverflowError:
Stacktrace:
[1] f(::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f),Float64},Float64,1}) at ./REPL[3]:1 (repeats 80000 times)
Because float(Dual) gives Dual which is not AbstractFloat. Is there a way
around this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#366>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AFXArUS8XVaEkZPt2UetUbYm21UVFO9Kks5ujLUlgaJpZM4XTcLM>
.
|
My apologies, I misunderstood your issue. Thanks for posting the correct
issue links.
…On Tue, Oct 9, 2018 at 10:55 Dilum Aluthge ***@***.***> wrote:
This is a known limitation of ForwardDiff.jl:
http://www.juliadiff.org/ForwardDiff.jl/latest/user/limitations.html
The only ways around this that I can think of will come from either
Cassette.jl/Capstan.jl or Zygote.jl.
On Tue, Oct 9, 2018 at 10:39 Jorge Fernandez-de-Cossio-Diaz <
***@***.***> wrote:
> Many definitions follow this pattern:
>
> f(x::AbstractFloat) = 2x # any computation here
> f(x::Real) = f(float(x))
>
> But then:
>
> julia> ForwardDiff.derivative(f, 1.)
> ERROR: StackOverflowError:
> Stacktrace:
> [1] f(::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f),Float64},Float64,1})
at ./REPL[3]:1 (repeats 80000 times)
>
> Because float(Dual) gives Dual which is not AbstractFloat. Is there a way
> around this?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#366>, or mute the
> thread
> <
https://github.com/notifications/unsubscribe-auth/AFXArUS8XVaEkZPt2UetUbYm21UVFO9Kks5ujLUlgaJpZM4XTcLM
>
> .
>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFXArT8IrJTSRDrq7Q51nlNxcmyyIwfdks5ujLi1gaJpZM4XTcLM>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many definitions follow this pattern:
But then:
Because
float(Dual)
givesDual
which is notAbstractFloat
. Is there a way around this?The text was updated successfully, but these errors were encountered: