Skip to content

Commit

Permalink
Merge pull request #5 from EnzymeAD/higherorder
Browse files Browse the repository at this point in the history
failing test
  • Loading branch information
ZuseZ4 authored Apr 3, 2024
2 parents cb957c4 + d8f4369 commit 4e314cb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions samples/tests/higher/mod.rs
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);
}

2 changes: 2 additions & 0 deletions samples/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
mod forward;
mod neohookean;
mod reverse;
mod higher;

0 comments on commit 4e314cb

Please sign in to comment.