Skip to content

Commit bc3d1b6

Browse files
Merge pull request #40 from frankschae/ReverseDiff_buffer
Move ReverseDiff defs for LazyBuffer to SciMLSensitivity
2 parents 2f5e2b6 + 7036242 commit bc3d1b6

File tree

7 files changed

+14
-72
lines changed

7 files changed

+14
-72
lines changed

Project.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,23 @@ version = "0.4.3"
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
99
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
10-
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
1110

1211
[compat]
1312
Adapt = "3"
1413
ArrayInterfaceCore = "0.1.1"
1514
ForwardDiff = "0.10.3"
16-
ReverseDiff = "1"
1715
julia = "1.6"
1816

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

3428
[targets]
35-
test = ["FiniteDiff", "LabelledArrays", "LinearAlgebra", "OrdinaryDiffEq", "Test", "Random", "RecursiveArrayTools", "Pkg", "SafeTestsets", "Optimization", "OptimizationOptimJL", "SciMLSensitivity", "Zygote"]
29+
test = ["LabelledArrays", "LinearAlgebra", "OrdinaryDiffEq", "Test", "RecursiveArrayTools", "Pkg", "SafeTestsets", "Optimization", "OptimizationOptimJL"]

src/PreallocationTools.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module PreallocationTools
22

33
using ForwardDiff, ArrayInterfaceCore, Adapt
4-
import ReverseDiff
54

65
struct DiffCache{T <: AbstractArray, S <: AbstractArray}
76
du::T
@@ -100,16 +99,6 @@ function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray}
10099
return buf
101100
end
102101

103-
function Base.getindex(b::LazyBufferCache, u::ReverseDiff.TrackedArray)
104-
s = b.sizemap(size(u)) # required buffer size
105-
T = ReverseDiff.TrackedArray
106-
buf = get!(b.bufs, (T, s)) do
107-
# declare type since b.bufs dictionary is untyped
108-
similar(u, s)
109-
end
110-
return buf
111-
end
112-
113102
export dualcache, get_tmp, LazyBufferCache
114103

115104
end

test/core_nesteddual.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ end
5959
ps = 2 #use to specify problem size; don't go crazy on this, because of the compilation time...
6060
coeffs = -collect(0.1:0.1:(ps^2 / 10))
6161
cache = dualcache(zeros(ps, ps), levels = 3)
62-
prob = ODEProblem(foo, ones(ps, ps), (0.0, 1.0), (coeffs, cache))
62+
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, ones(ps, ps), (0.0, 1.0),
63+
(coeffs, cache))
6364
realsol = solve(prob, TRBDF2(), saveat = 0.0:0.1:10.0, reltol = 1e-8)
6465

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

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

8991
function objfun(x, prob, realsol, cache)

test/core_odes.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ chunk_size = 5
1313
u0 = ones(5, 5)
1414
A = ones(5, 5)
1515
cache = dualcache(zeros(5, 5), chunk_size)
16-
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, cache))
16+
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0), (A, cache))
1717
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
1818
@test sol.retcode == :Success
1919

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

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

@@ -46,10 +47,11 @@ function foo(du, u, (A, tmp), t)
4647
end
4748
#with specified chunk_size
4849
chunk_size = 4
49-
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, dualcache(c, chunk_size)))
50+
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0),
51+
(A, dualcache(c, chunk_size)))
5052
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
5153
@test sol.retcode == :Success
5254
#with auto-detected chunk_size
53-
prob = ODEProblem(foo, u0, (0.0, 1.0), (A, dualcache(c)))
55+
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0, 1.0), (A, dualcache(c)))
5456
sol = solve(prob, TRBDF2())
5557
@test sol.retcode == :Success

test/gpu_all.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ chunk_size = 10
3939
u0 = cu(rand(10, 10)) #example kept small for test purposes.
4040
A = cu(-randn(10, 10))
4141
cache = dualcache(cu(zeros(10, 10)), chunk_size)
42-
prob = ODEProblem(foo, u0, (0.0f0, 1.0f0), (A, cache))
42+
prob = ODEProblem{true, SciMLBase.FullSpecialize}(foo, u0, (0.0f0, 1.0f0), (A, cache))
4343
sol = solve(prob, TRBDF2(chunk_size = chunk_size))
4444
@test sol.retcode == :Success
4545

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

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ if GROUP == "All" || GROUP == "Core"
1515
@safetestset "ODE tests" begin include("core_odes.jl") end
1616
@safetestset "Resizing" begin include("core_resizing.jl") end
1717
@safetestset "Nested Duals" begin include("core_nesteddual.jl") end
18-
@safetestset "ODE Sensitivity analysis" begin include("upstream/sensitivity_analysis.jl") end
1918
end
2019

2120
if !is_APPVEYOR && GROUP == "GPU"

test/upstream/sensitivity_analysis.jl

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)