Skip to content

Commit d6d3ab2

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

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
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: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,60 @@
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 ForwardDiff2: D
13+
14+
julia> v = rand(2)
15+
2-element Array{Float64,1}:
16+
0.22260830987887537
17+
0.6397089507287486
18+
19+
julia> D(prod)(v) # gradient
20+
1×2 LinearAlgebra.Adjoint{Float64,Array{Float64,1}}:
21+
0.639709 0.222608
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(prod))(v) # Hessian
29+
2×2 LinearAlgebra.Adjoint{Float64,Array{Float64,2}}:
30+
0.0 1.0
31+
1.0 0.0
32+
```
33+
34+
Note that `ForwardDiff2.jl` also works with `ModelingToolkit.jl`:
35+
```julia
36+
julia> using ModelingToolkit
37+
38+
julia> @variables v[1:2]
39+
(Operation[v₁, v₂],)
40+
41+
julia> D(prod)(v) # gradient
42+
1×2 LinearAlgebra.Adjoint{Operation,Array{Operation,1}}:
43+
conj(1v₂ + v₁ * identity(0)) conj(identity(0) * v₂ + v₁ * 1)
44+
45+
julia> D(cumsum)(v) # Jacobian
46+
2×2 Array{Expression,2}:
47+
Constant(1) identity(0)
48+
identity(0) + 1 1 + identity(0)
49+
50+
julia> D(D(prod))(v) # Hessian
51+
2×2 LinearAlgebra.Adjoint{Operation,Array{Operation,2}}:
52+
conj((1 * identity(0) + v₁ * 0) + (1 * identity(0) + v₂ * 0)) conj((identity(0) * identity(0) + v₁ * 0) + (1 * 1 + v₂ * 0))
53+
conj((1 * 1 + v₁ * 0) + (identity(0) * identity(0) + v₂ * 0)) conj((identity(0) * 1 + v₁ * 0) + (identity(0) * 1 + v₂ * 0))
54+
```
755

856
Planned features:
957

1058
- works both on GPU and CPU
11-
- scalar forward mode AD
12-
- vectorized forward mode AD
1359
- [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 (?)
1660
- user-extensible scalar and tensor derivative definitions
1761
- in-place function
1862
- 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

test/dualtest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ for N in (3), M in (4), V in (Int, Float32)
399399
if V != Int
400400
for (M, f, arity) in DiffRules.diffrules()
401401
in(f, (:hankelh1, :hankelh1x, :hankelh2, :hankelh2x, :/, :rem2pi)) && continue
402-
#println(" ...auto-testing $(M).$(f) with $arity arguments")
402+
println(" ...auto-testing $(M).$(f) with $arity arguments")
403403
if arity == 1
404404
deriv = DiffRules.diffrule(M, f, :x)
405405
modifier = in(f, (:asec, :acsc, :asecd, :acscd, :acosh, :acoth)) ? one(V) : zero(V)

0 commit comments

Comments
 (0)