Skip to content

Commit

Permalink
Revert skipping creation of local adjoints for const params and make …
Browse files Browse the repository at this point in the history
…those non-const
  • Loading branch information
kchristin22 authored and vgvassilev committed Nov 6, 2024
1 parent a50432f commit 9070023
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 9070023

Please sign in to comment.