-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ruleconfig support and Zygote tests * actually run the tests :) * avoid loading Yota * lower bound Zygote compat * move imports * bump version * avoid testing ruleconfig in 1.0 * remove Zygote compat
- Loading branch information
1 parent
9a3b564
commit 8f0d6db
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
ReverseRuleConfigBackend | ||
AD backend that uses reverse mode with any ChainRules-compatible reverse-mode AD package. | ||
""" | ||
struct ReverseRuleConfigBackend{RC <: RuleConfig} <: AbstractReverseMode | ||
ruleconfig::RC | ||
end | ||
|
||
AD.@primitive function pullback_function(ab::ReverseRuleConfigBackend, f, xs...) | ||
return (vs) -> begin | ||
_, back = rrule_via_ad(ab.ruleconfig, f, xs...) | ||
if vs isa Tuple && length(vs) === 1 | ||
return Base.tail(back(vs[1])) | ||
else | ||
return Base.tail(back(vs)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using AbstractDifferentiation | ||
using Test | ||
using Zygote | ||
|
||
@testset "ReverseRuleConfigBackend(ZygoteRuleConfig())" begin | ||
backends = [@inferred(AD.ZygoteBackend())] | ||
@testset for backend in backends | ||
@testset "Derivative" begin | ||
test_derivatives(backend) | ||
end | ||
@testset "Gradient" begin | ||
test_gradients(backend) | ||
end | ||
@testset "Jacobian" begin | ||
test_jacobians(backend) | ||
end | ||
@testset "jvp" begin | ||
test_jvp(backend) | ||
end | ||
@testset "j′vp" begin | ||
test_j′vp(backend) | ||
end | ||
@testset "Lazy Derivative" begin | ||
test_lazy_derivatives(backend) | ||
end | ||
@testset "Lazy Gradient" begin | ||
test_lazy_gradients(backend) | ||
end | ||
@testset "Lazy Jacobian" begin | ||
test_lazy_jacobians(backend) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8f0d6db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
8f0d6db
There was a problem hiding this comment.
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/54230
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: