Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to improve literal types #998

Merged
merged 27 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2b2af14
Try to improve literal types
vaithak Jul 22, 2024
61982a1
Try to improve literal types
vaithak Jul 22, 2024
4432e1f
Merge remote-tracking branch 'refs/remotes/vaithak/cuda-bug' into cud…
kchristin22 Aug 3, 2024
4b57f76
Get enum's underlying value type
kchristin22 Aug 3, 2024
1f4e2a3
Try to improve literal types
vaithak Jul 22, 2024
97acf5f
Get enum's underlying value type
kchristin22 Aug 3, 2024
aee91cd
Zero initialization based on type
kchristin22 Aug 8, 2024
6130c91
Fix pointer zero initialization
kchristin22 Aug 13, 2024
98352a8
Merge with master
kchristin22 Aug 13, 2024
1de6bbe
Merge remote-tracking branch 'vaithak/cuda-bug' into cuda-bug
kchristin22 Aug 13, 2024
17012c0
Fix format
kchristin22 Aug 13, 2024
9feae1b
Fix compatibility of zero initialization of unsigned ints in tests
kchristin22 Aug 13, 2024
03fbcec
Fix clang-tidy suggestions
kchristin22 Aug 13, 2024
1a1e25b
Remove unnecessary leftover casting for zero initilization
kchristin22 Aug 21, 2024
2dc1126
Merge branch 'master' into cuda-bug
kchristin22 Aug 21, 2024
ac042f9
Fix STL test
kchristin22 Aug 21, 2024
69075f1
Synthesize booleans separately from integers and cast type to int whe…
kchristin22 Aug 26, 2024
3a593d0
Create the boolean literal with the new keyword for compatibility rea…
kchristin22 Aug 26, 2024
d3740e4
Remove fail case of type for zero initialization
kchristin22 Aug 26, 2024
2e6b9d0
Add complex type test
kchristin22 Aug 26, 2024
2a8655e
Revert "Add complex type test"
kchristin22 Aug 26, 2024
df2617d
Remove check for nonRealType before calling synthesizeLiteral
kchristin22 Sep 2, 2024
6816d9a
Initialize pointers as nullptr and add a default int case for literal…
kchristin22 Sep 2, 2024
f7b3caa
Merge branch 'master' into cuda-bug
kchristin22 Sep 2, 2024
c74882d
Fix clang format
kchristin22 Sep 2, 2024
fd45301
Init chars as ints to remove suffix
kchristin22 Sep 3, 2024
0413ab7
Use AnyCharacterType check instead of plain CharType
kchristin22 Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/Differentiator/BaseForwardModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,11 @@
// If DRE is of type pointer, then the derivative is a null pointer.
if (clonedDRE->getType()->isPointerType())
return StmtDiff(clonedDRE, nullptr);
QualType literalTy = utils::GetValueType(clonedDRE->getType());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should extend visitorbase::getZeroInit as discussed here #989 (comment)

cc: @gojakuch

if (!literalTy->isRealType())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this special check here?

literalTy = m_Context.IntTy;
return StmtDiff(clonedDRE, ConstantFolder::synthesizeLiteral(
m_Context.IntTy, m_Context, /*val=*/0));
literalTy, m_Context, /*val=*/0));
}

