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

Remove m_DerivativeForForwSweep from StmtDiff #1230

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

PetroZarytskyi
Copy link
Collaborator

Depends on #1228.
Currently, m_DerivativeForForwSweep is used to store adjoint to the reference to a given expression. e.g.

  1. for x, it stores _d_x
  2. for x[i], _d_x[i]

etc.

We only use m_DerivativeForForwSweep to initialize reference-type variables. However, to initialize pointers, we use getExpr_dx(). Pointers and references are equivalent and should be initialized the same way. When differentiating expressions, we initialize m_DerivativeForForwSweep either with the same value as Expr_dx or with nullptr.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.65%. Comparing base (d4d29d8) to head (ffa0102).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1230      +/-   ##
==========================================
- Coverage   94.65%   94.65%   -0.01%     
==========================================
  Files          51       51              
  Lines        8908     8901       -7     
==========================================
- Hits         8432     8425       -7     
  Misses        476      476              
Files with missing lines Coverage Δ
include/clad/Differentiator/VisitorBase.h 100.00% <100.00%> (ø)
lib/Differentiator/ReverseModeVisitor.cpp 95.62% <100.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
include/clad/Differentiator/VisitorBase.h 100.00% <100.00%> (ø)
lib/Differentiator/ReverseModeVisitor.cpp 95.62% <100.00%> (-0.01%) ⬇️

@vgvassilev
Copy link
Owner

Can you rebase?

Currently, ``m_DerivativeForForwSweep`` is used to store adjoint to the reference to a given expression. e.g.
1) for ``x``,  it stores ``_d_x``
2) for ``x[i]``, ``_d_x[i]``
etc.

We only use ``m_DerivativeForForwSweep`` to initialize reference-type variables. However, to initialize pointers, we use ``getExpr_dx()``. Pointers and references are equivalent and should be initialized the same way. When differentiating expressions, we initialize ``m_DerivativeForForwSweep`` either with the same value as ``Expr_dx`` or with ``nullptr``.
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

LGTM!

@vgvassilev vgvassilev merged commit 715f6d2 into vgvassilev:master Jan 23, 2025
94 checks passed
@PetroZarytskyi PetroZarytskyi deleted the remove-forw branch January 23, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants