From 6130c910842de50f4ba6b7d38c13d081e5fff6a1 Mon Sep 17 00:00:00 2001 From: kchristin Date: Tue, 13 Aug 2024 15:23:19 +0300 Subject: [PATCH] Fix pointer zero initialization --- lib/Differentiator/VisitorBase.cpp | 2 +- test/Gradient/Assignments.C | 2 +- test/Gradient/FunctionCalls.C | 18 +++--- test/Gradient/Loops.C | 22 +++---- test/Gradient/MemberFunctions.C | 22 +++---- test/Gradient/NonDifferentiable.C | 6 +- test/Gradient/Pointers.C | 36 +++++------ test/Gradient/Switch.C | 16 ++--- test/Gradient/SwitchInit.C | 2 +- test/Gradient/TestTypeConversion.C | 2 +- test/Gradient/UserDefinedTypes.C | 30 ++++----- test/Gradient/constexprTest.C | 6 +- test/Hessian/BuiltinDerivatives.C | 100 ++++++++++++++--------------- test/Hessian/Hessians.C | 16 ++--- test/Hessian/NestedFunctionCalls.C | 32 ++++----- test/Hessian/Pointers.C | 16 ++--- test/NumericalDiff/NoNumDiff.C | 2 +- test/NumericalDiff/NumDiff.C | 2 +- unittests/Misc/CallDeclOnly.cpp | 10 +-- 19 files changed, 171 insertions(+), 171 deletions(-) diff --git a/lib/Differentiator/VisitorBase.cpp b/lib/Differentiator/VisitorBase.cpp index c9a49a74c..407c1d7e1 100644 --- a/lib/Differentiator/VisitorBase.cpp +++ b/lib/Differentiator/VisitorBase.cpp @@ -378,7 +378,7 @@ namespace clad { // FIXME: Consolidate other uses of synthesizeLiteral for creation 0 or 1. if (T->isVoidType()) return nullptr; - if (T->isScalarType()) { + else if (T->isScalarType() && !T->isPointerType()) { ExprResult Zero = ConstantFolder::synthesizeLiteral(T, m_Context, 0); CastKind CK = m_Sema.PrepareScalarCast(Zero, T); diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index f3b27b6e0..94211555f 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -492,7 +492,7 @@ double f12(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: *_t2 = _t3; //CHECK-NEXT: double _r_d2 = (_cond0 ? _d_t : _d_t); -//CHECK-NEXT: (_cond0 ? _d_t : _d_t) = 0; +//CHECK-NEXT: (_cond0 ? _d_t : _d_t) = 0.; //CHECK-NEXT: (_cond0 ? _d_t : _d_t) += _r_d2 * y; //CHECK-NEXT: *_d_y += *_t2 * _r_d2; //CHECK-NEXT: if (_cond0) { diff --git a/test/Gradient/FunctionCalls.C b/test/Gradient/FunctionCalls.C index 66bf2e897..67687a836 100644 --- a/test/Gradient/FunctionCalls.C +++ b/test/Gradient/FunctionCalls.C @@ -818,7 +818,7 @@ double sq_defined_later(double x) { // CHECK-NEXT: i += j; // CHECK-NEXT: double _t1 = j; // CHECK-NEXT: j += j; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = i + j; // CHECK-NEXT: _d_res += _d_y; // CHECK-NEXT: { @@ -858,7 +858,7 @@ double sq_defined_later(double x) { // CHECK-NEXT: int _d_i = 0; // CHECK-NEXT: int i = 0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: float _d_res = 0; +// CHECK-NEXT: float _d_res = 0.F; // CHECK-NEXT: float res = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { @@ -896,7 +896,7 @@ double sq_defined_later(double x) { // CHECK-NEXT: { // CHECK-NEXT: d = _t0; // CHECK-NEXT: double _r_d0 = *_d_d; -// CHECK-NEXT: *_d_d = 0; +// CHECK-NEXT: *_d_d = 0.; // CHECK-NEXT: *_d_d += 2 * _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -907,7 +907,7 @@ double sq_defined_later(double x) { // CHECK-NEXT: { // CHECK-NEXT: arr[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_arr[0]; -// CHECK-NEXT: _d_arr[0] = 0; +// CHECK-NEXT: _d_arr[0] = 0.; // CHECK-NEXT: _d_arr[0] += 5 * _r_d0; // CHECK-NEXT: _d_arr[1] += _r_d0; // CHECK-NEXT: } @@ -915,7 +915,7 @@ double sq_defined_later(double x) { // CHECK: void identity_pullback(double &i, double _d_y, double *_d_i) { // CHECK-NEXT: MyStruct::myFunction(); -// CHECK-NEXT: double _d__d_i = 0; +// CHECK-NEXT: double _d__d_i = 0.; // CHECK-NEXT: double _d_i0 = i; // CHECK-NEXT: double _t0 = _d_i0; // CHECK-NEXT: _d_i0 += 1; @@ -929,7 +929,7 @@ double sq_defined_later(double x) { // CHECK: clad::ValueAndAdjoint identity_forw(double &i, double *_d_i) { // CHECK-NEXT: MyStruct::myFunction(); -// CHECK-NEXT: double _d__d_i = 0; +// CHECK-NEXT: double _d__d_i = 0.; // CHECK-NEXT: double _d_i0 = i; // CHECK-NEXT: double _t0 = _d_i0; // CHECK-NEXT: _d_i0 += 1; @@ -967,7 +967,7 @@ double sq_defined_later(double x) { // CHECK-NEXT: if (_cond1) { // CHECK-NEXT: _cond0 = _t0; // CHECK-NEXT: double _r_d0 = _d_cond0; -// CHECK-NEXT: _d_cond0 = 0; +// CHECK-NEXT: _d_cond0 = 0.; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -1009,8 +1009,8 @@ double sq_defined_later(double x) { //CHECK-NEXT: if (_cond0) //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 0; -//CHECK-NEXT: double _r1 = 0; +//CHECK-NEXT: double _r0 = 0.; +//CHECK-NEXT: double _r1 = 0.; //CHECK-NEXT: recFun_pullback(x - 1, y, _d_y0, &_r0, &_r1); //CHECK-NEXT: *_d_x += _r0; //CHECK-NEXT: *_d_y += _r1; diff --git a/test/Gradient/Loops.C b/test/Gradient/Loops.C index cdd319767..397ec653f 100644 --- a/test/Gradient/Loops.C +++ b/test/Gradient/Loops.C @@ -1605,7 +1605,7 @@ double fn19(double* arr, int n) { // CHECK-NEXT: int i = 0; // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: double *_d_ref = 0.; +// CHECK-NEXT: double *_d_ref = {}; // CHECK-NEXT: double *ref = {}; // CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: double _d_res = 0.; @@ -1652,7 +1652,7 @@ double f_loop_init_var(double lower, double upper) { // CHECK: void f_loop_init_var_grad(double lower, double upper, double *_d_lower, double *_d_upper) { // CHECK-NEXT: double _d_x = 0.; -// CHECK-NEXT: double x = 0; +// CHECK-NEXT: double x = 0.; // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: double _d_sum = 0.; @@ -2696,10 +2696,10 @@ double fn34(double x, double y){ //CHECK: void fn34_grad(double x, double y, double *_d_x, double *_d_y) { //CHECK-NEXT: unsigned {{int|long}} _t0; -//CHECK-NEXT: double (*_d___range1)[3] = 0.; +//CHECK-NEXT: double (*_d___range1)[3] = {}; //CHECK-NEXT: double (*__range10)[3] = {}; -//CHECK-NEXT: double *_d___begin1 = 0; -//CHECK-NEXT: double *__begin10 = 0; +//CHECK-NEXT: double *_d___begin1 = {}; +//CHECK-NEXT: double *__begin10 = {}; //CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::tape _t3 = {}; @@ -2713,8 +2713,8 @@ double fn34(double x, double y){ //CHECK-NEXT: __range10 = &a; //CHECK-NEXT: __begin10 = *__range10; //CHECK-NEXT: double *__end10 = *__range10 + {{3|3L}}; -//CHECK-NEXT: double *_d_i = 0.; -//CHECK-NEXT: double *i = 0; +//CHECK-NEXT: double *_d_i = {}; +//CHECK-NEXT: double *i = {}; //CHECK-NEXT: for (; __begin10 != __end10; ++__begin10 , ++_d___begin1) { //CHECK-NEXT: { //CHECK-NEXT: _t0++; @@ -2762,10 +2762,10 @@ double fn35(double x, double y){ //CHECK: void fn35_grad(double x, double y, double *_d_x, double *_d_y) { //CHECK-NEXT: unsigned {{int|long}} _t0; -//CHECK-NEXT: double (*_d___range1)[3] = 0.; +//CHECK-NEXT: double (*_d___range1)[3] = {}; //CHECK-NEXT: double (*__range10)[3] = {}; -//CHECK-NEXT: double *_d___begin1 = 0.; -//CHECK-NEXT: double *__begin10 = 0; +//CHECK-NEXT: double *_d___begin1 = {}; +//CHECK-NEXT: double *__begin10 = {}; //CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::tape _t3 = {}; @@ -2781,7 +2781,7 @@ double fn35(double x, double y){ //CHECK-NEXT: __begin10 = *__range10; //CHECK-NEXT: double *__end10 = *__range10 + {{3|3L}}; //CHECK-NEXT: double _d_i = 0.; -//CHECK-NEXT: double i = 0; +//CHECK-NEXT: double i = 0.; //CHECK-NEXT: for (; __begin10 != __end10; ++__begin10 , ++_d___begin1) { //CHECK-NEXT: { //CHECK-NEXT: _t0++; diff --git a/test/Gradient/MemberFunctions.C b/test/Gradient/MemberFunctions.C index fa5b2e52c..b744e0673 100644 --- a/test/Gradient/MemberFunctions.C +++ b/test/Gradient/MemberFunctions.C @@ -363,7 +363,7 @@ public: double partial_mem_fn(double i, double j) { return (x + y) * i + i * j; } // CHECK: void partial_mem_fn_grad_0(double i, double j, SimpleFunctions *_d_this, double *_d_i) { - // CHECK-NEXT: double _d_j = 0; + // CHECK-NEXT: double _d_j = 0.; // CHECK-NEXT: { // CHECK-NEXT: (*_d_this).x += 1 * i; // CHECK-NEXT: (*_d_this).y += 1 * i; @@ -438,7 +438,7 @@ double fn2(SimpleFunctions& sf, double i) { // CHECK-NEXT: SimpleFunctions _t0 = sf; // CHECK-NEXT: clad::ValueAndAdjoint _t1 = _t0.ref_mem_fn_forw(i, &(*_d_sf), nullptr); // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; +// CHECK-NEXT: double _r0 = 0.; // CHECK-NEXT: _t0.ref_mem_fn_pullback(i, 1, &(*_d_sf), &_r0); // CHECK-NEXT: *_d_i += _r0; // CHECK-NEXT: } @@ -463,7 +463,7 @@ double fn5(SimpleFunctions& v, double value) { // CHECK-NEXT: clad::ValueAndAdjoint _t1 = _t0.operator_plus_equal_forw(value, &(*_d_v), nullptr); // CHECK-NEXT: (*_d_v).x += 1; // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; +// CHECK-NEXT: double _r0 = 0.; // CHECK-NEXT: _t0.operator_plus_equal_pullback(value, {}, &(*_d_v), &_r0); // CHECK-NEXT: *_d_value += _r0; // CHECK-NEXT: } @@ -537,7 +537,7 @@ int main() { auto d_const_volatile_lval_ref_mem_fn_i = clad::gradient(&SimpleFunctions::const_volatile_lval_ref_mem_fn, "i"); // CHECK: void const_volatile_lval_ref_mem_fn_grad_0(double i, double j, volatile SimpleFunctions *_d_this, double *_d_i) const volatile & { - // CHECK-NEXT: double _d_j = 0; + // CHECK-NEXT: double _d_j = 0.; // CHECK-NEXT: double _t0 = (this->x + this->y); // CHECK-NEXT: { // CHECK-NEXT: (*_d_this).x += 1 * i; @@ -551,7 +551,7 @@ int main() { auto d_const_volatile_rval_ref_mem_fn_j = clad::gradient(&SimpleFunctions::const_volatile_rval_ref_mem_fn, "j"); // CHECK: void const_volatile_rval_ref_mem_fn_grad_1(double i, double j, volatile SimpleFunctions *_d_this, double *_d_j) const volatile && { - // CHECK-NEXT: double _d_i = 0; + // CHECK-NEXT: double _d_i = 0.; // CHECK-NEXT: double _t0 = (this->x + this->y); // CHECK-NEXT: { // CHECK-NEXT: (*_d_this).x += 1 * i; @@ -568,14 +568,14 @@ int main() { printf("%.2f %.2f", result[0], result[1]); // CHECK-EXEC: 10.00 4.00 // CHECK: void fn3_grad_2_3(double x, double y, double i, double j, double *_d_i, double *_d_j) { -// CHECK-NEXT: double _d_x = 0; -// CHECK-NEXT: double _d_y = 0; +// CHECK-NEXT: double _d_x = 0.; +// CHECK-NEXT: double _d_y = 0.; // CHECK-NEXT: SimpleFunctions _d_sf({}); // CHECK-NEXT: SimpleFunctions sf(x, y); // CHECK-NEXT: SimpleFunctions _t0 = sf; // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; -// CHECK-NEXT: double _r1 = 0; +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; // CHECK-NEXT: _t0.mem_fn_pullback(i, j, 1, &_d_sf, &_r0, &_r1); // CHECK-NEXT: *_d_i += _r0; // CHECK-NEXT: *_d_j += _r1; @@ -591,13 +591,13 @@ int main() { // CHECK-NEXT: { // CHECK-NEXT: this->x = _t1; // CHECK-NEXT: double _r_d1 = (*_d_this).x; -// CHECK-NEXT: (*_d_this).x = 0; +// CHECK-NEXT: (*_d_this).x = 0.; // CHECK-NEXT: *_d_i += -_r_d1; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: this->x = _t0; // CHECK-NEXT: double _r_d0 = (*_d_this).x; -// CHECK-NEXT: (*_d_this).x = 0; +// CHECK-NEXT: (*_d_this).x = 0.; // CHECK-NEXT: *_d_i += _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/NonDifferentiable.C b/test/Gradient/NonDifferentiable.C index 8ad0ea115..bfe7d2d11 100644 --- a/test/Gradient/NonDifferentiable.C +++ b/test/Gradient/NonDifferentiable.C @@ -130,8 +130,8 @@ int main() { // CHECK-NEXT: SimpleFunctions1 obj(2, 3); // CHECK-NEXT: SimpleFunctions1 _t0 = obj; // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 0; - // CHECK-NEXT: double _r1 = 0; + // CHECK-NEXT: double _r0 = 0.; + // CHECK-NEXT: double _r1 = 0.; // CHECK-NEXT: _t0.mem_fn_1_pullback(i, j, 1, &_d_obj, &_r0, &_r1); // CHECK-NEXT: *_d_i += _r0; // CHECK-NEXT: *_d_j += _r1; @@ -169,7 +169,7 @@ int main() { // CHECK-NEXT: } // CHECK: void fn_non_diff_var_grad(double i, double j, double *_d_i, double *_d_j) { - // CHECK-NEXT: double _d_k = 0; + // CHECK-NEXT: double _d_k = 0.; // CHECK-NEXT: double k = i * i * j; // CHECK-NEXT: _d_k += 1; // CHECK-NEXT: } diff --git a/test/Gradient/Pointers.C b/test/Gradient/Pointers.C index 3232bdf42..027c0d83a 100644 --- a/test/Gradient/Pointers.C +++ b/test/Gradient/Pointers.C @@ -33,7 +33,7 @@ double minimalPointer(double x) { // CHECK-NEXT: { // CHECK-NEXT: *p = _t0; // CHECK-NEXT: double _r_d0 = *_d_p; -// CHECK-NEXT: *_d_p = 0; +// CHECK-NEXT: *_d_p = 0.; // CHECK-NEXT: *_d_p += _r_d0 * (*p); // CHECK-NEXT: *_d_p += *p * _r_d0; // CHECK-NEXT: } @@ -62,7 +62,7 @@ double arrayPointer(const double* arr) { // CHECK-NEXT: double *_t1 = _d_p; // CHECK-NEXT: _d_p = _d_p + 1; // CHECK-NEXT: p = p + 1; -// CHECK-NEXT: double _d_sum = 0; +// CHECK-NEXT: double _d_sum = 0.; // CHECK-NEXT: double sum = *p; // CHECK-NEXT: _d_p++; // CHECK-NEXT: p++; @@ -147,17 +147,17 @@ double pointerParam(const double* arr, size_t n) { } // CHECK: void pointerParam_grad_0(const double *arr, size_t n, double *_d_arr) { -// CHECK-NEXT: size_t _d_n = 0; -// CHECK-NEXT: size_t _d_i = 0; -// CHECK-NEXT: size_t i = 0; +// CHECK-NEXT: size_t _d_n = 0UL; +// CHECK-NEXT: size_t _d_i = 0UL; +// CHECK-NEXT: size_t i = 0UL; // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: size_t *_d_j = 0; -// CHECK-NEXT: size_t *j = 0; +// CHECK-NEXT: size_t *_d_j = {}; +// CHECK-NEXT: size_t *j = {}; // CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: clad::tape _t6 = {}; -// CHECK-NEXT: double _d_sum = 0; +// CHECK-NEXT: double _d_sum = 0.; // CHECK-NEXT: double sum = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { @@ -214,7 +214,7 @@ double pointerMultipleParams(const double* a, const double* b) { } // CHECK: void pointerMultipleParams_grad(const double *a, const double *b, double *_d_a, double *_d_b) { -// CHECK-NEXT: double _d_sum = 0; +// CHECK-NEXT: double _d_sum = 0.; // CHECK-NEXT: double sum = b[2]; // CHECK-NEXT: const double *_t0 = b; // CHECK-NEXT: double *_t1 = _d_b; @@ -334,7 +334,7 @@ double newAndDeletePointer(double i, double j) { // CHECK-NEXT: r[0] = i + j; // CHECK-NEXT: double _t1 = r[1]; // CHECK-NEXT: r[1] = i * j; -// CHECK-NEXT: double _d_sum = 0; +// CHECK-NEXT: double _d_sum = 0.; // CHECK-NEXT: double sum = *p + *q + r[0] + r[1]; // CHECK-NEXT: _d_sum += 1; // CHECK-NEXT: { @@ -346,14 +346,14 @@ double newAndDeletePointer(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: r[1] = _t1; // CHECK-NEXT: double _r_d1 = _d_r[1]; -// CHECK-NEXT: _d_r[1] = 0; +// CHECK-NEXT: _d_r[1] = 0.; // CHECK-NEXT: *_d_i += _r_d1 * j; // CHECK-NEXT: *_d_j += i * _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: r[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_r[0]; -// CHECK-NEXT: _d_r[0] = 0; +// CHECK-NEXT: _d_r[0] = 0.; // CHECK-NEXT: *_d_i += _r_d0; // CHECK-NEXT: *_d_j += _r_d0; // CHECK-NEXT: } @@ -382,7 +382,7 @@ double structPointer (double x) { // CHECK: void structPointer_grad(double x, double *_d_x) { // CHECK-NEXT: T *_d_t = new T(); // CHECK-NEXT: T *t = new T({x, /*implicit*/(int)0}); -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = t->x; // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: _d_t->x += _d_res; @@ -407,7 +407,7 @@ double cStyleMemoryAlloc(double x, size_t n) { } // CHECK: void cStyleMemoryAlloc_grad_0(double x, size_t n, double *_d_x) { -// CHECK-NEXT: size_t _d_n = 0; +// CHECK-NEXT: size_t _d_n = 0UL; // CHECK-NEXT: T *_d_t = (T *)malloc(n * sizeof(T)); // CHECK-NEXT: T *t = (T *)malloc(n * sizeof(T)); // CHECK-NEXT: memset(_d_t, 0, n * sizeof(T)); @@ -418,7 +418,7 @@ double cStyleMemoryAlloc(double x, size_t n) { // CHECK-NEXT: double *p = (double *)calloc(1, sizeof(double)); // CHECK-NEXT: double _t1 = *p; // CHECK-NEXT: *p = x; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = t->x + *p; // CHECK-NEXT: double *_t2 = p; // CHECK-NEXT: double *_t3 = _d_p; @@ -437,7 +437,7 @@ double cStyleMemoryAlloc(double x, size_t n) { // CHECK-NEXT: { // CHECK-NEXT: p[1] = _t4; // CHECK-NEXT: double _r_d2 = _d_p[1]; -// CHECK-NEXT: _d_p[1] = 0; +// CHECK-NEXT: _d_p[1] = 0.; // CHECK-NEXT: *_d_x += 2 * _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { @@ -451,13 +451,13 @@ double cStyleMemoryAlloc(double x, size_t n) { // CHECK-NEXT: { // CHECK-NEXT: *p = _t1; // CHECK-NEXT: double _r_d1 = *_d_p; -// CHECK-NEXT: *_d_p = 0; +// CHECK-NEXT: *_d_p = 0.; // CHECK-NEXT: *_d_x += _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: t->x = _t0; // CHECK-NEXT: double _r_d0 = _d_t->x; -// CHECK-NEXT: _d_t->x = 0; +// CHECK-NEXT: _d_t->x = 0.; // CHECK-NEXT: *_d_x += _r_d0; // CHECK-NEXT: } // CHECK-NEXT: free(p); diff --git a/test/Gradient/Switch.C b/test/Gradient/Switch.C index 15bcc4524..477b26dd2 100644 --- a/test/Gradient/Switch.C +++ b/test/Gradient/Switch.C @@ -25,7 +25,7 @@ double fn1(double i, double j) { // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; // CHECK-NEXT: double _t4; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: int _d_count = 0; // CHECK-NEXT: int count = 1; @@ -140,7 +140,7 @@ double fn2(double i, double j) { // CHECK-NEXT: double _t4; // CHECK-NEXT: double _t5; // CHECK-NEXT: double _t6; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: { // CHECK-NEXT: count = 2; @@ -268,7 +268,7 @@ double fn3(double i, double j) { // CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: int counter = 2; @@ -392,7 +392,7 @@ double fn4(double i, double j) { // CHECK-NEXT: int counter = 0; // CHECK-NEXT: unsigned {{int|long}} _t2; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: { // CHECK-NEXT: switch (1) { @@ -478,7 +478,7 @@ double fn5(double i, double j) { // CHECK-NEXT: int _cond0; // CHECK-NEXT: double _t0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: { // CHECK-NEXT: count = 1; @@ -524,7 +524,7 @@ double fn6(double u, double v) { // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: int _d_res = 0; // CHECK-NEXT: int res = 0; -// CHECK-NEXT: double _d_temp = 0; +// CHECK-NEXT: double _d_temp = 0.; // CHECK-NEXT: double temp = 0; // CHECK-NEXT: { // CHECK-NEXT: _t0 = res; @@ -548,7 +548,7 @@ double fn6(double u, double v) { // CHECK-NEXT: { // CHECK-NEXT: temp = _t1; // CHECK-NEXT: double _r_d1 = _d_temp; -// CHECK-NEXT: _d_temp = 0; +// CHECK-NEXT: _d_temp = 0.; // CHECK-NEXT: } // CHECK-NEXT: if (true) // CHECK-NEXT: break; @@ -589,7 +589,7 @@ double fn7(double u, double v) { // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { diff --git a/test/Gradient/SwitchInit.C b/test/Gradient/SwitchInit.C index 62abf9525..97a7b1fc7 100644 --- a/test/Gradient/SwitchInit.C +++ b/test/Gradient/SwitchInit.C @@ -25,7 +25,7 @@ double fn1(double i, double j) { // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; // CHECK-NEXT: double _t4; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: { // CHECK-NEXT: count = 1; diff --git a/test/Gradient/TestTypeConversion.C b/test/Gradient/TestTypeConversion.C index dc5d087d4..85c581120 100644 --- a/test/Gradient/TestTypeConversion.C +++ b/test/Gradient/TestTypeConversion.C @@ -42,7 +42,7 @@ void fn_type_conversion_grad(float z, int a, float *_d_z, int *_d_a); // CHECK-NEXT: { // CHECK-NEXT: z = clad::pop(_t1); // CHECK-NEXT: float _r_d0 = *_d_z; -// CHECK-NEXT: *_d_z = 0; +// CHECK-NEXT: *_d_z = 0.F; // CHECK-NEXT: *_d_z += _r_d0 * a; // CHECK-NEXT: *_d_a += z * _r_d0; // CHECK-NEXT: } diff --git a/test/Gradient/UserDefinedTypes.C b/test/Gradient/UserDefinedTypes.C index f5f954808..190f0c193 100644 --- a/test/Gradient/UserDefinedTypes.C +++ b/test/Gradient/UserDefinedTypes.C @@ -20,7 +20,7 @@ double fn1(pairdd p, double i) { } // CHECK: void fn1_grad(pairdd p, double i, pairdd *_d_p, double *_d_i) { -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = p.first + 2 * p.second + 3 * i; // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { @@ -72,7 +72,7 @@ double fn2(Tangent t, double i) { // CHECK: void fn2_grad(Tangent t, double i, Tangent *_d_t, double *_d_i) { // CHECK-NEXT: Tangent _t0 = t; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = sum(t); // CHECK-NEXT: double _t1 = res; // CHECK-NEXT: res += sum(t.data) + i + 2 * t.data[0]; @@ -112,14 +112,14 @@ double fn3(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: t.data[1] = _t1; // CHECK-NEXT: double _r_d1 = _d_t.data[1]; -// CHECK-NEXT: _d_t.data[1] = 0; +// CHECK-NEXT: _d_t.data[1] = 0.; // CHECK-NEXT: *_d_i += 5 * _r_d1; // CHECK-NEXT: *_d_j += 3 * _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: t.data[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_t.data[0]; -// CHECK-NEXT: _d_t.data[0] = 0; +// CHECK-NEXT: _d_t.data[0] = 0.; // CHECK-NEXT: *_d_i += 2 * _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -168,8 +168,8 @@ double fn5(const Tangent& t, double i) { // CHECK: void fn5_grad(const Tangent &t, double i, Tangent *_d_t, double *_d_i) { // CHECK-NEXT: Tangent _t0 = t; // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; -// CHECK-NEXT: double _r1 = 0; +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; // CHECK-NEXT: _t0.someMemFn2_pullback(i, i, 1, &(*_d_t), &_r0, &_r1); // CHECK-NEXT: *_d_i += _r0; // CHECK-NEXT: *_d_i += _r1; @@ -196,7 +196,7 @@ double fn6(dcomplex c, double i) { // CHECK-NEXT: dcomplex _t1 = c; // CHECK-NEXT: dcomplex _t3 = c; // CHECK-NEXT: double _t2 = c.imag(); -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = c.real() + 3 * _t2 + 6 * i; // CHECK-NEXT: double _t4 = res; // CHECK-NEXT: dcomplex _t6 = c; @@ -214,7 +214,7 @@ double fn6(dcomplex c, double i) { // CHECK-NEXT: *_d_i += 6 * _d_res; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; +// CHECK-NEXT: double _r0 = 0.; // CHECK-NEXT: _t0.real_pullback(5 * i, &(*_d_c), &_r0); // CHECK-NEXT: *_d_i += 5 * _r0; // CHECK-NEXT: } @@ -239,7 +239,7 @@ double fn7(dcomplex c1, dcomplex c2) { // CHECK-NEXT: _t6.imag_pullback(3 * 1, &(*_d_c1)); // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; +// CHECK-NEXT: double _r0 = 0.; // CHECK-NEXT: _t3.real_pullback(c2.imag() + 5 * _t1, &(*_d_c1), &_r0); // CHECK-NEXT: _t0.imag_pullback(_r0, &(*_d_c2)); // CHECK-NEXT: _t2.real_pullback(5 * _r0, &(*_d_c2)); @@ -263,7 +263,7 @@ double fn8(Tangent t, dcomplex c) { // CHECK-NEXT: sum_pullback(_t2, 1, &(*_d_t)); // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; +// CHECK-NEXT: double _r0 = 0.; // CHECK-NEXT: _t1.updateTo_pullback(c.real(), &(*_d_t), &_r0); // CHECK-NEXT: _t0.real_pullback(_r0, &(*_d_c)); // CHECK-NEXT: } @@ -285,7 +285,7 @@ double fn9(Tangent t, dcomplex c) { // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { @@ -370,7 +370,7 @@ int main() { // CHECK-NEXT: int _d_i = 0; // CHECK-NEXT: int i = 0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { @@ -399,7 +399,7 @@ int main() { // CHECK-NEXT: int _d_i = 0; // CHECK-NEXT: int i = 0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _d_res = 0.; // CHECK-NEXT: double res = 0; // CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}}; // CHECK-NEXT: for (i = 0; ; ++i) { @@ -440,7 +440,7 @@ int main() { // CHECK-NEXT: { // CHECK-NEXT: {{(__real)?}} this->[[_M_value:.*]] = _t0; // CHECK-NEXT: double _r_d0 ={{( __real)?}} (*_d_this).[[_M_value]]; -// CHECK-NEXT: {{(__real)?}} (*_d_this).[[_M_value]] = 0; +// CHECK-NEXT: {{(__real)?}} (*_d_this).[[_M_value]] = 0.; // CHECK-NEXT: *[[_d___val]] += _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -475,7 +475,7 @@ int main() { // CHECK-NEXT: --i; // CHECK-NEXT: this->data[i] = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = (*_d_this).data[i]; -// CHECK-NEXT: (*_d_this).data[i] = 0; +// CHECK-NEXT: (*_d_this).data[i] = 0.; // CHECK-NEXT: *_d_d += _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } \ No newline at end of file diff --git a/test/Gradient/constexprTest.C b/test/Gradient/constexprTest.C index 7339b29a9..6da68fc1b 100644 --- a/test/Gradient/constexprTest.C +++ b/test/Gradient/constexprTest.C @@ -13,7 +13,7 @@ constexpr double mul (double a, double b, double c) { } //CHECK: constexpr void mul_grad(double a, double b, double c, double *_d_a, double *_d_b, double *_d_c) { -//CHECK-NEXT: double _d_result = 0; +//CHECK-NEXT: double _d_result = 0.; //CHECK-NEXT: double result = a * b * c; //CHECK-NEXT: _d_result += 1; //CHECK-NEXT: { @@ -30,9 +30,9 @@ constexpr double fn( double a, double b, double c) { } //CHECK: constexpr void fn_grad(double a, double b, double c, double *_d_a, double *_d_b, double *_d_c) { -//CHECK-NEXT: double _d_val = 0; +//CHECK-NEXT: double _d_val = 0.; //CHECK-NEXT: double val = 98.; -//CHECK-NEXT: double _d_result = 0; +//CHECK-NEXT: double _d_result = 0.; //CHECK-NEXT: double result = a * b / c * (a + b) * 100 + c; //CHECK-NEXT: _d_result += 1; //CHECK-NEXT: { diff --git a/test/Hessian/BuiltinDerivatives.C b/test/Hessian/BuiltinDerivatives.C index 932b4d939..416679d89 100644 --- a/test/Hessian/BuiltinDerivatives.C +++ b/test/Hessian/BuiltinDerivatives.C @@ -186,7 +186,7 @@ int main() { // CHECK: void cos_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x); // CHECK: void f1_darg0_grad(float x, float *_d_x) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, _d_x0); @@ -197,15 +197,15 @@ int main() { // CHECK-NEXT: _d__t1.pushforward += 1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: cos_pushforward_pullback(x, _d_x0, _d__t1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r2; // CHECK-NEXT: _d__d_x += _r3; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: sin_pushforward_pullback(x, _d_x0, _d__t0, &_r0, &_r1); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: _d__d_x += _r1; @@ -221,14 +221,14 @@ int main() { // CHECK: void exp_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x); // CHECK: void f2_darg0_grad(float x, float *_d_x) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, _d_x0); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: exp_pushforward_pullback(x, _d_x0, _d__t0, &_r0, &_r1); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: _d__d_x += _r1; @@ -244,14 +244,14 @@ int main() { // CHECK: void log_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x); // CHECK: void f3_darg0_grad(float x, float *_d_x) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::log_pushforward(x, _d_x0); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: log_pushforward_pullback(x, _d_x0, _d__t0, &_r0, &_r1); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: _d__d_x += _r1; @@ -267,16 +267,16 @@ int main() { // CHECK: void pow_pushforward_pullback(float x, float exponent, float d_x, float d_exponent, ValueAndPushforward _d_y, float *_d_x, float *_d_exponent, float *_d_d_x, float *_d_d_exponent); // CHECK: void f4_darg0_grad(float x, float *_d_x) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, 4.F, _d_x0, 0.F); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: pow_pushforward_pullback(x, 4.F, _d_x0, 0.F, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: _d__d_x += _r2; @@ -290,16 +290,16 @@ int main() { // CHECK-NEXT: } // CHECK: void f5_darg0_grad(float x, float *_d_x) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(2.F, x, 0.F, _d_x0); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: pow_pushforward_pullback(2.F, x, 0.F, _d_x0, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r1; // CHECK-NEXT: _d__d_x += _r3; @@ -314,18 +314,18 @@ int main() { // CHECK-NEXT: } // CHECK: void f6_darg0_grad(float x, float y, float *_d_x, float *_d_y) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: float _d__d_y = 0; +// CHECK-NEXT: float _d__d_y = 0.F; // CHECK-NEXT: float _d_y0 = 0; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: pow_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: *_d_y += _r1; @@ -342,18 +342,18 @@ int main() { // CHECK-NEXT: } // CHECK: void f6_darg1_grad(float x, float y, float *_d_x, float *_d_y) { -// CHECK-NEXT: float _d__d_x = 0; +// CHECK-NEXT: float _d__d_x = 0.F; // CHECK-NEXT: float _d_x0 = 0; -// CHECK-NEXT: float _d__d_y = 0; +// CHECK-NEXT: float _d__d_y = 0.F; // CHECK-NEXT: float _d_y0 = 1; // CHECK-NEXT: ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: pow_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: *_d_y += _r1; @@ -364,7 +364,7 @@ int main() { // CHECK: void f7_darg0_grad(float x, float y, float *_d_x, float *_d_y) { // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; +// CHECK-NEXT: float _r0 = 0.F; // CHECK-NEXT: _r0 += 1 * clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: } @@ -373,10 +373,10 @@ int main() { // CHECK: void sin_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x) { // CHECK-NEXT: float _t0 = ::std::cos(x); // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; +// CHECK-NEXT: float _r0 = 0.F; // CHECK-NEXT: _r0 += _d_y.value * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: _r1 += _d_y.pushforward * d_x * clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r1; // CHECK-NEXT: *_d_d_x += _t0 * _d_y.pushforward; @@ -386,10 +386,10 @@ int main() { // CHECK: void cos_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x) { // CHECK-NEXT: float _t0 = ::std::sin(x); // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; +// CHECK-NEXT: float _r0 = 0.F; // CHECK-NEXT: _r0 += _d_y.value * clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: _r1 += -1 * _d_y.pushforward * d_x * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r1; // CHECK-NEXT: *_d_d_x += -1 * _t0 * _d_y.pushforward; @@ -399,10 +399,10 @@ int main() { // CHECK: void exp_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x) { // CHECK-NEXT: float _t0 = ::std::exp(x); // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; +// CHECK-NEXT: float _r0 = 0.F; // CHECK-NEXT: _r0 += _d_y.value * clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: _r1 += _d_y.pushforward * d_x * clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r1; // CHECK-NEXT: *_d_d_x += _t0 * _d_y.pushforward; @@ -411,7 +411,7 @@ int main() { // CHECK: void log_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, float *_d_x, float *_d_d_x) { // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; +// CHECK-NEXT: float _r0 = 0.F; // CHECK-NEXT: _r0 += _d_y.value * clad::custom_derivatives{{(::std)?}}::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: double _r1 = _d_y.pushforward * d_x * -(1. / (x * x)); @@ -425,10 +425,10 @@ int main() { // CHECK-NEXT: float _t1; // CHECK-NEXT: float _t2; // CHECK-NEXT: float _t3; -// CHECK-NEXT: float _d_val = 0; +// CHECK-NEXT: float _d_val = 0.F; // CHECK-NEXT: float val = ::std::pow(x, exponent); // CHECK-NEXT: float _t0 = ::std::pow(x, exponent - 1); -// CHECK-NEXT: float _d_derivative = 0; +// CHECK-NEXT: float _d_derivative = 0.F; // CHECK-NEXT: float derivative = (exponent * _t0) * d_x; // CHECK-NEXT: { // CHECK-NEXT: _cond0 = d_exponent; @@ -446,28 +446,28 @@ int main() { // CHECK-NEXT: if (_cond0) { // CHECK-NEXT: derivative = _t1; // CHECK-NEXT: float _r_d0 = _d_derivative; -// CHECK-NEXT: float _r4 = 0; -// CHECK-NEXT: float _r5 = 0; +// CHECK-NEXT: float _r4 = 0.F; +// CHECK-NEXT: float _r5 = 0.F; // CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(x, exponent, _r_d0 * d_exponent * _t2, &_r4, &_r5); // CHECK-NEXT: *_d_x += _r4; // CHECK-NEXT: *_d_exponent += _r5; -// CHECK-NEXT: float _r6 = 0; +// CHECK-NEXT: float _r6 = 0.F; // CHECK-NEXT: _r6 += _t3 * _r_d0 * d_exponent * clad::custom_derivatives{{(::std)?}}::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: *_d_x += _r6; // CHECK-NEXT: *_d_d_exponent += (_t3 * _t2) * _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: *_d_exponent += _d_derivative * d_x * _t0; -// CHECK-NEXT: float _r2 = 0; -// CHECK-NEXT: float _r3 = 0; +// CHECK-NEXT: float _r2 = 0.F; +// CHECK-NEXT: float _r3 = 0.F; // CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(x, exponent - 1, exponent * _d_derivative * d_x, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r2; // CHECK-NEXT: *_d_exponent += _r3; // CHECK-NEXT: *_d_d_x += (exponent * _t0) * _d_derivative; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = 0; -// CHECK-NEXT: float _r1 = 0; +// CHECK-NEXT: float _r0 = 0.F; +// CHECK-NEXT: float _r1 = 0.F; // CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(x, exponent, _d_val, &_r0, &_r1); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: *_d_exponent += _r1; diff --git a/test/Hessian/Hessians.C b/test/Hessian/Hessians.C index cfe9a3202..691c64cca 100644 --- a/test/Hessian/Hessians.C +++ b/test/Hessian/Hessians.C @@ -215,13 +215,13 @@ int main() { //CHECK-NEXT:} //CHECK:{{[__attribute__((always_inline)) ]*}}void f_cubed_add1_darg0_grad(double a, double b, double *_d_a, double *_d_b){{[ __attribute__((always_inline))]*}} { -//CHECK-NEXT: double _d__d_a = 0; +//CHECK-NEXT: double _d__d_a = 0.; //CHECK-NEXT: double _d_a0 = 1; -//CHECK-NEXT: double _d__d_b = 0; +//CHECK-NEXT: double _d__d_b = 0.; //CHECK-NEXT: double _d_b0 = 0; -//CHECK-NEXT: double _d__t0 = 0; +//CHECK-NEXT: double _d__t0 = 0.; //CHECK-NEXT: double _t00 = a * a; -//CHECK-NEXT: double _d__t1 = 0; +//CHECK-NEXT: double _d__t1 = 0.; //CHECK-NEXT: double _t10 = b * b; //CHECK-NEXT: { //CHECK-NEXT: _d__d_a += 1 * a * a; @@ -250,13 +250,13 @@ int main() { //CHECK-NEXT:} //CHECK:{{[__attribute__((always_inline)) ]*}}void f_cubed_add1_darg1_grad(double a, double b, double *_d_a, double *_d_b){{[ __attribute__((always_inline))]*}} { -//CHECK-NEXT: double _d__d_a = 0; +//CHECK-NEXT: double _d__d_a = 0.; //CHECK-NEXT: double _d_a0 = 0; -//CHECK-NEXT: double _d__d_b = 0; +//CHECK-NEXT: double _d__d_b = 0.; //CHECK-NEXT: double _d_b0 = 1; -//CHECK-NEXT: double _d__t0 = 0; +//CHECK-NEXT: double _d__t0 = 0.; //CHECK-NEXT: double _t00 = a * a; -//CHECK-NEXT: double _d__t1 = 0; +//CHECK-NEXT: double _d__t1 = 0.; //CHECK-NEXT: double _t10 = b * b; //CHECK-NEXT: { //CHECK-NEXT: _d__d_a += 1 * a * a; diff --git a/test/Hessian/NestedFunctionCalls.C b/test/Hessian/NestedFunctionCalls.C index 093c15cdf..743eeb593 100644 --- a/test/Hessian/NestedFunctionCalls.C +++ b/test/Hessian/NestedFunctionCalls.C @@ -41,24 +41,24 @@ double f2(double x, double y){ // CHECK: void f_pushforward_pullback(double x, double y, double _d_x, double _d_y, clad::ValueAndPushforward _d_y0, double *_d_x, double *_d_y, double *_d__d_x, double *_d__d_y); // CHECK: void f2_darg0_grad(double x, double y, double *_d_x, double *_d_y) { -// CHECK-NEXT: double _d__d_x = 0; +// CHECK-NEXT: double _d__d_x = 0.; // CHECK-NEXT: double _d_x0 = 1; -// CHECK-NEXT: double _d__d_y = 0; +// CHECK-NEXT: double _d__d_y = 0.; // CHECK-NEXT: double _d_y0 = 0; // CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(x, y, _d_x0, _d_y0); -// CHECK-NEXT: double _d__d_ans = 0; +// CHECK-NEXT: double _d__d_ans = 0.; // CHECK-NEXT: double _d_ans = _t00.pushforward; -// CHECK-NEXT: double _d_ans0 = 0; +// CHECK-NEXT: double _d_ans0 = 0.; // CHECK-NEXT: double ans = _t00.value; // CHECK-NEXT: _d__d_ans += 1; // CHECK-NEXT: _d__t0.value += _d_ans0; // CHECK-NEXT: _d__t0.pushforward += _d__d_ans; // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; -// CHECK-NEXT: double _r1 = 0; -// CHECK-NEXT: double _r2 = 0; -// CHECK-NEXT: double _r3 = 0; +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; +// CHECK-NEXT: double _r2 = 0.; +// CHECK-NEXT: double _r3 = 0.; // CHECK-NEXT: f_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: *_d_y += _r1; @@ -77,24 +77,24 @@ double f2(double x, double y){ // CHECK-NEXT: } // CHECK: void f2_darg1_grad(double x, double y, double *_d_x, double *_d_y) { -// CHECK-NEXT: double _d__d_x = 0; +// CHECK-NEXT: double _d__d_x = 0.; // CHECK-NEXT: double _d_x0 = 0; -// CHECK-NEXT: double _d__d_y = 0; +// CHECK-NEXT: double _d__d_y = 0.; // CHECK-NEXT: double _d_y0 = 1; // CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(x, y, _d_x0, _d_y0); -// CHECK-NEXT: double _d__d_ans = 0; +// CHECK-NEXT: double _d__d_ans = 0.; // CHECK-NEXT: double _d_ans = _t00.pushforward; -// CHECK-NEXT: double _d_ans0 = 0; +// CHECK-NEXT: double _d_ans0 = 0.; // CHECK-NEXT: double ans = _t00.value; // CHECK-NEXT: _d__d_ans += 1; // CHECK-NEXT: _d__t0.value += _d_ans0; // CHECK-NEXT: _d__t0.pushforward += _d__d_ans; // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 0; -// CHECK-NEXT: double _r1 = 0; -// CHECK-NEXT: double _r2 = 0; -// CHECK-NEXT: double _r3 = 0; +// CHECK-NEXT: double _r0 = 0.; +// CHECK-NEXT: double _r1 = 0.; +// CHECK-NEXT: double _r2 = 0.; +// CHECK-NEXT: double _r3 = 0.; // CHECK-NEXT: f_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_r0, &_r1, &_r2, &_r3); // CHECK-NEXT: *_d_x += _r0; // CHECK-NEXT: *_d_y += _r1; diff --git a/test/Hessian/Pointers.C b/test/Hessian/Pointers.C index ceb02b63f..886e2469f 100644 --- a/test/Hessian/Pointers.C +++ b/test/Hessian/Pointers.C @@ -21,16 +21,16 @@ double nonMemFn(double i, double j) { // CHECK-NEXT: } // CHECK: double nonMemFn_darg0(double i, double j) { -// CHECK-NEXT: double _d_i = 1.; -// CHECK-NEXT: double _d_j = 0.; +// CHECK-NEXT: double _d_i = 1; +// CHECK-NEXT: double _d_j = 0; // CHECK-NEXT: return _d_i * j + i * _d_j; // CHECK-NEXT: } // CHECK: void nonMemFn_darg0_grad(double i, double j, double *_d_i, double *_d_j) { // CHECK-NEXT: double _d__d_i = 0.; -// CHECK-NEXT: double _d_i0 = 1.; +// CHECK-NEXT: double _d_i0 = 1; // CHECK-NEXT: double _d__d_j = 0.; -// CHECK-NEXT: double _d_j0 = 0.; +// CHECK-NEXT: double _d_j0 = 0; // CHECK-NEXT: { // CHECK-NEXT: _d__d_i += 1 * j; // CHECK-NEXT: *_d_j += _d_i0 * 1; @@ -40,16 +40,16 @@ double nonMemFn(double i, double j) { // CHECK-NEXT: } // CHECK: double nonMemFn_darg1(double i, double j) { -// CHECK-NEXT: double _d_i = 0.; -// CHECK-NEXT: double _d_j = 1.; +// CHECK-NEXT: double _d_i = 0; +// CHECK-NEXT: double _d_j = 1; // CHECK-NEXT: return _d_i * j + i * _d_j; // CHECK-NEXT: } // CHECK: void nonMemFn_darg1_grad(double i, double j, double *_d_i, double *_d_j) { // CHECK-NEXT: double _d__d_i = 0.; -// CHECK-NEXT: double _d_i0 = 0.; +// CHECK-NEXT: double _d_i0 = 0; // CHECK-NEXT: double _d__d_j = 0.; -// CHECK-NEXT: double _d_j0 = 1.; +// CHECK-NEXT: double _d_j0 = 1; // CHECK-NEXT: { // CHECK-NEXT: _d__d_i += 1 * j; // CHECK-NEXT: *_d_j += _d_i0 * 1; diff --git a/test/NumericalDiff/NoNumDiff.C b/test/NumericalDiff/NoNumDiff.C index 247dd04b5..0a14de784 100644 --- a/test/NumericalDiff/NoNumDiff.C +++ b/test/NumericalDiff/NoNumDiff.C @@ -11,7 +11,7 @@ double func(double x) { return std::tanh(x); } //CHECK: warning: Numerical differentiation is diabled using the -DCLAD_NO_NUM_DIFF flag, this means that every try to numerically differentiate a function will fail! Remove the flag to revert to default behaviour. //CHECK: warning: Numerical differentiation is diabled using the -DCLAD_NO_NUM_DIFF flag, this means that every try to numerically differentiate a function will fail! Remove the flag to revert to default behaviour. //CHECK: double func_darg0(double x) { -//CHECK-NEXT: double _d_x = 1.; +//CHECK-NEXT: double _d_x = 1; //CHECK-NEXT: return 0; //CHECK-NEXT: } diff --git a/test/NumericalDiff/NumDiff.C b/test/NumericalDiff/NumDiff.C index 168c7b439..baeb7391b 100644 --- a/test/NumericalDiff/NumDiff.C +++ b/test/NumericalDiff/NumDiff.C @@ -24,7 +24,7 @@ double test_2(double x){ return std::log10(x); } //CHECK: double test_2_darg0(double x) { -//CHECK-NEXT: double _d_x = 1.; +//CHECK-NEXT: double _d_x = 1; //CHECK-NEXT: return numerical_diff::forward_central_difference(std::log10, x, 0, 0, x) * _d_x; //CHECK-NEXT: } diff --git a/unittests/Misc/CallDeclOnly.cpp b/unittests/Misc/CallDeclOnly.cpp index 52cb2f395..4ee6db74d 100644 --- a/unittests/Misc/CallDeclOnly.cpp +++ b/unittests/Misc/CallDeclOnly.cpp @@ -24,13 +24,13 @@ TEST(CallDeclOnly, CheckNumDiff) { // Check the generated code from grad.dump() std::string expected = R"(The code is: void wrapper1_grad(double *params, double *_d_params) { - double _d_ix = 0; + double _d_ix = 0.; const double ix = 1 + params[0]; { - double _r0 = 0; - double _r1 = 0; - double _r2 = 0; - double _r3 = 0; + double _r0 = 0.; + double _r1 = 0.; + double _r2 = 0.; + double _r3 = 0.; double _grad0[4] = {0}; numerical_diff::central_difference(foo, _grad0, 0, 10., ix, 1., 0); _r0 += 1 * _grad0[0];