-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Description
I'm upgrading a few projects from Julia v0.6 to Juila 1.1 and I'm getting this interesting edge case error.
This used to work on Julia v0.6, where the gradient takes an empty input.
I think Julia v0.6 version is stuck on ForwardDiff v0.7.5.
julia> f(x) = 1.0
f (generic function with 1 method)
julia> g = x -> ForwardDiff.gradient(f, x)
(::#1) (generic function with 1 method)
julia> g([1.0])
1-element Array{Float64,1}:
0.0
julia> g(zeros(Float64, 0))
0-element Array{Float64,1}On Julia v1.1, I'm using ForwardDiff v0.10.3. And the same example triggers a BoundsError.
julia> f(x) = 1.0
f (generic function with 1 method)
julia> g = x -> ForwardDiff.gradient(f, x)
#3 (generic function with 1 method)
julia> g([1.0])
1-element Array{Float64,1}:
0.0
julia> g(zeros(Float64, 0))
ERROR: BoundsError: attempt to access 12-element Array{ForwardDiff.Chunk,1} at index [0]
Stacktrace:
[1] getindex at ./array.jl:729 [inlined]
[2] ForwardDiff.Chunk(::Int64, ::Int64) at /home/felipenoris/.julia/packages/ForwardDiff/N0wMF/src/prelude.jl:17
[3] Type at /home/felipenoris/.julia/packages/ForwardDiff/N0wMF/src/prelude.jl:22 [inlined] (repeats 2 times)
[4] ForwardDiff.GradientConfig(::typeof(f), ::Array{Float64,1}) at /home/felipenoris/.julia/packages/ForwardDiff/N0wMF/src/config.jl:121
[5] gradient(::Function, ::Array{Float64,1}) at /home/felipenoris/.julia/packages/ForwardDiff/N0wMF/src/gradient.jl:15
[6] (::getfield(Main, Symbol("##3#4")))(::Array{Float64,1}) at ./REPL[6]:1
[7] top-level scope at none:0Octogonapus
Metadata
Metadata
Assignees
Labels
No labels