StmtDiff BaseForwardModeVisitor::VisitIntegerLiteral(const IntegerLiteral* IL) {
Expand Down Expand Up @@ -1374,8 +1377,12 @@
} else if (opKind == UnaryOperatorKind::UO_Deref) {
if (Expr* dx = diff.getExpr_dx())
return StmtDiff(op, BuildOp(opKind, dx));
return StmtDiff(op, ConstantFolder::synthesizeLiteral(
m_Context.IntTy, m_Context, /*val=*/0));
QualType literalTy =
utils::GetValueType(UnOp->getSubExpr()->getType()->getPointeeType());
if (!literalTy->isRealType())
literalTy = m_Context.IntTy;

Check warning on line 1383 in lib/Differentiator/BaseForwardModeVisitor.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Differentiator/BaseForwardModeVisitor.cpp#L1383

Added line #L1383 was not covered by tests
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not need this. This gets handled in ConstantFolder::synthesizeLiteral anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it was a leftover from Vaibhav's PR. I will remove these lines.

return StmtDiff(
op, ConstantFolder::synthesizeLiteral(literalTy, m_Context, /*val=*/0));
} else if (opKind == UnaryOperatorKind::UO_AddrOf) {
return StmtDiff(op, BuildOp(opKind, diff.getExpr_dx()));
} else if (opKind == UnaryOperatorKind::UO_LNot) {
Expand Down
4 changes: 4 additions & 0 deletions lib/Differentiator/CladUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ namespace clad {
else if (T->isArrayType())
valueType =
T->getPointeeOrArrayElementType()->getCanonicalTypeInternal();
else if (T->isEnumeralType()) {
if (const auto* ET = dyn_cast<EnumType>(T))
valueType = ET->getDecl()->getIntegerType();
}
valueType.removeLocalConst();
return valueType;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ namespace clad {
// FIXME: Consolidate other uses of synthesizeLiteral for creation 0 or 1.
if (T->isVoidType())
return nullptr;
if (T->isScalarType()) {
ExprResult Zero =
ConstantFolder::synthesizeLiteral(m_Context.IntTy, m_Context, 0);
if (T->isScalarType() && !T->isPointerType()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this here? Shouldn't ConstantFolder::synthesizeLiteral check if T is a pointer type and synthesize nullptr?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the pointers are initialized as an empty list, which is equivalent to nullptr, the same way clad tapes are initialized. I can alter them to be equal to nullptr if that's safer.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that'd be more readable, too.

ExprResult Zero = ConstantFolder::synthesizeLiteral(T, m_Context, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: argument comment missing for literal argument 'val' [bugprone-argument-comment]

      ExprResult Zero = ConstantFolder::synthesizeLiteral(T, m_Context, 0);
                                                                        ^

this fix will not be applied because it overlaps with another fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: argument comment missing for literal argument 'val' [bugprone-argument-comment]

Suggested change
ExprResult Zero = ConstantFolder::synthesizeLiteral(T, m_Context, 0);
ExprResult Zero = ConstantFolder::synthesizeLiteral(T, m_Context, /*val=*/0);

CastKind CK = m_Sema.PrepareScalarCast(Zero, T);
return m_Sema.ImpCastExprToType(Zero.get(), T, CK).get();
}
vgvassilev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions test/Arrays/ArrayInputsForwardMode.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ double multiply(const double *arr) {
}

//CHECK: double multiply_darg0_1(const double *arr) {
//CHECK-NEXT: return 0 * arr[1] + arr[0] * 1.;
//CHECK-NEXT: return 0. * arr[1] + arr[0] * 1.;
//CHECK-NEXT: }

double divide(const double *arr) {
return arr[0] / arr[1];
}

//CHECK: double divide_darg0_1(const double *arr) {
//CHECK-NEXT: return (0 * arr[1] - arr[0] * 1.) / (arr[1] * arr[1]);
//CHECK-NEXT: return (0. * arr[1] - arr[0] * 1.) / (arr[1] * arr[1]);
//CHECK-NEXT: }

double addArr(const double *arr, int n) {
Expand Down
46 changes: 23 additions & 23 deletions test/Arrays/ArrayInputsReverseMode.C
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ float func(float* a, float* b) {
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<float> _t1 = {};
//CHECK-NEXT: clad::tape<float> _t2 = {};
//CHECK-NEXT: float _d_sum = 0;
//CHECK-NEXT: float _d_sum = 0.F;
//CHECK-NEXT: float sum = 0;
//CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}};
//CHECK-NEXT: for (i = 0; ; i++) {
Expand Down Expand Up @@ -71,7 +71,7 @@ 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] = 0;
//CHECK-NEXT: _d_a[i] = 0.F;
//CHECK-NEXT: _d_a[i] += _r_d0 * b[i];
//CHECK-NEXT: _d_b[i] += a[i] * _r_d0;
//CHECK-NEXT: }
Expand All @@ -95,7 +95,7 @@ float func2(float* a) {
//CHECK-NEXT: int _d_i = 0;
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<float> _t1 = {};
//CHECK-NEXT: float _d_sum = 0;
//CHECK-NEXT: float _d_sum = 0.F;
//CHECK-NEXT: float sum = 0;
//CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}};
//CHECK-NEXT: for (i = 0; ; i++) {
Expand All @@ -116,7 +116,7 @@ float func2(float* a) {
//CHECK-NEXT: i--;
//CHECK-NEXT: sum = clad::pop(_t1);
//CHECK-NEXT: float _r_d0 = _d_sum;
//CHECK-NEXT: float _r0 = 0;
//CHECK-NEXT: float _r0 = 0.F;
//CHECK-NEXT: helper_pullback(a[i], _r_d0, &_r0);
//CHECK-NEXT: _d_a[i] += _r0;
//CHECK-NEXT: }
Expand All @@ -134,7 +134,7 @@ float func3(float* a, float* b) {
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<float> _t1 = {};
//CHECK-NEXT: clad::tape<float> _t2 = {};
//CHECK-NEXT: float _d_sum = 0;
//CHECK-NEXT: float _d_sum = 0.F;
//CHECK-NEXT: float sum = 0;
//CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}};
//CHECK-NEXT: for (i = 0; ; i++) {
Expand Down Expand Up @@ -178,7 +178,7 @@ double func4(double x) {
//CHECK-NEXT: clad::tape<double> _t1 = {};
//CHECK-NEXT: double _d_arr[3] = {0};
//CHECK-NEXT: double arr[3] = {x, 2 * x, x * x};
//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++) {
Expand Down Expand Up @@ -251,7 +251,7 @@ double func5(int k) {
//CHECK-NEXT: clad::push(_t1, arr[i]);
//CHECK-NEXT: arr[i] = k;
//CHECK-NEXT: }
//CHECK-NEXT: double _d_sum = 0;
//CHECK-NEXT: double _d_sum = 0.;
//CHECK-NEXT: double sum = 0;
//CHECK-NEXT: unsigned {{int|long}} _t2 = {{0U|0UL}};
//CHECK-NEXT: for (i0 = 0; ; i0++) {
Expand Down Expand Up @@ -287,7 +287,7 @@ double func5(int k) {
//CHECK-NEXT: {
//CHECK-NEXT: arr[i] = clad::pop(_t1);
//CHECK-NEXT: double _r_d0 = _d_arr[i];
//CHECK-NEXT: _d_arr[i] = 0;
//CHECK-NEXT: _d_arr[i] = 0.;
//CHECK-NEXT: *_d_k += _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand All @@ -310,7 +310,7 @@ double func6(double seed) {
//CHECK-NEXT: double _d_arr[3] = {0};
//CHECK-NEXT: clad::array<double> arr({{3U|3UL}});
//CHECK-NEXT: clad::tape<double> _t2 = {};
//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++) {
Expand Down Expand Up @@ -364,13 +364,13 @@ double func7(double *params) {
}

//CHECK: void func7_grad(double *params, double *_d_params) {
//CHECK-NEXT: std::size_t _d_i = 0;
//CHECK-NEXT: std::size_t i = 0;
//CHECK-NEXT: std::size_t _d_i = {{0U|0UL}};
//CHECK-NEXT: std::size_t i = {{0U|0UL}};
//CHECK-NEXT: clad::tape<clad::array<double> > _t1 = {};
//CHECK-NEXT: double _d_paramsPrime[1] = {0};
//CHECK-NEXT: clad::array<double> paramsPrime({{1U|1UL}});
//CHECK-NEXT: clad::tape<double> _t2 = {};
//CHECK-NEXT: double _d_out = 0;
//CHECK-NEXT: double _d_out = 0.;
//CHECK-NEXT: double out = 0.;
//CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}};
// CHECK-NEXT: for (i = 0; ; ++i) {
Expand All @@ -393,7 +393,7 @@ double func7(double *params) {
//CHECK-NEXT: {
//CHECK-NEXT: out = clad::pop(_t2);
//CHECK-NEXT: double _r_d0 = _d_out;
//CHECK-NEXT: _d_out = 0;
//CHECK-NEXT: _d_out = 0.;
//CHECK-NEXT: _d_out += _r_d0;
//CHECK-NEXT: inv_square_pullback(paramsPrime, _r_d0, _d_paramsPrime);
//CHECK-NEXT: }
Expand All @@ -420,7 +420,7 @@ double func8(double i, double *arr, int n) {
}

//CHECK: void func8_grad(double i, double *arr, int n, double *_d_i, double *_d_arr, int *_d_n) {
//CHECK-NEXT: double _d_res = 0;
//CHECK-NEXT: double _d_res = 0.;
//CHECK-NEXT: double res = 0;
//CHECK-NEXT: double _t0 = arr[0];
//CHECK-NEXT: arr[0] = 1;
Expand All @@ -432,13 +432,13 @@ double func8(double i, double *arr, int n) {
//CHECK-NEXT: {
//CHECK-NEXT: arr[0] = _t2;
//CHECK-NEXT: double _r_d2 = _d_arr[0];
//CHECK-NEXT: _d_arr[0] = 0;
//CHECK-NEXT: _d_arr[0] = 0.;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: res = _t1;
//CHECK-NEXT: double _r_d1 = _d_res;
//CHECK-NEXT: _d_res = 0;
//CHECK-NEXT: double _r0 = 0;
//CHECK-NEXT: _d_res = 0.;
//CHECK-NEXT: double _r0 = 0.;
//CHECK-NEXT: int _r1 = 0;
//CHECK-NEXT: helper2_pullback(i, arr, n, _r_d1, &_r0, _d_arr, &_r1);
//CHECK-NEXT: *_d_i += _r0;
Expand All @@ -447,7 +447,7 @@ double func8(double i, double *arr, int n) {
//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: }
//CHECK-NEXT: }

Expand Down Expand Up @@ -497,7 +497,7 @@ double func9(double i, double j) {
//CHECK-NEXT: --idx;
//CHECK-NEXT: {
//CHECK-NEXT: arr[idx] = clad::back(_t1);
//CHECK-NEXT: double _r0 = 0;
//CHECK-NEXT: double _r0 = 0.;
//CHECK-NEXT: modify_pullback(clad::back(_t1), i, &_d_arr[idx], &_r0);
//CHECK-NEXT: clad::pop(_t1);
//CHECK-NEXT: *_d_i += _r0;
Expand Down Expand Up @@ -526,7 +526,7 @@ double func10(double *arr, int n) {
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<double> _t1 = {};
//CHECK-NEXT: clad::tape<double> _t2 = {};
//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) {
Expand Down Expand Up @@ -626,7 +626,7 @@ int main() {
//CHECK-NEXT: int _d_i = 0;
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<double> _t1 = {};
//CHECK-NEXT: double _d_ret = 0;
//CHECK-NEXT: double _d_ret = 0.;
//CHECK-NEXT: double ret = 0;
//CHECK-NEXT: unsigned {{int|long}} _t0 = {{0U|0UL}};
// CHECK-NEXT: for (i = 0; ; i++) {
Expand Down Expand Up @@ -679,7 +679,7 @@ int main() {
//CHECK-NEXT: {
//CHECK-NEXT: elem = _t0;
//CHECK-NEXT: double _r_d0 = *_d_elem;
//CHECK-NEXT: *_d_elem = 0;
//CHECK-NEXT: *_d_elem = 0.;
//CHECK-NEXT: *_d_val += _r_d0;
//CHECK-NEXT: }
//CHECK-NEXT: }
Expand All @@ -691,7 +691,7 @@ int main() {
//CHECK-NEXT: {
//CHECK-NEXT: elem = _t0;
//CHECK-NEXT: double _r_d0 = *_d_elem;
//CHECK-NEXT: *_d_elem = 0;
//CHECK-NEXT: *_d_elem = 0.;
//CHECK-NEXT: *_d_elem += _r_d0 * elem;
//CHECK-NEXT: *_d_elem += elem * _r_d0;
//CHECK-NEXT: }
Expand Down
16 changes: 8 additions & 8 deletions test/CUDA/GradientCuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ __device__ __host__ double gauss(double* x, double* p, double sigma, int dim) {


// CHECK: void gauss_grad_1(double *x, double *p, double sigma, int dim, double *_d_p) __attribute__((device)) __attribute__((host)) {
//CHECK-NEXT: double _d_sigma = 0;
//CHECK-NEXT: double _d_sigma = 0.;
//CHECK-NEXT: int _d_dim = 0;
//CHECK-NEXT: int _d_i = 0;
//CHECK-NEXT: int i = 0;
//CHECK-NEXT: clad::tape<double> _t1 = {};
//CHECK-NEXT: double _d_t = 0;
//CHECK-NEXT: double _d_t = 0.;
//CHECK-NEXT: double t = 0;
//CHECK-NEXT: unsigned long _t0 = {{0U|0UL}};
//CHECK-NEXT: for (i = 0; ; i++) {
Expand All @@ -53,22 +53,22 @@ __device__ __host__ double gauss(double* x, double* p, double sigma, int dim) {
//CHECK-NEXT: double _t5 = std::pow(sigma, -0.5);
//CHECK-NEXT: double _t4 = std::exp(t);
//CHECK-NEXT: {
//CHECK-NEXT: double _r1 = 0;
//CHECK-NEXT: double _r2 = 0;
//CHECK-NEXT: double _r1 = 0.;
//CHECK-NEXT: double _r2 = 0.;
//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(2 * 3.1415926535897931, -dim / 2., 1 * _t4 * _t5, &_r1, &_r2);
//CHECK-NEXT: _d_dim += -_r2 / 2.;
//CHECK-NEXT: double _r3 = 0;
//CHECK-NEXT: double _r4 = 0;
//CHECK-NEXT: double _r3 = 0.;
//CHECK-NEXT: double _r4 = 0.;
//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(sigma, -0.5, _t6 * 1 * _t4, &_r3, &_r4);
//CHECK-NEXT: _d_sigma += _r3;
//CHECK-NEXT: double _r5 = 0;
//CHECK-NEXT: double _r5 = 0.;
//CHECK-NEXT: _r5 += _t6 * _t5 * 1 * clad::custom_derivatives::exp_pushforward(t, 1.).pushforward;
//CHECK-NEXT: _d_t += _r5;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: t = _t2;
//CHECK-NEXT: double _r_d1 = _d_t;
//CHECK-NEXT: _d_t = 0;
//CHECK-NEXT: _d_t = 0.;
//CHECK-NEXT: _d_t += -_r_d1 / _t3;
//CHECK-NEXT: double _r0 = _r_d1 * -(-t / (_t3 * _t3));
//CHECK-NEXT: _d_sigma += 2 * _r0 * sigma;
Expand Down
14 changes: 7 additions & 7 deletions test/ErrorEstimation/Assignments.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ float func(float x, float y) {
//CHECK-NEXT: {
//CHECK-NEXT: y = _t1;
//CHECK-NEXT: float _r_d1 = *_d_y;
//CHECK-NEXT: *_d_y = 0;
//CHECK-NEXT: *_d_y = 0.F;
//CHECK-NEXT: *_d_x += _r_d1;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: _final_error += std::abs(*_d_x * x * {{.+}});
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = *_d_x;
//CHECK-NEXT: *_d_x = 0;
//CHECK-NEXT: *_d_x = 0.F;
//CHECK-NEXT: *_d_x += _r_d0;
//CHECK-NEXT: *_d_y += _r_d0;
//CHECK-NEXT: }
Expand All @@ -49,7 +49,7 @@ float func2(float x, int y) {
//CHECK-NEXT: _final_error += std::abs(*_d_x * x * {{.+}});
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = *_d_x;
//CHECK-NEXT: *_d_x = 0;
//CHECK-NEXT: *_d_x = 0.F;
//CHECK-NEXT: *_d_y += _r_d0 * x;
//CHECK-NEXT: *_d_x += y * _r_d0;
//CHECK-NEXT: *_d_x += _r_d0 * x;
Expand Down Expand Up @@ -82,7 +82,7 @@ float func4(float x, float y) {
}

//CHECK: void func4_grad(float x, float y, float *_d_x, float *_d_y, double &_final_error) {
//CHECK-NEXT: double _d_z = 0;
//CHECK-NEXT: double _d_z = 0.;
//CHECK-NEXT: double z = y;
//CHECK-NEXT: float _t0 = x;
//CHECK-NEXT: x = z + y;
Expand All @@ -91,7 +91,7 @@ float func4(float x, float y) {
//CHECK-NEXT: _final_error += std::abs(*_d_x * x * {{.+}});
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = *_d_x;
//CHECK-NEXT: *_d_x = 0;
//CHECK-NEXT: *_d_x = 0.F;
//CHECK-NEXT: _d_z += _r_d0;
//CHECK-NEXT: *_d_y += _r_d0;
//CHECK-NEXT: }
Expand All @@ -116,7 +116,7 @@ float func5(float x, float y) {
//CHECK-NEXT: _final_error += std::abs(*_d_x * x * {{.+}});
//CHECK-NEXT: x = _t0;
//CHECK-NEXT: float _r_d0 = *_d_x;
//CHECK-NEXT: *_d_x = 0;
//CHECK-NEXT: *_d_x = 0.F;
//CHECK-NEXT: _d_z += _r_d0;
//CHECK-NEXT: *_d_y += _r_d0;
//CHECK-NEXT: }
Expand All @@ -134,7 +134,7 @@ float func6(float x) { return x; }
float func7(float x, float y) { return (x * y); }

//CHECK: void func7_grad(float x, float y, float *_d_x, float *_d_y, double &_final_error) {
//CHECK-NEXT: double _ret_value0 = 0;
//CHECK-NEXT: double _ret_value0 = 0.;
//CHECK-NEXT: _ret_value0 = (x * y);
//CHECK-NEXT: {
//CHECK-NEXT: *_d_x += 1 * y;
Expand Down
Loading
Loading