Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Jan 31, 2024
1 parent 2a399a0 commit 7ebcff1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
40 changes: 27 additions & 13 deletions test/Arrays/ArrayInputsReverseMode.C
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,18 @@ double func6(double seed) {
//CHECK-NEXT: int _t1;
//CHECK-NEXT: int _d_i = 0;
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<clad::array<double> > _t2 = {};
//CHECK-NEXT: clad::array<double> _d_arr(3UL);
//CHECK-NEXT: clad::tape<double> _t2 = {};
//CHECK-NEXT: clad::array<double> arr(3UL);
//CHECK-NEXT: clad::tape<double> _t3 = {};
//CHECK-NEXT: clad::tape<clad::array<double> > _t4 = {};
//CHECK-NEXT: double sum = 0;
//CHECK-NEXT: _t0 = 0;
//CHECK-NEXT: for (_t1 = i , i = 0; i < 3; i++) {
//CHECK-NEXT: _t0++;
//CHECK-NEXT: double arr[3] = {seed, seed * i, seed + i};
//CHECK-NEXT: clad::push(_t2, sum);
//CHECK-NEXT: clad::push(_t2, arr) , arr = {seed, seed * i, seed + i};
//CHECK-NEXT: clad::push(_t3, sum);
//CHECK-NEXT: clad::push(_t4, arr);
//CHECK-NEXT: sum += addArr(arr, 3);
//CHECK-NEXT: }
//CHECK-NEXT: goto _label0;
Expand All @@ -359,12 +363,14 @@ double func6(double seed) {
//CHECK-NEXT: for (; _t0; _t0--) {
//CHECK-NEXT: i--;
//CHECK-NEXT: {
//CHECK-NEXT: sum = clad::pop(_t2);
//CHECK-NEXT: sum = clad::pop(_t3);
//CHECK-NEXT: double _r_d0 = _d_sum;
//CHECK-NEXT: clad::array<double> _r1 = clad::pop(_t4);
//CHECK-NEXT: arr = _r1;
//CHECK-NEXT: int _grad1 = 0;
//CHECK-NEXT: addArr_pullback(arr, 3, _r_d0, _d_arr, &_grad1);
//CHECK-NEXT: clad::array<double> _r0(_d_arr);
//CHECK-NEXT: int _r1 = _grad1;
//CHECK-NEXT: addArr_pullback(_r1, 3, _r_d0, _d_arr, &_grad1);
//CHECK-NEXT: clad::array<double> _r0 = _d_arr;
//CHECK-NEXT: int _r2 = _grad1;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: * _d_seed += _d_arr[0];
Expand All @@ -373,6 +379,7 @@ double func6(double seed) {
//CHECK-NEXT: * _d_seed += _d_arr[2];
//CHECK-NEXT: _d_i += _d_arr[2];
//CHECK-NEXT: _d_arr = {};
//CHECK-NEXT: arr = clad::pop(_t2);
//CHECK-NEXT: }
//CHECK-NEXT: }
//CHECK-NEXT: i = _t1;
Expand Down Expand Up @@ -410,14 +417,18 @@ double func7(double *params) {
//CHECK-NEXT: std::size_t _t1;
//CHECK-NEXT: std::size_t _d_i = 0;
//CHECK-NEXT: std::size_t i = 0;
//CHECK-NEXT: clad::tape<clad::array<double> > _t2 = {};
//CHECK-NEXT: clad::array<double> _d_paramsPrime(1UL);
//CHECK-NEXT: clad::tape<double> _t2 = {};
//CHECK-NEXT: clad::array<double> paramsPrime(1UL);
//CHECK-NEXT: clad::tape<double> _t3 = {};
//CHECK-NEXT: clad::tape<clad::array<double> > _t4 = {};
//CHECK-NEXT: double out = 0.;
//CHECK-NEXT: _t0 = 0;
//CHECK-NEXT: for (_t1 = i , i = 0; i < 1; ++i) {
//CHECK-NEXT: _t0++;
//CHECK-NEXT: double paramsPrime[1] = {params[0]};
//CHECK-NEXT: clad::push(_t2, out);
//CHECK-NEXT: clad::push(_t2, paramsPrime) , paramsPrime = {params[0]};
//CHECK-NEXT: clad::push(_t3, out);
//CHECK-NEXT: clad::push(_t4, paramsPrime);
//CHECK-NEXT: out = out + inv_square(paramsPrime);
//CHECK-NEXT: }
//CHECK-NEXT: goto _label0;
Expand All @@ -427,16 +438,19 @@ double func7(double *params) {
//CHECK-NEXT: for (; _t0; _t0--) {
//CHECK-NEXT: --i;
//CHECK-NEXT: {
//CHECK-NEXT: out = clad::pop(_t2);
//CHECK-NEXT: out = clad::pop(_t3);
//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: clad::array<double> _r1 = clad::pop(_t4);
//CHECK-NEXT: paramsPrime = _r1;
//CHECK-NEXT: inv_square_pullback(_r1, _r_d0, _d_paramsPrime);
//CHECK-NEXT: clad::array<double> _r0 = _d_paramsPrime;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: _d_params[0] += _d_paramsPrime[0];
//CHECK-NEXT: _d_paramsPrime = {};
//CHECK-NEXT: paramsPrime = clad::pop(_t2);
//CHECK-NEXT: }
//CHECK-NEXT: }
//CHECK-NEXT: i = _t1;
Expand Down
11 changes: 7 additions & 4 deletions test/Gradient/Loops.C
Original file line number Diff line number Diff line change
Expand Up @@ -1598,30 +1598,33 @@ double fn19(double* arr, int n) {
// CHECK-NEXT: int _d_i = 0;
// CHECK-NEXT: int i = 0;
// CHECK-NEXT: clad::tape<double *> _t2 = {};
// CHECK-NEXT: clad::tape<double *> _t3 = {};
// CHECK-NEXT: double *_d_ref = 0;
// CHECK-NEXT: double *ref = {};
// CHECK-NEXT: clad::tape<double> _t4 = {};
// CHECK-NEXT: double res = 0;
// CHECK-NEXT: _t0 = 0;
// CHECK-NEXT: for (_t1 = i , i = 0; i < n; ++i) {
// CHECK-NEXT: _t0++;
// CHECK-NEXT: _d_ref = &_d_arr[i];
// CHECK-NEXT: clad::push(_t2, _d_ref);
// CHECK-NEXT: double &ref = arr[i];
// CHECK-NEXT: clad::push(_t3, ref) , ref = &arr[i];
// CHECK-NEXT: clad::push(_t4, res);
// CHECK-NEXT: res += ref;
// CHECK-NEXT: res += *ref;
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: for (; _t0; _t0--) {
// CHECK-NEXT: --i;
// CHECK-NEXT: double *_t3 = clad::pop(_t2);
// CHECK-NEXT: _d_ref = clad::pop(_t2);
// CHECK-NEXT: {
// CHECK-NEXT: res = clad::pop(_t4);
// CHECK-NEXT: double _r_d0 = _d_res;
// CHECK-NEXT: *_t3 += _r_d0;
// CHECK-NEXT: *_d_ref += _r_d0;
// CHECK-NEXT: }
// CHECK-NEXT: ref = clad::pop(_t3);
// CHECK-NEXT: }
// CHECK-NEXT: i = _t1;
// CHECK-NEXT: }
Expand Down
23 changes: 13 additions & 10 deletions test/Gradient/Pointers.C
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,23 @@ double pointerParam(const double* arr, size_t n) {
// CHECK-NEXT: size_t _d_i = 0;
// CHECK-NEXT: size_t i = 0;
// CHECK-NEXT: clad::tape<size_t *> _t2 = {};
// CHECK-NEXT: clad::tape<size_t *> _t4 = {};
// CHECK-NEXT: size_t *_d_j = 0;
// CHECK-NEXT: clad::tape<double> _t4 = {};
// CHECK-NEXT: clad::tape<const double *> _t5 = {};
// CHECK-NEXT: clad::tape<clad::array_ref<double> > _t6 = {};
// CHECK-NEXT: size_t *j = 0;
// CHECK-NEXT: clad::tape<double> _t5 = {};
// CHECK-NEXT: clad::tape<const double *> _t6 = {};
// CHECK-NEXT: clad::tape<clad::array_ref<double> > _t7 = {};
// CHECK-NEXT: double sum = 0;
// CHECK-NEXT: _t0 = 0;
// CHECK-NEXT: for (_t1 = i , i = 0; i < n; ++i) {
// CHECK-NEXT: _t0++;
// CHECK-NEXT: _d_j = &_d_i;
// CHECK-NEXT: clad::push(_t2, _d_j);
// CHECK-NEXT: size_t *j = &i;
// CHECK-NEXT: clad::push(_t4, sum);
// CHECK-NEXT: clad::push(_t4, j) , j = &i;
// CHECK-NEXT: clad::push(_t5, sum);
// CHECK-NEXT: sum += arr[0] * (*j);
// CHECK-NEXT: clad::push(_t5, arr);
// CHECK-NEXT: clad::push(_t6, _d_arr);
// CHECK-NEXT: clad::push(_t6, arr);
// CHECK-NEXT: clad::push(_t7, _d_arr);
// CHECK-NEXT: _d_arr.ptr_ref() = _d_arr.ptr_ref() + 1;
// CHECK-NEXT: arr = arr + 1;
// CHECK-NEXT: }
Expand All @@ -200,15 +202,16 @@ double pointerParam(const double* arr, size_t n) {
// CHECK-NEXT: --i;
// CHECK-NEXT: size_t *_t3 = clad::pop(_t2);
// CHECK-NEXT: {
// CHECK-NEXT: arr = clad::pop(_t5);
// CHECK-NEXT: _d_arr = clad::pop(_t6);
// CHECK-NEXT: arr = clad::pop(_t6);
// CHECK-NEXT: _d_arr = clad::pop(_t7);
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: sum = clad::pop(_t4);
// CHECK-NEXT: sum = clad::pop(_t5);
// CHECK-NEXT: double _r_d0 = _d_sum;
// CHECK-NEXT: _d_arr[0] += _r_d0 * (*j);
// CHECK-NEXT: *_t3 += arr[0] * _r_d0;
// CHECK-NEXT: }
// CHECK-NEXT: j = clad::pop(_t4);
// CHECK-NEXT: }
// CHECK-NEXT: i = _t1;
// CHECK-NEXT: }
Expand Down

0 comments on commit 7ebcff1

Please sign in to comment.