Skip to content

Commit

Permalink
fix: use PolyesterForwardDiff's inner gradient in its HVP (#610)
Browse files Browse the repository at this point in the history
* fix: use PolyesterForwardDiff's inner gradient in its HVP

* SecondOrder
  • Loading branch information
gdalle authored Nov 5, 2024
1 parent 3b978b8 commit fb16fab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DifferentiationInterface/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DifferentiationInterface"
uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
authors = ["Guillaume Dalle", "Adrian Hill"]
version = "0.6.19"
version = "0.6.20"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using DifferentiationInterface:
NoJacobianPrep,
PushforwardPrep,
SecondDerivativePrep,
SecondOrder,
unwrap,
with_contexts
using LinearAlgebra: mul!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ end
function DI.prepare_hvp(
f, backend::AutoPolyesterForwardDiff, x, tx::NTuple, contexts::Vararg{Context,C}
) where {C}
return DI.prepare_hvp(f, single_threaded(backend), x, tx, contexts...)
return DI.prepare_hvp(
f, SecondOrder(single_threaded(backend), backend), x, tx, contexts...
)
end

function DI.hvp(
Expand All @@ -294,7 +296,9 @@ function DI.hvp(
tx::NTuple,
contexts::Vararg{Context,C},
) where {C}
return DI.hvp(f, prep, single_threaded(backend), x, tx, contexts...)
return DI.hvp(
f, prep, SecondOrder(single_threaded(backend), backend), x, tx, contexts...
)
end

function DI.hvp!(
Expand All @@ -306,7 +310,9 @@ function DI.hvp!(
tx::NTuple,
contexts::Vararg{Context,C},
) where {C}
return DI.hvp!(f, tg, prep, single_threaded(backend), x, tx, contexts...)
return DI.hvp!(
f, tg, prep, SecondOrder(single_threaded(backend), backend), x, tx, contexts...
)
end

function DI.gradient_and_hvp(
Expand All @@ -317,7 +323,9 @@ function DI.gradient_and_hvp(
tx::NTuple,
contexts::Vararg{Context,C},
) where {C}
return DI.gradient_and_hvp(f, prep, single_threaded(backend), x, tx, contexts...)
return DI.gradient_and_hvp(
f, prep, SecondOrder(single_threaded(backend), backend), x, tx, contexts...
)
end

function DI.gradient_and_hvp!(
Expand All @@ -331,7 +339,14 @@ function DI.gradient_and_hvp!(
contexts::Vararg{Context,C},
) where {C}
return DI.gradient_and_hvp!(
f, grad, tg, prep, single_threaded(backend), x, tx, contexts...
f,
grad,
tg,
prep,
SecondOrder(single_threaded(backend), backend),
x,
tx,
contexts...,
)
end

Expand Down

2 comments on commit fb16fab

@gdalle
Copy link
Member Author

@gdalle gdalle commented on fb16fab Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=DifferentiationInterface

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/118763

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a DifferentiationInterface-v0.6.20 -m "<description of version>" fb16fabbe7c4904ee179ae730c8fe63e0138ba48
git push origin DifferentiationInterface-v0.6.20

Please sign in to comment.