Skip to content

Commit 81db6d0

Browse files
committed
Merge branch 'main' into pr/penelopeysm/835
2 parents d0393fc + 4a59a3a commit 81db6d0

11 files changed

Lines changed: 202 additions & 135 deletions

File tree

.github/workflows/Test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
files: lcov.info
8787
flags: DI
8888
token: ${{ secrets.CODECOV_TOKEN }}
89-
fail_ci_if_error: true
89+
fail_ci_if_error: false
9090

9191
test-DIT:
9292
name: ${{ matrix.version }} - DIT (${{ matrix.group }})
@@ -128,9 +128,9 @@ jobs:
128128
Pkg.Registry.update();
129129
Pkg.develop(path="./DifferentiationInterface");
130130
if ENV["JULIA_DI_PR_DRAFT"] == "true";
131-
Pkg.test("DifferentiationInterfaceTest"; coverage=true, julia_args=["-O1"]);
131+
Pkg.test("DifferentiationInterfaceTest"; allow_reresolve=false, coverage=true, julia_args=["-O1"]);
132132
else;
133-
Pkg.test("DifferentiationInterfaceTest"; coverage=true);
133+
Pkg.test("DifferentiationInterfaceTest"; allow_reresolve=false, coverage=true);
134134
end;'
135135
- uses: julia-actions/julia-processcoverage@v1
136136
with:
@@ -140,4 +140,4 @@ jobs:
140140
files: lcov.info
141141
flags: DIT
142142
token: ${{ secrets.CODECOV_TOKEN }}
143-
fail_ci_if_error: true
143+
fail_ci_if_error: false

