Skip to content

Commit

Permalink
Document new type parameter for AutoReverseDiff (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle authored Jul 14, 2024
1 parent d41670e commit b8499f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit b8499f3

Please sign in to comment.