Skip to content

Commit e3e2d1a

Browse files
Add AutoTaylorDiff (#99)
* Add TaylorDiff * Remove typed constructors and bump version * Fix test * Add docs * Update CI.yml --------- Co-authored-by: Christopher Rackauckas <[email protected]>
1 parent d468741 commit e3e2d1a

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
with:
4444
files: lcov.info
4545
token: ${{ secrets.CODECOV_TOKEN }}
46-
fail_ci_if_error: true
46+
fail_ci_if_error: false

Project.toml

+1-1
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.10.0"
4+
version = "1.11.0"
55

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

docs/src/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Taylor mode:
3434

3535
```@docs
3636
AutoGTPSA
37+
AutoTaylorDiff
3738
```
3839

3940
### Reverse mode

src/ADTypes.jl

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export AutoChainRules,
4747
AutoReverseDiff,
4848
AutoSymbolics,
4949
AutoTapir,
50+
AutoTaylorDiff,
5051
AutoTracker,
5152
AutoZygote
5253
@public AbstractMode

src/dense.jl

+29
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,35 @@ function Base.show(io::IO, backend::AutoForwardDiff{chunksize}) where {chunksize
197197
print(io, ")")
198198
end
199199

200+
"""
201+
AutoTaylorDiff{order}
202+
203+
Struct used to select the [TaylorDiff.jl](https://github.com/JuliaDiff/TaylorDiff.jl) backend for automatic differentiation.
204+
205+
Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
206+
207+
# Constructors
208+
209+
AutoTaylorDiff(; order = 1)
210+
211+
# Type parameters
212+
213+
- `order`: the order of the Taylor-mode automatic differentiation
214+
"""
215+
struct AutoTaylorDiff{order} <: AbstractADType end
216+
217+
function AutoTaylorDiff(; order = 1)
218+
return AutoTaylorDiff{order}()
219+
end
220+
221+
mode(::AutoTaylorDiff) = ForwardMode()
222+
223+
function Base.show(io::IO, ::AutoTaylorDiff{order}) where {order}
224+
print(io, AutoTaylorDiff, "(")
225+
print(io, "order=", repr(order; context = io))
226+
print(io, ")")
227+
end
228+
200229
"""
201230
AutoGTPSA{D}
202231

test/dense.jl

+12
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ end
182182
@test !ad.safe_mode
183183
end
184184

185+
@testset "AutoTaylorDiff" begin
186+
ad = AutoTaylorDiff(; order = 2)
187+
@test ad isa AbstractADType
188+
@test ad isa AutoTaylorDiff{2}
189+
@test mode(ad) isa ForwardMode
190+
191+
ad = AutoTaylorDiff()
192+
@test ad isa AbstractADType
193+
@test ad isa AutoTaylorDiff{1}
194+
@test mode(ad) isa ForwardMode
195+
end
196+
185197
@testset "AutoTracker" begin
186198
ad = AutoTracker()
187199
@test ad isa AbstractADType

0 commit comments

Comments
 (0)