DifferentiationInterface/CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.5...main)
8+
## [Unreleased](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.6...main)
9+
10+
## [0.7.6](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.5...DifferentiationInterface-v0.7.6)
11+
12+
### Fixed
13+
14+
- Put test deps into `test/Project.toml` ([#840](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/840))
15+
- Set up `pre-commit` ([#837](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/837))
16+
17+
### Fixed
18+
19+
- Put test deps into `test/Project.toml` ([#840](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/840))
920

1021
## [0.7.5](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.4...DifferentiationInterface-v0.7.5)
1122

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DifferentiationInterface"
22
uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
33
authors = ["Guillaume Dalle", "Adrian Hill"]
4-
version = "0.7.5"
4+
version = "0.7.6"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -57,89 +57,26 @@ DifferentiationInterfaceZygoteExt = ["Zygote", "ForwardDiff"]
5757

5858
[compat]
5959
ADTypes = "1.17.0"
60-
Aqua = "0.8.12"
6160
ChainRulesCore = "1.23.0"
62-
ComponentArrays = "0.15.27"
63-
DataFrames = "1.7.0"
64-
Dates = "1"
6561
DiffResults = "1.1.0"
6662
Diffractor = "=0.2.6"
6763
Enzyme = "0.13.39"
6864
EnzymeCore = "0.8.8"
69-
ExplicitImports = "1.10.1"
7065
FastDifferentiation = "0.4.3"
7166
FiniteDiff = "2.27.0"
7267
FiniteDifferences = "0.12.31"
7368
ForwardDiff = "0.10.36,1"
7469
GPUArraysCore = "0.2"
7570
GTPSA = "1.4.0"
76-
JET = "0.9"
77-
JLArrays = "0.2.0"
7871
LinearAlgebra = "1"
7972
Mooncake = "0.4.147"
80-
Pkg = "1"
8173
PolyesterForwardDiff = "0.1.2"
82-
Random = "1"
8374
ReverseDiff = "1.15.1"
8475
SparseArrays = "1"
8576
SparseConnectivityTracer = "0.6.14, 1"
8677
SparseMatrixColorings = "0.4.9"
87-
StableRNGs = "1.0.1"
8878
StaticArrays = "1.9.7"
8979
Symbolics = "5.27.1, 6"
90-
Test = "1"
9180
Tracker = "0.2.33"
9281
Zygote = "0.6.69, 0.7"
9382
julia = "1.10"
94-
95-
[extras]
96-
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
97-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
98-
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
99-
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
100-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
101-
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
102-
Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c"
103-
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
104-
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
105-
FastDifferentiation = "eb9bf01b-bf85-4b60-bf87-ee5de06c00be"
106-
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
107-
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
108-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
109-
GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8"
110-
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
111-
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
112-
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
113-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
114-
PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
115-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
116-
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
117-
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
118-
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
119-
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
120-
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
121-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
122-
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
123-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
124-
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
125-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
126-
127-
[targets]
128-
test = [
129-
"ADTypes",
130-
"Aqua",
131-
"ComponentArrays",
132-
"DataFrames",
133-
"Dates",
134-
"ExplicitImports",
135-
"JET",
136-
"JLArrays",
137-
"Pkg",
138-
"Random",
139-
"SparseArrays",
140-
"SparseConnectivityTracer",
141-
"SparseMatrixColorings",
142-
"StableRNGs",
143-
"StaticArrays",
144-
"Test",
145-
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[deps]
2+
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
3+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
4+
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
5+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
6+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
7+
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
8+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
9+
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
10+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
12+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
13+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
14+
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
15+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
16+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
17+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
18+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
19+
20+
[compat]
21+
Aqua = "0.8.12"
22+
ComponentArrays = "0.15.27"
23+
DataFrames = "1.7.0"
24+
Dates = "1"
25+
ExplicitImports = "1.10.1"
26+
JET = "0.9"
27+
JLArrays = "0.2.0"
28+
Pkg = "1"
29+
Random = "1"
30+
StableRNGs = "1.0.1"
31+
Test = "1"

DifferentiationInterfaceTest/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.10.0...main)
8+
## [Unreleased](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.10.1...main)
9+
10+
## [0.10.1](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.10.0...DifferentiationInterfaceTest-v0.10.1)
11+
12+
### Added
13+
14+
- Compute Scenario results with a reference backend ([#839](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/839))
915

1016
### Fixed
1117

18+
- Put test deps into `test/Project.toml` ([#840](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/840))
19+
- Set up `pre-commit` ([#837](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/837))
1220
- Bump compat for SparseConnectivityTracer v1 ([#823](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/823))
1321

1422
## [0.10.0](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.9.6...DifferentiationInterfaceTest-v0.10.0)

DifferentiationInterfaceTest/Project.toml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ DifferentiationInterfaceTestLuxExt = [
4343
DifferentiationInterfaceTestStaticArraysExt = "StaticArrays"
4444

4545
[compat]
46-
Aqua = "0.8.12"
4746
ADTypes = "1.7.0"
4847
AllocCheck = "0.2"
4948
Chairmarks = "1.2.1"
5049
ComponentArrays = "0.15"
5150
DataFrames = "1.6.1"
5251
DifferentiationInterface = "0.7.0"
5352
DocStringExtensions = "0.8,0.9"
54-
ExplicitImports = "1.10.1"
55-
FiniteDiff = "2.27.0"
5653
FiniteDifferences = "0.12"
5754
Flux = "0.16"
5855
ForwardDiff = "0.10.36,1"
@@ -62,62 +59,11 @@ JLArrays = "0.1, 0.2"
6259
LinearAlgebra = "1"
6360
Lux = "1.1.0"
6461
LuxTestUtils = "1.3.1"
65-
Pkg = "1"
6662
ProgressMeter = "1"
6763
Random = "1"
6864
SparseArrays = "1"
69-
SparseConnectivityTracer = "0.5.0,0.6,1"
70-
SparseMatrixColorings = "0.4.9"
7165
StaticArrays = "1.9"
7266
Statistics = "1"
7367
Test = "1"
7468
Zygote = "0.6, 0.7"
7569
julia = "1.10"
76-
77-
[extras]
78-
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
79-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
80-
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
81-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
82-
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
83-
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
84-
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
85-
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
86-
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
87-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
88-
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
89-
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
90-
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
91-
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
92-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
93-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
94-
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
95-
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
96-
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
97-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
98-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
99-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
100-
101-
[targets]
102-
test = [
103-
"ADTypes",
104-
"Aqua",
105-
"ComponentArrays",
106-
"DataFrames",
107-
"DifferentiationInterface",
108-
"ExplicitImports",
109-
"FiniteDiff",
110-
"FiniteDifferences",
111-
"Flux",
112-
"ForwardDiff",
113-
"JET",
114-
"JLArrays",
115-
"Pkg",
116-
"Random",
117-
"SparseArrays",
118-
"SparseConnectivityTracer",
119-
"SparseMatrixColorings",
120-
"StaticArrays",
121-
"Test",
122-
"Zygote",
123-
]

DifferentiationInterfaceTest/docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ DifferentiationInterfaceTest
1313

1414
```@docs
1515
Scenario
16+
compute_results
1617
test_differentiation
1718
benchmark_differentiation
1819
```

DifferentiationInterfaceTest/src/DifferentiationInterfaceTest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ include("tests/allocs_eval.jl")
136136
include("test_differentiation.jl")
137137

138138
export FIRST_ORDER, SECOND_ORDER
139-
export Scenario
139+
export Scenario, compute_results
140140
export test_differentiation, benchmark_differentiation
141141
export DifferentiationBenchmarkDataRow
142142

DifferentiationInterfaceTest/src/scenarios/modify.jl

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,91 @@ closurify(scens::AbstractVector{<:Scenario}) = closurify.(scens)
366366
constantify(scens::AbstractVector{<:Scenario}) = constantify.(scens)
367367
cachify(scens::AbstractVector{<:Scenario}; use_tuples) = cachify.(scens; use_tuples)
368368
constantorcachify(scens::AbstractVector{<:Scenario}) = constantorcachify.(scens)
369+
370+
## Compute results with backend
371+
372+
get_res1(::Val, args...) = nothing
373+
get_res2(::Val, args...) = nothing
374+
375+
function get_res1(::Val{:derivative}, f, backend::AbstractADType, x, contexts...)
376+
return derivative(f, backend, x, contexts...)
377+
end
378+
function get_res1(::Val{:derivative}, f!, y, backend::AbstractADType, x, contexts...)
379+
return derivative(f!, y, backend, x, contexts...)
380+
end
381+
function get_res1(::Val{:gradient}, f, backend::AbstractADType, x, contexts...)
382+
return gradient(f, backend, x, contexts...)
383+
end
384+
function get_res1(::Val{:jacobian}, f, backend::AbstractADType, x, contexts...)
385+
return jacobian(f, backend, x, contexts...)
386+
end
387+
function get_res1(::Val{:jacobian}, f!, y, backend::AbstractADType, x, contexts...)
388+
return jacobian(f!, y, backend, x, contexts...)
389+
end
390+
function get_res1(::Val{:second_derivative}, f, backend::AbstractADType, x, contexts...)
391+
return derivative(f, backend, x, contexts...)
392+
end
393+
function get_res1(::Val{:hessian}, f, backend::AbstractADType, x, contexts...)
394+
return gradient(f, backend, x, contexts...)
395+
end
396+
397+
function get_res2(::Val{:second_derivative}, f, backend::AbstractADType, x, contexts...)
398+
return second_derivative(f, backend, x, contexts...)
399+
end
400+
function get_res2(::Val{:hessian}, f, backend::AbstractADType, x, contexts...)
401+
return hessian(f, backend, x, contexts...)
402+
end
403+
404+
function get_res1(::Val{:pushforward}, f, backend::AbstractADType, x, t, contexts...)
405+
return pushforward(f, backend, x, t, contexts...)
406+
end
407+
function get_res1(::Val{:pushforward}, f!, y, backend::AbstractADType, x, t, contexts...)
408+
return pushforward(f!, y, backend, x, t, contexts...)
409+
end
410+
function get_res1(::Val{:pullback}, f, backend::AbstractADType, x, t, contexts...)
411+
return pullback(f, backend, x, t, contexts...)
412+
end
413+
function get_res1(::Val{:pullback}, f!, y, backend::AbstractADType, x, t, contexts...)
414+
return pullback(f!, y, backend, x, t, contexts...)
415+
end
416+
function get_res1(::Val{:hvp}, f, backend::AbstractADType, x, t, contexts...)
417+
return gradient(f, backend, x, contexts...)
418+
end
419+
420+
function get_res2(::Val{:hvp}, f, backend::AbstractADType, x, t, contexts...)
421+
return hvp(f, backend, x, t, contexts...)
422+
end
423+
424+
"""
425+
compute_results(scen::Scenario, backend::AbstractADType)
426+
427+
Return a scenario identical to `scen` but where the first- and second-order results `res1` and `res2` have been computed with the given differentiation `backend`.
428+
429+
Useful for comparison of outputs between backends.
430+
"""
431+
function compute_results(
432+
scen::Scenario{op,pl_op,pl_fun}, backend::AbstractADType
433+
) where {op,pl_op,pl_fun}
434+
(; f, y, x, t, contexts, prep_args, name) = deepcopy(scen)
435+
if pl_fun == :in
436+
if isnothing(t)
437+
new_res1 = get_res1(Val(op), f, y, backend, x, contexts...)
438+
new_res2 = get_res2(Val(op), f, y, backend, x, contexts...)
439+
else
440+
new_res1 = get_res1(Val(op), f, y, backend, x, t, contexts...)
441+
new_res2 = get_res2(Val(op), f, y, backend, x, t, contexts...)
442+
end
443+
else
444+
if isnothing(t)
445+
new_res1 = get_res1(Val(op), f, backend, x, contexts...)
446+
new_res2 = get_res2(Val(op), f, backend, x, contexts...)
447+
else
448+
new_res1 = get_res1(Val(op), f, backend, x, t, contexts...)
449+
new_res2 = get_res2(Val(op), f, backend, x, t, contexts...)
450+
end
451+
end
452+
new_scen = Scenario{op,pl_op,pl_fun}(;
453+
f, x, y, t, contexts, res1=new_res1, res2=new_res2, prep_args, name
454+
)
455+
return new_scen
456+
end

0 commit comments

Comments
 (0)