Skip to content

Make sparsity detection and coloring interfaces public #83

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 5 commits into from
Sep 9, 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: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name = "ADTypes"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
authors = [
"Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors",
]
authors = ["Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors"]
version = "1.7.1"

[deps]
Expand Down
23 changes: 22 additions & 1 deletion src/ADTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Base.broadcastable(ad::AbstractADType) = Ref(ad)
@inline _unwrap_val(::Val{T}) where {T} = T
@inline _unwrap_val(x) = x

include("compat.jl") # @public macro
include("mode.jl")
include("dense.jl")
include("sparse.jl")
Expand All @@ -30,8 +31,8 @@ if !isdefined(Base, :get_extension)
include("../ext/ADTypesEnzymeCoreExt.jl")
end

# Automatic Differentiation
export AbstractADType

export AutoChainRules,
AutoDiffractor,
AutoEnzyme,
Expand All @@ -46,8 +47,28 @@ export AutoChainRules,
AutoTapir,
AutoTracker,
AutoZygote
@public AbstractMode
@public ForwardMode, ReverseMode, ForwardOrReverseMode, SymbolicMode
@public mode
@public Auto

# Sparse Automatic Differentiation
export AutoSparse
@public dense_ad

# Sparsity detection
export AbstractSparsityDetector
export jacobian_sparsity, hessian_sparsity
@public sparsity_detector
@public NoSparsityDetector
@public KnownJacobianSparsityDetector
@public KnownHessianSparsityDetector

# Matrix coloring
export AbstractColoringAlgorithm
export column_coloring, row_coloring, symmetric_coloring
@public coloring_algorithm
@public NoColoringAlgorithm

# legacy exports are taken care of by @deprecated

Expand Down
11 changes: 11 additions & 0 deletions src/compat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Backward compatibility with `public` keyword, as suggested in
# https://discourse.julialang.org/t/is-compat-jl-worth-it-for-the-public-keyword/119041/22
macro public(ex)
if VERSION >= v"1.11.0-DEV.469"
args = ex isa Symbol ? (ex,) :
Base.isexpr(ex, :tuple) ? ex.args : error("Failed to mark $ex as public")
esc(Expr(:public, args...))
else
nothing
end
end
23 changes: 23 additions & 0 deletions test/public.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using ADTypes
using Test

public_symbols = (
:AbstractMode,
:ForwardMode,
:ReverseMode,
:ForwardOrReverseMode,
:SymbolicMode,
:mode,
:Auto,
# Sparse Automatic Differentiation
:dense_ad,
# Sparsity detection
:sparsity_detector,
:NoSparsityDetector,
:KnownJacobianSparsityDetector,
:KnownHessianSparsityDetector,
# Matrix coloring
:coloring_algorithm,
:NoColoringAlgorithm
)
@test public_symbols ⊆ names(ADTypes)
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ end
@testset "Miscellaneous" begin
include("misc.jl")
end
if VERSION >= v"1.11.0-DEV.469"
@testset "Public" begin
include("public.jl")
end
end
end
Loading