Skip to content

Document new type parameter for AutoReverseDiff #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2024
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
4 changes: 2 additions & 2 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function Base.show(io::IO, backend::AutoPolyesterForwardDiff{chunksize}) where {
end

"""
AutoReverseDiff
AutoReverseDiff{compile}

Struct used to select the [ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl) backend for automatic differentiation.

Expand All @@ -231,7 +231,7 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).

# Fields

- `compile::Union{Val, Bool}`: whether to [compile the tape](https://juliadiff.org/ReverseDiff.jl/api/#ReverseDiff.compile) prior to differentiation
- `compile::Union{Val, Bool}`: whether to [compile the tape](https://juliadiff.org/ReverseDiff.jl/api/#ReverseDiff.compile) prior to differentiation (the boolean version is also the type parameter)
"""
struct AutoReverseDiff{C} <: AbstractADType
compile::Bool # this field is left for legacy reasons
Expand Down
6 changes: 3 additions & 3 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ end
@testset "AutoReverseDiff" begin
ad = @inferred AutoReverseDiff()
@test ad isa AbstractADType
@test ad isa AutoReverseDiff
@test ad isa AutoReverseDiff{false}
@test mode(ad) isa ReverseMode
@test !ad.compile
@test_deprecated ad.compile

ad = AutoReverseDiff(; compile = true)
@test ad isa AbstractADType
@test ad isa AutoReverseDiff
@test ad isa AutoReverseDiff{true}
@test mode(ad) isa ReverseMode
@test ad.compile
@test_deprecated ad.compile

ad = @inferred AutoReverseDiff(; compile = Val(true))
@test ad isa AbstractADType
@test ad isa AutoReverseDiff
@test ad isa AutoReverseDiff{true}
@test mode(ad) isa ReverseMode
@test ad.compile
@test_deprecated ad.compile
Expand Down
Loading