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
2 changes: 1 addition & 1 deletion DifferentiationInterface/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ FiniteDifferences = "0.12.31"
ForwardDiff = "0.10.36,1"
GPUArraysCore = "0.2"
GTPSA = "1.4.0"
JuliaFormatter = "1"
JuliaFormatter = "1,2"
LinearAlgebra = "<0.0.1,1"
Mooncake = "0.4.88"
PolyesterForwardDiff = "0.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ to_val(::DI.BatchSizeSettings{B}) where {B} = Val(B)
## Annotations

@inline function get_f_and_df(
f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, ::Val{B}=Val(1)
f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, (::Val{B})=Val(1)
) where {F,M,B}
return f
end

@inline function get_f_and_df(
f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, ::Val{B}=Val(1)
f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, (::Val{B})=Val(1)
) where {F,M,B}
return Const(f)
end
Expand All @@ -34,7 +34,7 @@ end
},
},
mode::Mode,
::Val{B}=Val(1),
(::Val{B})=Val(1),
) where {F,M,B}
# TODO: needs more sophistication for mixed activities
if B == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function DI.pushforward(
DI.check_prep(f, prep, backend, x, tx, contexts...)
fc = DI.fix_tail(f, map(DI.unwrap, contexts)...)
ty = map(tx) do dx
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
yt = fc(prep.xt)
if yt isa Number
return yt[1]
Expand All @@ -71,7 +71,7 @@ function DI.pushforward!(
fc = DI.fix_tail(f, map(DI.unwrap, contexts)...)
for b in eachindex(tx, ty)
dx, dy = tx[b], ty[b]
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
yt = fc(prep.xt)
map!(t -> t[1], dy, yt)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function DI.pushforward(
DI.check_prep(f!, y, prep, backend, x, tx, contexts...)
fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...)
ty = map(tx) do dx
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
fc!(prep.yt, prep.xt)
dy = map(t -> t[1], prep.yt)
return dy
Expand All @@ -79,7 +79,7 @@ function DI.pushforward!(
fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...)
for b in eachindex(tx, ty)
dx, dy = tx[b], ty[b]
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
fc!(prep.yt, prep.xt)
map!(t -> t[1], dy, prep.yt)
end
Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterfaceTest/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ForwardDiff = "0.10.36,1"
Functors = "0.4, 0.5"
JET = "0.4 - 0.8, 0.9"
JLArrays = "0.1, 0.2"
JuliaFormatter = "1"
JuliaFormatter = "1,2"
LinearAlgebra = "<0.0.1,1"
Lux = "1.1.0"
LuxTestUtils = "1.3.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return sum(sin.(x.a)) + sum(cos.(x.b))
end

comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=-sin.(x.b))
comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=(-sin.(x.b)))

Check warning on line 13 in DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl#L13

Added line #L13 was not covered by tests

function comp_to_num_pushforward(x, dx)
g = comp_to_num_gradient(x)
Expand Down
36 changes: 12 additions & 24 deletions DifferentiationInterfaceTest/src/tests/correctness_eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -124,8 +123,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 126 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L126

Added line #L126 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -208,8 +206,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 209 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L209

Added line #L209 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -286,8 +283,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 286 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L286

Added line #L286 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -375,8 +371,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 374 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L374

Added line #L374 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -445,8 +440,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 443 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L443

Added line #L443 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -532,8 +526,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 529 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L529

Added line #L529 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -599,8 +592,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 595 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L595

Added line #L595 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -682,8 +674,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 677 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L677

Added line #L677 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -765,8 +756,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 759 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L759

Added line #L759 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -867,8 +857,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 860 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L860

Added line #L860 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down Expand Up @@ -934,8 +923,7 @@
contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...)
local prepstrict
preptup_cands_val, preptup_cands_noval = map(1:2) do _
new_smaller =
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba

Check warning on line 926 in DifferentiationInterfaceTest/src/tests/correctness_eval.jl

View check run for this annotation

Codecov / codecov/patch

DifferentiationInterfaceTest/src/tests/correctness_eval.jl#L926

Added line #L926 was not covered by tests
deepcopy(scen)
else
deepcopy(smaller)
Expand Down
Loading