Skip to content

Commit a00b615

Browse files
committed
Ready for the first release!!!
1 parent 408a9d4 commit a00b615

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

Project.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ForwardDiff2"
22
uuid = "994df76e-a4c1-5e1f-bd5c-23b9b5303d4f"
3-
authors = ["Yingbo Ma <mayingbo5@gmail.com>"]
3+
authors = ["Yingbo Ma <mayingbo5@gmail.com>", "Shashi Gowda <gowda@mit.edu>"]
44
version = "0.1.0"
55

66
[deps]
@@ -14,9 +14,15 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1414

1515
[compat]
1616
julia = "1"
17+
Calculus = "0.5.1"
1718
Cassette = "0.3.0"
1819
ChainRules = "0.3.1"
1920
ChainRulesCore = "0.5.3"
21+
DiffRules = "1.0.0"
22+
MacroTools = "0.5.3"
23+
NaNMath = "0.3.3"
24+
SafeTestsets = "0.0.1"
25+
SpecialFunctions = "0.9"
2026
StaticArrays = "0.11, 0.12"
2127

2228
[extras]

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,58 @@
33
[![Build Status](https://travis-ci.org/YingboMa/ForwardDiff2.jl.svg?branch=master)](https://travis-ci.org/YingboMa/ForwardDiff2.jl)
44
[![codecov](https://codecov.io/gh/YingboMa/ForwardDiff2.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/YingboMa/ForwardDiff2.jl)
55

6-
`ForwardDiff2` = `ForwardDiff.jl` + `ChainRules.jl` + Struct of arrays + `DualCache`
6+
`ForwardDiff2` = `ForwardDiff.jl` + `ChainRules.jl` + Struct of arrays
7+
8+
### Warning!!!: This package is still work-in-progress
9+
10+
User API:
11+
```julia
12+
julia> using ModelingToolkit; using ForwardDiff2: D
13+
14+
julia> v = rand(2)
15+
2-element Array{Float64,1}:
16+
0.1611559779886218
17+
0.1485936723994714
18+
19+
julia> D(prod)(v) # gradient
20+
1×2 LinearAlgebra.Adjoint{Float64,Array{Float64,1}}:
21+
0.148594 0.161156
22+
23+
julia> D(cumsum)(v) # Jacobian
24+
2×2 Array{Float64,2}:
25+
1.0 0.0
26+
1.0 1.0
27+
28+
julia> D(D(sum))(v) # Hessian
29+
2×2 LinearAlgebra.Adjoint{Float64,Array{Float64,2}}:
30+
0.0 0.0
31+
0.0 0.0
32+
```
33+
34+
Note that `ForwardDiff2.jl` also works with `ModelingToolkit.jl`:
35+
```julia
36+
julia> @variables v[1:2]
37+
(Operation[v₁, v₂],)
38+
39+
julia> D(prod)(v) # gradient
40+
1×2 LinearAlgebra.Adjoint{Operation,Array{Operation,1}}:
41+
conj(1v₂ + v₁ * identity(0)) conj(identity(0) * v₂ + v₁ * 1)
42+
43+
julia> D(cumsum)(v) # Jacobian
44+
2×2 Array{Expression,2}:
45+
Constant(1) identity(0)
46+
identity(0) + 1 1 + identity(0)
47+
48+
julia> D(D(sum))(v) # Hessian
49+
2×2 LinearAlgebra.Adjoint{Operation,Array{Operation,2}}:
50+
conj(0 + 0) conj(0 + 0)
51+
conj(0 + 0) conj(0 + 0)
52+
```
753

854
Planned features:
955

1056
- works both on GPU and CPU
11-
- scalar forward mode AD
12-
- vectorized forward mode AD
1357
- [Dual cache](http://docs.juliadiffeq.org/latest/basics/faq.html#I-get-Dual-number-errors-when-I-solve-my-ODE-with-Rosenbrock-or-SDIRK-methods...?-1)
14-
- nested differentiation
15-
- hyper duals (?)
1658
- user-extensible scalar and tensor derivative definitions
1759
- in-place function
1860
- sparsity exploitation (color vector support)

test/api.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ using StaticArrays
1616
@test D(D(x->x[1]^x[2] + x[3]^3 + x[3]*x[2]*x[1]))(@SVector[1,2,3]) === @SMatrix [2 4 2; 4 0 1; 2 1 18.]
1717
@test D(D(x->x[1]^x[2] + x[3]^3 + x[3]*x[2]*x[1]))([1,2,3]) == [2 4 2; 4 0 1; 2 1 18.]
1818
# inference
19+
@inferred D(x->exp(x) + x^x + cos(x) + tan(x) + 2^x)(1)
1920
# broken due to `Core._apply`
2021
@test_broken @inferred D(x->exp(x) + x^x + cos(x) + tan(x) + 2^x + log(cos(x)) + sec(pi*x) - angle(x) + one(x) / log1p(sin(x)))(1)
2122
end

0 commit comments

Comments
 (0)