Skip to content

Commit

Permalink
Add depwarn for .compile
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jun 22, 2024
1 parent efdc12e commit d932bf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ struct AutoReverseDiff{C} <: AbstractADType
end
end

function Base.getproperty(ad::AutoReverseDiff, s::Symbol)
if s === :compile
Base.depwarn(
"`ad.compile` where `ad` is `AutoReverseDiff` has been deprecated and \
will be removed in v2. Instead it is available as a compile-time \
constant as `AutoReverseDiff{true}` or `AutoReverseDiff{false}`.",
:getproperty)
end
return getfield(ad, s)
end

mode(::AutoReverseDiff) = ReverseMode()

"""
Expand Down
3 changes: 3 additions & 0 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,21 @@ end
@test ad isa AutoReverseDiff
@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 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 mode(ad) isa ReverseMode
@test ad.compile
@test_deprecated ad.compile
end

@testset "AutoSymbolics" begin
Expand Down

0 comments on commit d932bf3

Please sign in to comment.