|
| 1 | +// RUN: %eopt --enzyme %s | FileCheck %s |
| 2 | + |
| 3 | +func.func @foo(%x : f64) -> f64{ |
| 4 | + %out = memref.alloca_scope -> (f64) { |
| 5 | + %buf = memref.alloca() : memref<f64> |
| 6 | + memref.store %x, %buf[] : memref<f64> |
| 7 | + %y = memref.load %buf[] : memref<f64> |
| 8 | + memref.alloca_scope.return %y : f64 |
| 9 | + } |
| 10 | + return %out : f64 |
| 11 | +} |
| 12 | + |
| 13 | + |
| 14 | +func.func @dfoo(%x: f64, %dout : f64) -> f64 { |
| 15 | + %dx = enzyme.autodiff @foo(%x, %dout) { |
| 16 | + activity = [#enzyme<activity enzyme_active>], |
| 17 | + ret_activity = [#enzyme<acitivity enzyme_activenoneed>] |
| 18 | + } : (f64, f64) -> (f64) |
| 19 | + return %dx : f64 |
| 20 | +} |
| 21 | + |
| 22 | +func.func @foo2(%x : f64) -> f64{ |
| 23 | + %cst = arith.constant 0.0000e+00 : f64 |
| 24 | + %buf = memref.alloca() : memref<f64> |
| 25 | + memref.store %x, %buf[] : memref<f64> |
| 26 | + %y = memref.load %buf[] : memref<f64> |
| 27 | + %out = arith.addf %cst, %y : f64 |
| 28 | + return %out : f64 |
| 29 | +} |
| 30 | + |
| 31 | + |
| 32 | +func.func @dfoo2(%x: f64, %dout : f64) -> f64 { |
| 33 | + %dx = enzyme.autodiff @foo2(%x, %dout) { |
| 34 | + activity = [#enzyme<activity enzyme_active>], |
| 35 | + ret_activity = [#enzyme<activity enzyme_activenoneed>] |
| 36 | + } : (f64, f64) -> (f64) |
| 37 | + return %dx : f64 |
| 38 | +} |
0 commit comments