Skip to content

Commit 2b3f360

Browse files
authored
feat: make dense_ad act as the identity on a dense backend (#107)
* feat: make `dense_ad` act as the identity on a dense backend * Typo
1 parent 4b707db commit 2b3f360

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ADTypes"
22
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
authors = ["Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors"]
4-
version = "1.13.0"
4+
version = "1.14.0"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/sparse.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,16 @@ end
225225

226226
"""
227227
dense_ad(ad::AutoSparse)::AbstractADType
228+
dense_ad(ad::AbstractADType)::AbstractADType
228229
229-
Return the underlying AD package for a sparse AD choice.
230+
Return the underlying AD package for a sparse AD choice, act as the identity on a dense AD choice.
230231
231232
# See also
232233
233234
- [`AutoSparse`](@ref)
234235
"""
235236
dense_ad(ad::AutoSparse) = ad.dense_ad
237+
dense_ad(ad::AbstractADType) = ad
236238

237239
mode(sparse_ad::AutoSparse) = mode(dense_ad(sparse_ad))
238240

test/sparse.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
elseif mode(ad) isa SymbolicMode
1212
@test mode(sparse_ad) isa SymbolicMode
1313
end
14+
@test dense_ad(ad) == ad
1415
@test dense_ad(sparse_ad) == ad
1516
@test sparsity_detector(sparse_ad) == NoSparsityDetector()
1617
@test coloring_algorithm(sparse_ad) == NoColoringAlgorithm()

0 commit comments

Comments
 (0)