Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ version = "0.4.3"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"

[compat]
Adapt = "3"
ArrayInterfaceCore = "0.1.1"
ForwardDiff = "0.10.3"
ReverseDiff = "1"
julia = "1.6"

[extras]
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["FiniteDiff", "LabelledArrays", "LinearAlgebra", "OrdinaryDiffEq", "Test", "Random", "RecursiveArrayTools", "Pkg", "SafeTestsets", "Optimization", "OptimizationOptimJL", "SciMLSensitivity", "Zygote"]
test = ["LabelledArrays", "LinearAlgebra", "OrdinaryDiffEq", "Test", "RecursiveArrayTools", "Pkg", "SafeTestsets", "Optimization", "OptimizationOptimJL"]
11 changes: 0 additions & 11 deletions src/PreallocationTools.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module PreallocationTools

using ForwardDiff, ArrayInterfaceCore, Adapt
import ReverseDiff

struct DiffCache{T <: AbstractArray, S <: AbstractArray}
du::T
Expand Down Expand Up @@ -100,16 +99,6 @@ function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray}
return buf
end

function Base.getindex(b::LazyBufferCache, u::ReverseDiff.TrackedArray)
s = b.sizemap(size(u)) # required buffer size
T = ReverseDiff.TrackedArray
buf = get!(b.bufs, (T, s)) do
# declare type since b.bufs dictionary is untyped
similar(u, s)
end
return buf
end

export dualcache, get_tmp, LazyBufferCache

end
6 changes: 4 additions & 2 deletions test/core_nesteddual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ end
ps = 2 #use to specify problem size; don't go crazy on this, because of the compilation time...
coeffs = -collect(0.1:0.1:(ps^2 / 10))
cache = dualcache(zeros(ps, ps), levels = 3)
prob = ODEProblem(foo, ones(ps, ps), (0.0, 1.0), (coeffs, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, ones(ps, ps), (0.0, 1.0),
(coeffs, cache))
realsol = solve(prob, TRBDF2(), saveat = 0.0:0.1:10.0, reltol = 1e-8)

function objfun(x, prob, realsol, cache)
Expand All @@ -83,7 +84,8 @@ newtonsol = solve(optprob, Newton())

#an example where chunk_sizes are not the same on all differentiation levels:
cache = dualcache(zeros(ps, ps), [4, 4, 2])
prob = ODEProblem(foo, ones(ps, ps), (0.0, 1.0), (coeffs, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, ones(ps, ps), (0.0, 1.0),
(coeffs, cache))
realsol = solve(prob, TRBDF2(chunk_size = 2), saveat = 0.0:0.1:10.0, reltol = 1e-8)

function objfun(x, prob, realsol, cache)
Expand Down
12 changes: 7 additions & 5 deletions test/core_odes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ chunk_size = 5
u0 = ones(5, 5)
A = ones(5, 5)
cache = dualcache(zeros(5, 5), chunk_size)
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0), (A, cache))
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
@test sol.retcode == :Success

#with auto-detected chunk_size
cache = dualcache(zeros(5, 5))
prob = ODEProblem(foo, ones(5, 5), (0.0, 1.0), (A, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, ones(5, 5), (0.0, 1.0), (A, cache))
sol = solve(prob, TRBDF2())
@test sol.retcode == :Success

Expand All @@ -30,7 +30,8 @@ function foo(du, u, (A, lbc), t)
@. du = u + tmp
nothing
end
prob = ODEProblem(foo, ones(5, 5), (0.0, 1.0), (ones(5, 5), LazyBufferCache()))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, ones(5, 5), (0.0, 1.0),
(ones(5, 5), LazyBufferCache()))
sol = solve(prob, TRBDF2())
@test sol.retcode == :Success

Expand All @@ -46,10 +47,11 @@ function foo(du, u, (A, tmp), t)
end
#with specified chunk_size
chunk_size = 4
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, dualcache(c, chunk_size)))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0),
(A, dualcache(c, chunk_size)))
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
@test sol.retcode == :Success
#with auto-detected chunk_size
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, dualcache(c)))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0), (A, dualcache(c)))
sol = solve(prob, TRBDF2())
@test sol.retcode == :Success
4 changes: 2 additions & 2 deletions test/gpu_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ chunk_size = 10
u0 = cu(rand(10, 10)) #example kept small for test purposes.
A = cu(-randn(10, 10))
cache = dualcache(cu(zeros(10, 10)), chunk_size)
prob = ODEProblem(foo, u0, (0.0f0, 1.0f0), (A, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0f0, 1.0f0), (A, cache))
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
@test sol.retcode == :Success

#with auto-detected chunk_size
u0 = cu(rand(10, 10)) #example kept small for test purposes.
A = cu(-randn(10, 10))
cache = dualcache(cu(zeros(10, 10)))
prob = ODEProblem(foo, u0, (0.0f0, 1.0f0), (A, cache))
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0f0, 1.0f0), (A, cache))
sol = solve(prob, TRBDF2())
@test sol.retcode == :Success

Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if GROUP == "All" || GROUP == "Core"
@safetestset "ODE tests" begin include("core_odes.jl") end
@safetestset "Resizing" begin include("core_resizing.jl") end
@safetestset "Nested Duals" begin include("core_nesteddual.jl") end
@safetestset "ODE Sensitivity analysis" begin include("upstream/sensitivity_analysis.jl") end
end

if !is_APPVEYOR && GROUP == "GPU"
Expand Down
44 changes: 0 additions & 44 deletions test/upstream/sensitivity_analysis.jl

This file was deleted.