-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from EnzymeAD/higherorder
failing test
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// A direct translation of | ||
// https://enzyme.mit.edu/index.fcgi/julia/stable/generated/autodiff/#Forward-over-reverse | ||
|
||
#[autodiff(ddf, Forward, Dual, Dual, Dual, Dual)] | ||
fn df2(x: &[f32;2], dx: &mut [f32;2], out: &mut [f32;1], dout: &mut [f32;1]) { | ||
df(x, dx, out, dout); | ||
} | ||
|
||
#[autodiff(df, ReverseFirst, Duplicated, Duplicated)] | ||
fn f(x: &[f32;2], y: &mut [f32;1]) { | ||
y[0] = x[0] * x[0] + x[1] * x[0] | ||
} | ||
|
||
#[test] | ||
fn main() { | ||
let mut y = [0.0]; | ||
let x = [2.0, 2.0]; | ||
|
||
let mut dy = [0.0]; | ||
let mut dx = [1.0, 0.0]; | ||
|
||
let mut bx = [0.0, 0.0]; | ||
let mut by = [1.0]; | ||
let mut dbx = [0.0, 0.0]; | ||
let mut dby = [0.0]; | ||
|
||
ddf(&x, &mut bx, &mut dx, &mut dbx, | ||
&mut y, &mut by, &mut dy, &mut dby); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
mod forward; | ||
mod neohookean; | ||
mod reverse; | ||
mod higher; | ||
|