From 42a07001bdcbe142b61dd624fd571125b0e811ce Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Thu, 6 Mar 2025 07:46:23 +0100 Subject: [PATCH 1/2] feat: make `dense_ad` act as the identity on a dense backend --- Project.toml | 2 +- src/sparse.jl | 4 +++- test/sparse.jl | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1f58616..76f78f5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ADTypes" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" authors = ["Vaibhav Dixit , Guillaume Dalle and contributors"] -version = "1.13.0" +version = "1.14.0" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/sparse.jl b/src/sparse.jl index 953c334..1b389c8 100644 --- a/src/sparse.jl +++ b/src/sparse.jl @@ -225,14 +225,16 @@ end """ dense_ad(ad::AutoSparse)::AbstractADType + dense_ad(ad::AbstractADType)::AbstractADType -Return the underlying AD package for a sparse AD choice. +Return the underlying AD package for a sparse AD choice, acts as the identity on a dense AD choice. # See also - [`AutoSparse`](@ref) """ dense_ad(ad::AutoSparse) = ad.dense_ad +dense_ad(ad::AbstractADType) = ad mode(sparse_ad::AutoSparse) = mode(dense_ad(sparse_ad)) diff --git a/test/sparse.jl b/test/sparse.jl index 10c1c01..0d9df5e 100644 --- a/test/sparse.jl +++ b/test/sparse.jl @@ -11,6 +11,7 @@ elseif mode(ad) isa SymbolicMode @test mode(sparse_ad) isa SymbolicMode end + @test dense_ad(ad) == ad @test dense_ad(sparse_ad) == ad @test sparsity_detector(sparse_ad) == NoSparsityDetector() @test coloring_algorithm(sparse_ad) == NoColoringAlgorithm() From 1a9d27d00871186ea2a9a786910afc7773b5b6e0 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Thu, 6 Mar 2025 07:48:12 +0100 Subject: [PATCH 2/2] Typo --- src/sparse.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sparse.jl b/src/sparse.jl index 1b389c8..21dd8c6 100644 --- a/src/sparse.jl +++ b/src/sparse.jl @@ -227,7 +227,7 @@ end dense_ad(ad::AutoSparse)::AbstractADType dense_ad(ad::AbstractADType)::AbstractADType -Return the underlying AD package for a sparse AD choice, acts as the identity on a dense AD choice. +Return the underlying AD package for a sparse AD choice, act as the identity on a dense AD choice. # See also