Skip to content

Commit

Permalink
Fix reordering in tests and demos
Browse files Browse the repository at this point in the history
  • Loading branch information
vaithak authored and vgvassilev committed Jan 25, 2024
1 parent fa59708 commit ae4b94f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions test/Arrays/ArrayInputsReverseMode.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ float func(float* a, float* b) {
//CHECK-NEXT: {
//CHECK-NEXT: a[i] = clad::pop(_t1);
//CHECK-NEXT: float _r_d0 = _d_a[i];
//CHECK-NEXT: _d_a[i] -= _r_d0;
//CHECK-NEXT: _d_a[i] += _r_d0 * b[i];
//CHECK-NEXT: _d_b[i] += a[i] * _r_d0;
//CHECK-NEXT: _d_a[i] -= _r_d0;
//CHECK-NEXT: _d_a[i];
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand Down Expand Up @@ -284,8 +284,8 @@ double func5(int k) {
//CHECK-NEXT: {
//CHECK-NEXT: arr[i] = clad::pop(_t1);
//CHECK-NEXT: double _r_d0 = _d_arr[i];
//CHECK-NEXT: * _d_k += _r_d0;
//CHECK-NEXT: _d_arr[i] -= _r_d0;
//CHECK-NEXT: * _d_k += _r_d0;
//CHECK-NEXT: _d_arr[i];
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand Down Expand Up @@ -386,10 +386,10 @@ double func7(double *params) {
//CHECK-NEXT: {
//CHECK-NEXT: out = clad::pop(_t1);
//CHECK-NEXT: double _r_d0 = _d_out;
//CHECK-NEXT: _d_out -= _r_d0;
//CHECK-NEXT: _d_out += _r_d0;
//CHECK-NEXT: inv_square_pullback(paramsPrime, _r_d0, _d_paramsPrime);
//CHECK-NEXT: clad::array<double> _r0(_d_paramsPrime);
//CHECK-NEXT: _d_out -= _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: _d_params[0] += _d_paramsPrime[0];
Expand Down Expand Up @@ -445,6 +445,7 @@ double func8(double i, double *arr, int n) {
//CHECK-NEXT: {
//CHECK-NEXT: res = _t1;
//CHECK-NEXT: double _r_d1 = _d_res;
//CHECK-NEXT: _d_res -= _r_d1;
//CHECK-NEXT: arr = _t2;
//CHECK-NEXT: double _grad0 = 0.;
//CHECK-NEXT: int _grad2 = 0;
Expand All @@ -454,7 +455,6 @@ double func8(double i, double *arr, int n) {
//CHECK-NEXT: clad::array<double> _r1(_d_arr);
//CHECK-NEXT: int _r2 = _grad2;
//CHECK-NEXT: * _d_n += _r2;
//CHECK-NEXT: _d_res -= _r_d1;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: arr[0] = _t0;
Expand All @@ -475,8 +475,8 @@ void modify(double& elem, double val) {
//CHECK-NEXT: {
//CHECK-NEXT: elem = _t0;
//CHECK-NEXT: double _r_d0 = * _d_elem;
//CHECK-NEXT: * _d_val += _r_d0;
//CHECK-NEXT: * _d_elem -= _r_d0;
//CHECK-NEXT: * _d_val += _r_d0;
//CHECK-NEXT: * _d_elem;
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand Down Expand Up @@ -540,9 +540,9 @@ double sq(double& elem) {
//CHECK-NEXT: {
//CHECK-NEXT: elem = _t0;
//CHECK-NEXT: double _r_d0 = * _d_elem;
//CHECK-NEXT: * _d_elem -= _r_d0;
//CHECK-NEXT: * _d_elem += _r_d0 * elem;
//CHECK-NEXT: * _d_elem += elem * _r_d0;
//CHECK-NEXT: * _d_elem -= _r_d0;
//CHECK-NEXT: * _d_elem;
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand Down
2 changes: 1 addition & 1 deletion test/CUDA/GradientCuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ auto gauss_g = clad::gradient(gauss, "p");
//CHECK-NEXT: {
//CHECK-NEXT: t = _t2;
//CHECK-NEXT: double _r_d1 = _d_t;
//CHECK-NEXT: _d_t -= _r_d1;
//CHECK-NEXT: _d_t += -_r_d1 / _t3;
//CHECK-NEXT: double _r0 = _r_d1 * --t / (_t3 * _t3);
//CHECK-NEXT: _d_sigma += 2 * _r0 * sigma;
//CHECK-NEXT: _d_sigma += 2 * sigma * _r0;
//CHECK-NEXT: _d_t -= _r_d1;
//CHECK-NEXT: }
//CHECK-NEXT: for (; _t0; _t0--) {
//CHECK-NEXT: i--;
Expand Down
12 changes: 6 additions & 6 deletions test/ErrorEstimation/Assignments.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ float func(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: y = _t1;
//CHECK-NEXT: float _r_d1 = * _d_y;
//CHECK-NEXT: * _d_x += _r_d1;
//CHECK-NEXT: * _d_y -= _r_d1;
//CHECK-NEXT: * _d_x += _r_d1;
//CHECK-NEXT: * _d_y;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x += _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand Down Expand Up @@ -67,12 +67,12 @@ float func2(float x, int y) {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_y += _r_d0 * x;
//CHECK-NEXT: * _d_x += y * _r_d0;
//CHECK-NEXT: * _d_x += _r_d0 * x;
//CHECK-NEXT: * _d_x += x * _r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand All @@ -94,8 +94,8 @@ float func3(int x, int y) {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: int _r_d0 = * _d_x;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand Down Expand Up @@ -125,10 +125,10 @@ float func4(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: _d_z += _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: * _d_y += _d_z;
Expand Down Expand Up @@ -160,10 +160,10 @@ float func5(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: _d_z += _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand Down
14 changes: 7 additions & 7 deletions test/ErrorEstimation/BasicOps.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ float func(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: y = _t1;
//CHECK-NEXT: float _r_d1 = * _d_y;
//CHECK-NEXT: * _d_y -= _r_d1;
//CHECK-NEXT: * _d_y += _r_d1;
//CHECK-NEXT: * _d_y += _r_d1;
//CHECK-NEXT: y--;
//CHECK-NEXT: _delta_y += std::abs(* _d_y * _EERepl_y1 * {{.+}});
//CHECK-NEXT: * _d_y += _r_d1;
//CHECK-NEXT: _delta_y += std::abs(_r_d1 * _EERepl_y2 * {{.+}});
//CHECK-NEXT: * _d_y -= _r_d1;
//CHECK-NEXT: * _d_y;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x += _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand Down Expand Up @@ -102,12 +102,12 @@ float func2(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x += _r_d0;
//CHECK-NEXT: * _d_y += -_r_d0;
//CHECK-NEXT: * _d_y += -_r_d0 * y;
//CHECK-NEXT: * _d_y += y * -_r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand Down Expand Up @@ -160,22 +160,22 @@ float func3(float x, float y) {
//CHECK-NEXT: * _d_y += x * z * _d_t;
//CHECK-NEXT: y = _t2;
//CHECK-NEXT: float _r_d1 = * _d_y;
//CHECK-NEXT: * _d_y -= _r_d1;
//CHECK-NEXT: * _d_x += _r_d1;
//CHECK-NEXT: * _d_x += _r_d1;
//CHECK-NEXT: _delta_y += std::abs(_r_d1 * _EERepl_y1 * {{.+}});
//CHECK-NEXT: * _d_y -= _r_d1;
//CHECK-NEXT: _delta_t += std::abs(_d_t * _EERepl_t0 * {{.+}});
//CHECK-NEXT: }
//CHECK-NEXT: * _d_y += _d_z;
//CHECK-NEXT: {
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x += _r_d0;
//CHECK-NEXT: * _d_y += -_r_d0;
//CHECK-NEXT: * _d_y += -_r_d0 * y;
//CHECK-NEXT: * _d_y += y * -_r_d0;
//CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d0;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: _delta_x += std::abs(* _d_x * _EERepl_x0 * {{.+}});
Expand Down Expand Up @@ -232,10 +232,10 @@ float func5(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: y = _t0;
//CHECK-NEXT: float _r_d0 = * _d_y;
//CHECK-NEXT: * _d_y -= _r_d0;
//CHECK-NEXT: float _r0 = _r_d0 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward;
//CHECK-NEXT: * _d_x += _r0;
//CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * {{.+}});
//CHECK-NEXT: * _d_y -= _r_d0;
//CHECK-NEXT: * _d_y;
//CHECK-NEXT: }
//CHECK-NEXT: double _delta_x = 0;
Expand Down Expand Up @@ -360,14 +360,14 @@ float func8(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: z = _t0;
//CHECK-NEXT: float _r_d0 = _d_z;
//CHECK-NEXT: _d_z -= _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: x = _t1;
//CHECK-NEXT: double _t2 = 0;
//CHECK-NEXT: helper2_pullback(_t1, _r_d0, &* _d_x, _t2);
//CHECK-NEXT: float _r0 = * _d_x;
//CHECK-NEXT: _delta_z += _t2;
//CHECK-NEXT: _final_error += std::abs(_r0 * _t1 * {{.+}});
//CHECK-NEXT: _d_z -= _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: double _delta_x = 0;
//CHECK-NEXT: _delta_x += std::abs(* _d_x * x * {{.+}});
Expand Down
8 changes: 4 additions & 4 deletions test/ErrorEstimation/ConditonalStatements.C
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@ float func(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: y = _t0;
//CHECK-NEXT: float _r_d0 = * _d_y;
//CHECK-NEXT: * _d_y -= _r_d0;
//CHECK-NEXT: * _d_y += _r_d0 * x;
//CHECK-NEXT: * _d_x += y * _r_d0;
//CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * {{.+}});
//CHECK-NEXT: * _d_y -= _r_d0;
//CHECK-NEXT: * _d_y;
//CHECK-NEXT: }
//CHECK-NEXT: } else {
//CHECK-NEXT: {
//CHECK-NEXT: x = _t2;
//CHECK-NEXT: float _r_d2 = * _d_x;
//CHECK-NEXT: * _d_y += _r_d2;
//CHECK-NEXT: * _d_x -= _r_d2;
//CHECK-NEXT: * _d_y += _r_d2;
//CHECK-NEXT: * _d_x;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: temp = _t1;
//CHECK-NEXT: float _r_d1 = _d_temp;
//CHECK-NEXT: _d_temp -= _r_d1;
//CHECK-NEXT: * _d_y += _r_d1 * y;
//CHECK-NEXT: * _d_y += y * _r_d1;
//CHECK-NEXT: _delta_temp += std::abs(_r_d1 * _EERepl_temp1 * {{.+}});
//CHECK-NEXT: _d_temp -= _r_d1;
//CHECK-NEXT: }
//CHECK-NEXT: * _d_y += _d_temp;
//CHECK-NEXT: }
Expand Down Expand Up @@ -193,10 +193,10 @@ float func4(float x, float y) {
//CHECK-NEXT: } else {
//CHECK-NEXT: x = _t1;
//CHECK-NEXT: float _r_d1 = * _d_x;
//CHECK-NEXT: * _d_x -= _r_d1;
//CHECK-NEXT: * _d_x += _r_d1 * x;
//CHECK-NEXT: * _d_x += x * _r_d1;
//CHECK-NEXT: _delta_x += std::abs(_r_d1 * _EERepl_x2 * {{.+}});
//CHECK-NEXT: * _d_x -= _r_d1;
//CHECK-NEXT: }
//CHECK-NEXT: _cond0 ? * _d_x : * _d_x;
//CHECK-NEXT: }
Expand Down
14 changes: 7 additions & 7 deletions test/ErrorEstimation/LoopsAndArrays.C
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ float func2(float x) {
//CHECK-NEXT: {
//CHECK-NEXT: z = clad::pop(_t2);
//CHECK-NEXT: float _r_d0 = _d_z;
//CHECK-NEXT: _d_z -= _r_d0;
//CHECK-NEXT: _d_m += _r_d0;
//CHECK-NEXT: _d_m += _r_d0;
//CHECK-NEXT: float _r1 = clad::pop(_EERepl_z1);
//CHECK-NEXT: _delta_z += std::abs(_r_d0 * _r1 * {{.+}});
//CHECK-NEXT: _d_z -= _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: * _d_x += _d_m * x;
Expand Down Expand Up @@ -150,31 +150,31 @@ float func3(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: arr[2] = _t2;
//CHECK-NEXT: double _r_d2 = _d_arr[2];
//CHECK-NEXT: _d_arr[2] -= _r_d2;
//CHECK-NEXT: _d_arr[0] += _r_d2;
//CHECK-NEXT: _d_arr[1] += _r_d2;
//CHECK-NEXT: _delta_arr[2] += std::abs(_r_d2 * _EERepl_arr2 * {{.+}});
//CHECK-NEXT: _final_error += _delta_arr[2];
//CHECK-NEXT: _d_arr[2] -= _r_d2;
//CHECK-NEXT: _d_arr[2];
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: arr[1] = _t1;
//CHECK-NEXT: double _r_d1 = _d_arr[1];
//CHECK-NEXT: _d_arr[1] -= _r_d1;
//CHECK-NEXT: * _d_x += _r_d1 * x;
//CHECK-NEXT: * _d_x += x * _r_d1;
//CHECK-NEXT: _delta_arr[1] += std::abs(_r_d1 * _EERepl_arr1 * {{.+}});
//CHECK-NEXT: _final_error += _delta_arr[1];
//CHECK-NEXT: _d_arr[1] -= _r_d1;
//CHECK-NEXT: _d_arr[1];
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: arr[0] = _t0;
//CHECK-NEXT: double _r_d0 = _d_arr[0];
//CHECK-NEXT: _d_arr[0] -= _r_d0;
//CHECK-NEXT: * _d_x += _r_d0;
//CHECK-NEXT: * _d_y += _r_d0;
//CHECK-NEXT: _delta_arr[0] += std::abs(_r_d0 * _EERepl_arr0 * {{.+}});
//CHECK-NEXT: _final_error += _delta_arr[0];
//CHECK-NEXT: _d_arr[0] -= _r_d0;
//CHECK-NEXT: _d_arr[0];
//CHECK-NEXT: }
//CHECK-NEXT: double _delta_x = 0;
Expand Down Expand Up @@ -300,37 +300,37 @@ double func5(double* x, double* y, double* output) {
//CHECK-NEXT: {
//CHECK-NEXT: output[2] = _t2;
//CHECK-NEXT: double _r_d2 = _d_output[2];
//CHECK-NEXT: _d_output[2] -= _r_d2;
//CHECK-NEXT: _d_x[0] += _r_d2 * y[1];
//CHECK-NEXT: _d_y[1] += x[0] * _r_d2;
//CHECK-NEXT: _d_y[0] += -_r_d2 * x[1];
//CHECK-NEXT: _d_x[1] += y[0] * -_r_d2;
//CHECK-NEXT: _delta_output[2] += std::abs(_r_d2 * _EERepl_output3 * {{.+}});
//CHECK-NEXT: _final_error += _delta_output[2];
//CHECK-NEXT: _d_output[2] -= _r_d2;
//CHECK-NEXT: _d_output[2];
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: output[1] = _t1;
//CHECK-NEXT: double _r_d1 = _d_output[1];
//CHECK-NEXT: _d_output[1] -= _r_d1;
//CHECK-NEXT: _d_x[2] += _r_d1 * y[0];
//CHECK-NEXT: _d_y[0] += x[2] * _r_d1;
//CHECK-NEXT: _d_x[0] += -_r_d1 * y[2];
//CHECK-NEXT: _d_y[2] += x[0] * -_r_d1;
//CHECK-NEXT: _delta_output[1] += std::abs(_r_d1 * _EERepl_output2 * {{.+}});
//CHECK-NEXT: _final_error += _delta_output[1];
//CHECK-NEXT: _d_output[1] -= _r_d1;
//CHECK-NEXT: _d_output[1];
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: output[0] = _t0;
//CHECK-NEXT: double _r_d0 = _d_output[0];
//CHECK-NEXT: _d_output[0] -= _r_d0;
//CHECK-NEXT: _d_x[1] += _r_d0 * y[2];
//CHECK-NEXT: _d_y[2] += x[1] * _r_d0;
//CHECK-NEXT: _d_x[2] += -_r_d0 * y[1];
//CHECK-NEXT: _d_y[1] += x[2] * -_r_d0;
//CHECK-NEXT: _delta_output[0] += std::abs(_r_d0 * _EERepl_output1 * {{.+}});
//CHECK-NEXT: _final_error += _delta_output[0];
//CHECK-NEXT: _d_output[0] -= _r_d0;
//CHECK-NEXT: _d_output[0];
//CHECK-NEXT: }
//CHECK-NEXT: clad::array<double> _delta_x(_d_x.size());
Expand Down
Loading

0 comments on commit ae4b94f

Please sign in to comment.