From 197d2e69e3ac0e6d3db86b31231ed2fb91c15863 Mon Sep 17 00:00:00 2001 From: Songchen Tan Date: Tue, 19 Nov 2024 12:12:45 -0500 Subject: [PATCH 1/5] Add TaylorDiff --- src/ADTypes.jl | 1 + src/dense.jl | 30 ++++++++++++++++++++++++++++++ test/dense.jl | 12 ++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/ADTypes.jl b/src/ADTypes.jl index 0a1f66d..efc2b1a 100644 --- a/src/ADTypes.jl +++ b/src/ADTypes.jl @@ -47,6 +47,7 @@ export AutoChainRules, AutoReverseDiff, AutoSymbolics, AutoTapir, + AutoTaylorDiff, AutoTracker, AutoZygote @public AbstractMode diff --git a/src/dense.jl b/src/dense.jl index 8f5279f..d4ccfbc 100644 --- a/src/dense.jl +++ b/src/dense.jl @@ -197,6 +197,36 @@ function Base.show(io::IO, backend::AutoForwardDiff{chunksize}) where {chunksize print(io, ")") end +""" + AutoTaylorDiff{order} + +Struct used to select the [TaylorDiff.jl](https://github.com/JuliaDiff/TaylorDiff.jl) backend for automatic differentiation. + +Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). + +# Constructors + + AutoTaylorDiff(; order = 1) + AutoTaylorDiff{order}() + +# Type parameters + + - `order`: the order of the Taylor-mode automatic differentiation +""" +struct AutoTaylorDiff{order} <: AbstractADType end + +function AutoTaylorDiff(; order = 1) + return AutoTaylorDiff{order}() +end + +mode(::AutoTaylorDiff) = ForwardMode() + +function Base.show(io::IO, ::AutoTaylorDiff{order}) where {order} + print(io, AutoTaylorDiff, "(") + print(io, "tag=", repr(order; context = io)) + print(io, ")") +end + """ AutoGTPSA{D} diff --git a/test/dense.jl b/test/dense.jl index 4f680ca..8f16b34 100644 --- a/test/dense.jl +++ b/test/dense.jl @@ -182,6 +182,18 @@ end @test !ad.safe_mode end +@testset "AutoTaylorDiff" begin + ad = AutoTaylorDiff{2}() + @test ad isa AbstractADType + @test ad isa AutoTaylorDiff{2} + @test mode(ad) isa ForwardMode + + ad = AutoTaylorDiff() + @test ad isa AbstractADType + @test ad isa AutoTaylorDiff{1} + @test mode(ad) isa ForwardMode +end + @testset "AutoTracker" begin ad = AutoTracker() @test ad isa AbstractADType From cac3917e07fde10ecbae80f9434dda87999c527e Mon Sep 17 00:00:00 2001 From: Songchen Tan Date: Tue, 19 Nov 2024 12:35:10 -0500 Subject: [PATCH 2/5] Remove typed constructors and bump version --- Project.toml | 2 +- src/dense.jl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 4fbeddd..b8cd5cf 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.10.0" +version = "1.11.0" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/dense.jl b/src/dense.jl index d4ccfbc..9359726 100644 --- a/src/dense.jl +++ b/src/dense.jl @@ -207,7 +207,6 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl). # Constructors AutoTaylorDiff(; order = 1) - AutoTaylorDiff{order}() # Type parameters @@ -223,7 +222,7 @@ mode(::AutoTaylorDiff) = ForwardMode() function Base.show(io::IO, ::AutoTaylorDiff{order}) where {order} print(io, AutoTaylorDiff, "(") - print(io, "tag=", repr(order; context = io)) + print(io, "order=", repr(order; context = io)) print(io, ")") end From 4a65bd9774e4c25510ee3699c2cb33e7017aab87 Mon Sep 17 00:00:00 2001 From: Songchen Tan Date: Tue, 19 Nov 2024 13:42:54 -0500 Subject: [PATCH 3/5] Fix test --- test/dense.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dense.jl b/test/dense.jl index 8f16b34..f724b27 100644 --- a/test/dense.jl +++ b/test/dense.jl @@ -183,7 +183,7 @@ end end @testset "AutoTaylorDiff" begin - ad = AutoTaylorDiff{2}() + ad = AutoTaylorDiff(; order = 2) @test ad isa AbstractADType @test ad isa AutoTaylorDiff{2} @test mode(ad) isa ForwardMode From a5192305edeb0796318332f2c2e6dc2861528b3f Mon Sep 17 00:00:00 2001 From: Songchen Tan Date: Tue, 19 Nov 2024 19:03:54 -0500 Subject: [PATCH 4/5] Add docs --- docs/src/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/index.md b/docs/src/index.md index 2100fb2..254eb68 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -34,6 +34,7 @@ Taylor mode: ```@docs AutoGTPSA +AutoTaylorDiff ``` ### Reverse mode From 214e2c4803be152f390c02c4d3c37b4805aa6d72 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 20 Nov 2024 14:40:54 -0500 Subject: [PATCH 5/5] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 66fdbf9..53a1d3d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -43,4 +43,4 @@ jobs: with: files: lcov.info token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + fail_ci_if_error: false