Skip to content

Commit

Permalink
Specialize forwarddiff dual detection for Returns
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Sep 12, 2023
1 parent 7f15b4e commit 473a9b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/forwarddiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ end
anyeltypedual(x::Union{ForwardDiff.AbstractConfig, Module}, counter = 0) = Any
anyeltypedual(x::Type{T}, counter = 0) where {T <: ForwardDiff.AbstractConfig} = Any
anyeltypedual(x::SciMLBase.RecipesBase.AbstractPlot, counter = 0) = Any
anyeltypedual(x::Returns, counter = 0) = anyeltypedual(x.value, counter)

if isdefined(PreallocationTools, :FixedSizeDiffCache)
anyeltypedual(x::PreallocationTools.FixedSizeDiffCache, counter = 0) = Any
Expand Down
4 changes: 1 addition & 3 deletions test/forwarddiff_dual_detection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ p_possibilities17 = [
(Mod, ForwardDiff.Dual(2.0)), (() -> 2.0, ForwardDiff.Dual(2.0)),
(Base.pointer([2.0]), ForwardDiff.Dual(2.0)),
]
VERSION >= v"1.7" && VERSION < v"1.9" &&
push!(p_possibilities17, Returns((a = 2, b = 1.3, c = ForwardDiff.Dual(2.0f0))))
VERSION >= v"1.7" && push!(p_possibilities17, Returns((a = 2, b = 1.3, c = ForwardDiff.Dual(2.0f0))))

for p in p_possibilities17
@show p
Expand Down Expand Up @@ -128,7 +127,6 @@ p_possibilities_uninferrred = [
(; x = Vector{Float64}(undef, 2), y = [[MyStruct3(ForwardDiff.Dual(2.0))]]),
(; x = Matrix{Any}(undef, 2, 2), y = [[MyStruct3(ForwardDiff.Dual(2.0))]]),
]
VERSION >= v"1.9" &&
push!(p_possibilities_uninferrred,
Returns((a = 2, b = 1.3, c = ForwardDiff.Dual(2.0f0))))

Expand Down

0 comments on commit 473a9b2

Please sign in to comment.