Skip to content

Commit

Permalink
For Hessian
Browse files Browse the repository at this point in the history
  • Loading branch information
ShounakDas101 committed Jul 31, 2023
1 parent fa59d67 commit 145e4bc
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 24 deletions.
2 changes: 2 additions & 0 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
OnlyReturn=true;
else
OnlyReturn=false;
}else{
OnlyReturn=true;
}
}
if (m_ExternalSource)
Expand Down
18 changes: 0 additions & 18 deletions test/Hessian/BuiltinDerivatives.C
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ float f2(float x) {
// CHECK-NEXT: _t2 = x;
// CHECK-NEXT: _t3 = ::std::exp(_t2);
// CHECK-NEXT: _t1 = d_x;
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: {
// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::exp_pushforward(_t0, 1.F).pushforward;
// CHECK-NEXT: * _d_x += _r0;
Expand All @@ -145,8 +143,6 @@ float f2(float x) {
// CHECK-NEXT: _t0 = x;
// CHECK-NEXT: _t1 = _d_x0;
// CHECK-NEXT: ValueAndPushforward<float, float> _t00 = clad::custom_derivatives{{(::std)?}}::exp_pushforward(_t0, _t1);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down Expand Up @@ -183,8 +179,6 @@ float f3(float x) {
// CHECK-NEXT: _t2 = x;
// CHECK-NEXT: _t3 = (1. / _t2);
// CHECK-NEXT: _t1 = d_x;
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: {
// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::log_pushforward(_t0, 1.F).pushforward;
// CHECK-NEXT: * _d_x += _r0;
Expand All @@ -206,8 +200,6 @@ float f3(float x) {
// CHECK-NEXT: _t0 = x;
// CHECK-NEXT: _t1 = _d_x0;
// CHECK-NEXT: ValueAndPushforward<float, float> _t00 = clad::custom_derivatives{{(::std)?}}::log_pushforward(_t0, _t1);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down Expand Up @@ -275,8 +267,6 @@ float f4(float x) {
// CHECK-NEXT: _t8 = d_exponent;
// CHECK-NEXT: derivative += _t14 * _t8;
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: {
// CHECK-NEXT: _d_val += _d_y.value;
// CHECK-NEXT: _d_derivative += _d_y.pushforward;
Expand Down Expand Up @@ -335,8 +325,6 @@ float f4(float x) {
// CHECK-NEXT: _t0 = x;
// CHECK-NEXT: _t1 = _d_x0;
// CHECK-NEXT: ValueAndPushforward<decltype(::std::pow(float(), float())), decltype(::std::pow(float(), float()))> _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, 4.F, _t1, 0.F);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down Expand Up @@ -377,8 +365,6 @@ float f5(float x) {
// CHECK-NEXT: _t0 = x;
// CHECK-NEXT: _t1 = _d_x0;
// CHECK-NEXT: ValueAndPushforward<decltype(::std::pow(float(), float())), decltype(::std::pow(float(), float()))> _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(2.F, _t0, 0.F, _t1);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down Expand Up @@ -426,8 +412,6 @@ float f6(float x, float y) {
// CHECK-NEXT: _t2 = _d_x0;
// CHECK-NEXT: _t3 = _d_y0;
// CHECK-NEXT: ValueAndPushforward<decltype(::std::pow(float(), float())), decltype(::std::pow(float(), float()))> _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, _t1, _t2, _t3);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down Expand Up @@ -468,8 +452,6 @@ float f6(float x, float y) {
// CHECK-NEXT: _t2 = _d_x0;
// CHECK-NEXT: _t3 = _d_y0;
// CHECK-NEXT: ValueAndPushforward<decltype(::std::pow(float(), float())), decltype(::std::pow(float(), float()))> _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, _t1, _t2, _t3);
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__t0.pushforward += 1;
// CHECK-NEXT: {
// CHECK-NEXT: float _grad0 = 0.F;
Expand Down
2 changes: 0 additions & 2 deletions test/Hessian/Hessians.C
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ void f_cubed_add1_darg1_grad(double a, double b, clad::array_ref<double> _d_a, c
//CHECK-NEXT: _t13 = b;
//CHECK-NEXT: _t20 = _t10;
//CHECK-NEXT: _t19 = _d_b0;
//CHECK-NEXT: goto _label0;
//CHECK-NEXT: _label0:
//CHECK-NEXT: {
//CHECK-NEXT: double _r4 = 1 * _t4;
//CHECK-NEXT: double _r5 = _r4 * _t5;
Expand Down
2 changes: 0 additions & 2 deletions test/Hessian/NestedFunctionCalls.C
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ double f2(double x, double y){
// CHECK-NEXT: clad::ValueAndPushforward<double, double> _t00 = f_pushforward(_t0, _t1, _t2, _t3);
// CHECK-NEXT: double _d_ans = _t00.pushforward;
// CHECK-NEXT: double ans = _t00.value;
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d__d_ans += 1;
// CHECK-NEXT: _d__t0.value += _d_ans0;
// CHECK-NEXT: _d__t0.pushforward += _d__d_ans;
Expand Down
2 changes: 0 additions & 2 deletions test/Hessian/Pointers.C
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ double nonMemFn(double i, double j) {
// CHECK-NEXT: _t0 = j;
// CHECK-NEXT: _t3 = i;
// CHECK-NEXT: _t2 = _d_j0;
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: {
// CHECK-NEXT: double _r0 = 1 * _t0;
// CHECK-NEXT: _d__d_i += _r0;
Expand Down

0 comments on commit 145e4bc

Please sign in to comment.