Skip to content

Commit 53755d8

Browse files
Merge pull request #235 from gaurav-arya/ag-ci
Fix CI
2 parents f191085 + 7e41089 commit 53755d8

File tree

7 files changed

+18
-28
lines changed

7 files changed

+18
-28
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
group:
16-
- Core
16+
- All
1717
version:
1818
- '1' # Latest Release
1919
- '~1.6' # Current LTS

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ VertexSafeGraphs = "19fa3120-7c27-5ec5-8db8-b0b0aa330d6f"
2525
[compat]
2626
ADTypes = "0.1"
2727
Adapt = "3.0"
28-
ArrayInterface = "7"
28+
ArrayInterface = "7.4.2"
2929
Compat = "4"
3030
DataStructures = "0.18"
3131
FiniteDiff = "2.8.1"

ext/SparseDiffToolsZygote.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ function SparseDiffTools.numback_hesvec(f, x, v)
4141
end
4242

4343
function SparseDiffTools.autoback_hesvec!(dy, f, x, v,
44-
cache1 = Dual{typeof(ForwardDiff.Tag(DeivVecTag, eltype(x))),
44+
cache1 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(), eltype(x))),
4545
eltype(x), 1
4646
}.(x,
47-
ForwardDiff.Partials.(Tuple.(reshape(v, size(x))))),
48-
cache2 = Dual{typeof(ForwardDiff.Tag(DeivVecTag, eltype(x))),
47+
ForwardDiff.Partials.(tuple.(reshape(v, size(x))))),
48+
cache2 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(), eltype(x))),
4949
eltype(x), 1
5050
}.(x,
51-
ForwardDiff.Partials.(Tuple.(reshape(v, size(x))))))
51+
ForwardDiff.Partials.(tuple.(reshape(v, size(x))))))
5252
g = let f = f
5353
(dx, x) -> dx .= first(Zygote.gradient(f, x))
5454
end
55-
cache1 .= Dual{typeof(ForwardDiff.Tag(DeivVecTag, eltype(x))), eltype(x), 1
56-
}.(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x)))))
55+
# Reset each dual number in cache1 to primal = dual = 1.
56+
cache1 .= eltype(cache1).(x, ForwardDiff.Partials.(tuple.(reshape(v, size(x)))))
5757
g(cache2, cache1)
5858
dy .= partials.(cache2, 1)
5959
end
6060

6161
function SparseDiffTools.autoback_hesvec(f, x, v)
6262
g = x -> first(Zygote.gradient(f, x))
6363
y = Dual{typeof(ForwardDiff.Tag(DeivVecTag, eltype(x))), eltype(x), 1
64-
}.(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x)))))
64+
}.(x, ForwardDiff.Partials.(tuple.(reshape(v, size(x)))))
6565
ForwardDiff.partials.(g(y), 1)
6666
end
6767

src/differentiation/jaches_products.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
277277
cache1 = Dual{
278278
typeof(ForwardDiff.Tag(DeivVecTag(),eltype(u))), eltype(u), 1
279279
}.(u, ForwardDiff.Partials.(tuple.(u)))
280-
cache2 = copy(u)
280+
cache2 = copy(cache1)
281281

282282
(cache1, cache2), autoback_hesvec, autoback_hesvec!
283283
else

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ if GROUP == "All"
1717
@time @safetestset "Greedy star coloring" begin include("test_greedy_star.jl") end
1818
@time @safetestset "Acyclic coloring" begin include("test_acyclic.jl") end
1919
@time @safetestset "Matrix to graph conversion" begin include("test_matrix2graph.jl") end
20-
@time @safetestset "AD using colorvec vector" begin include("test_ad.jl") end
2120
@time @safetestset "Hessian colorvecs" begin include("test_sparse_hessian.jl") end
2221
@time @safetestset "Integration test" begin include("test_integration.jl") end
2322
@time @safetestset "Special matrices" begin include("test_specialmatrices.jl") end
2423
@time @safetestset "Jac Vecs and Hes Vecs" begin include("test_jaches_products.jl") end
2524
@time @safetestset "Vec Jac Products" begin include("test_vecjac_products.jl") end
25+
@time @safetestset "AD using colorvec vector" begin include("test_ad.jl") end
2626
end
2727

2828
if GROUP == "GPU"

test/test_jaches_products.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function h(dy, x)
2020
end
2121

2222
cache1 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(), eltype(x))),
23-
eltype(x), 1}.(x, ForwardDiff.Partials.(Tuple.(v)))
24-
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(), eltype(x))), eltype(x), 1}.(x, ForwardDiff.Partials.(Tuple.(v)))
23+
eltype(x), 1}.(x, ForwardDiff.Partials.(tuple.(v)))
24+
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(), eltype(x))), eltype(x), 1}.(x, ForwardDiff.Partials.(tuple.(v)))
2525
@test num_jacvec!(dy, f, x, v)ForwardDiff.jacobian(f, similar(x), x) * v rtol=1e-6
2626
@test num_jacvec!(dy, f, x, v, similar(v),
2727
similar(v))ForwardDiff.jacobian(f, similar(x), x) * v rtol=1e-6
@@ -50,9 +50,9 @@ cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(), e
5050
@test numback_hesvec(g, x, v)ForwardDiff.hessian(g, x) * v rtol=1e-8
5151

5252
cache3 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(Nothing, eltype(x))), eltype(x), 1
53-
}.(x, ForwardDiff.Partials.(Tuple.(v)))
53+
}.(x, ForwardDiff.Partials.(tuple.(v)))
5454
cache4 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(Nothing, eltype(x))), eltype(x), 1
55-
}.(x, ForwardDiff.Partials.(Tuple.(v)))
55+
}.(x, ForwardDiff.Partials.(tuple.(v)))
5656
@test autoback_hesvec!(dy, g, x, v)ForwardDiff.hessian(g, x) * v rtol=1e-8
5757
@test autoback_hesvec!(dy, g, x, v, cache3, cache4)ForwardDiff.hessian(g, x) * v rtol=1e-8
5858
@test autoback_hesvec(g, x, v)ForwardDiff.hessian(g, x) * v rtol=1e-8
@@ -135,8 +135,8 @@ gmres!(out, L, v)
135135
x = rand(N)
136136
v = rand(N)
137137
L = HesVecGrad(h, x, autodiff = AutoFiniteDiff())
138-
@test L * x num_hesvec(g, x, x)
139-
@test L * v num_hesvec(g, x, v)
138+
@test L * x num_hesvec(g, x, x) rtol=1e-2
139+
@test L * v num_hesvec(g, x, v) rtol=1e-2
140140
@test mul!(dy, L, v)num_hesvec(g, x, v) rtol=1e-2
141141
dy=rand(N);_dy=copy(dy);@test mul!(dy,L,v,a,b)a*num_hesvec(g,x,v)+b*_dy rtol=1e-2
142142
update_coefficients!(L, v, nothing, 0.0)

test/test_vecjac_products.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,4 @@ update_coefficients!(L, v, nothing, 0.0)
2121
L = VecJac(f, x; autodiff = AutoFiniteDiff())
2222
update_coefficients!(L, v, nothing, 0.0)
2323
@test L * v actual_vjp
24-
25-
@info "ZygoteVecJac"
26-
27-
L = ZygoteVecJac(f, x)
28-
actual_vjp = Zygote.jacobian(x -> f(x, nothing, 0.0), x)[1]' * v
29-
update_coefficients!(L, v, nothing, 0.0)
30-
@test L * v actual_vjp
31-
L = ZygoteVecJac(f, x; autodiff = AutoFiniteDiff())
32-
update_coefficients!(L, v, nothing, 0.0)
33-
@test L * v actual_vjp
34-
#
24+
#

0 commit comments

Comments
 (0)