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

Revert skipping creation of local adjoints for const params and declare those as non-const #1134

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
if (m_DiffReq.Mode == DiffMode::jacobian &&
i == m_DiffReq->getNumParams() - 1)
continue;
auto VDDerivedType = param->getType();
if (VDDerivedType.isConstQualified())
continue;
auto VDDerivedType = getNonConstType(param->getType(), m_Context, m_Sema);
// We cannot initialize derived variable for pointer types because
// we do not know the correct size.
if (utils::isArrayOrPointerType(VDDerivedType))
Expand Down
6 changes: 5 additions & 1 deletion test/Gradient/Assignments.C
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,15 @@ double constVal(double y, const double x) {
}

//CHECK: void constVal_grad_0(double y, const double x, double *_d_y) {
//CHECK-NEXT: double _d_x = 0.;
//CHECK-NEXT: double _d_z = 0.;
//CHECK-NEXT: const double z = y;
//CHECK-NEXT: double _t0 = y;
//CHECK-NEXT: y *= z;
//CHECK-NEXT: *_d_y += 1 * x;
//CHECK-NEXT: {
//CHECK-NEXT: *_d_y += 1 * x;
//CHECK-NEXT: _d_x += y * 1;
//CHECK-NEXT: }
//CHECK-NEXT: {
//CHECK-NEXT: y = _t0;
//CHECK-NEXT: double _r_d0 = *_d_y;
Expand Down
Loading