Skip to content

Commit

Permalink
Add AutoTaylorDiff (#99)
Browse files Browse the repository at this point in the history
* Add TaylorDiff

* Remove typed constructors and bump version

* Fix test

* Add docs

* Update CI.yml

---------

Co-authored-by: Christopher Rackauckas <accounts@chrisrackauckas.com>
  • Loading branch information
tansongchen and ChrisRackauckas authored Nov 20, 2024
1 parent d468741 commit e3e2d1a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ADTypes"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
authors = ["Vaibhav Dixit <vaibhavyashdixit@gmail.com>, Guillaume Dalle and contributors"]
version = "1.10.0"
version = "1.11.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Taylor mode:

```@docs
AutoGTPSA
AutoTaylorDiff
```

### Reverse mode
Expand Down
1 change: 1 addition & 0 deletions src/ADTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export AutoChainRules,
AutoReverseDiff,
AutoSymbolics,
AutoTapir,
AutoTaylorDiff,
AutoTracker,
AutoZygote
@public AbstractMode
Expand Down
29 changes: 29 additions & 0 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,35 @@ 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)
# 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, "order=", repr(order; context = io))
print(io, ")")
end

"""
AutoGTPSA{D}
Expand Down
12 changes: 12 additions & 0 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ end
@test !ad.safe_mode
end

@testset "AutoTaylorDiff" begin
ad = AutoTaylorDiff(; order = 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
Expand Down

2 comments on commit e3e2d1a

@gdalle
Copy link
Collaborator

@gdalle gdalle commented on e3e2d1a Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119861

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.11.0 -m "<description of version>" e3e2d1a3684935005314c94874dda48c728b167e
git push origin v1.11.0

Please sign in to comment.