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

Fix call expr to functor inside a function #626

Merged
merged 1 commit into from
Sep 17, 2023

Conversation

vaithak
Copy link
Collaborator

@vaithak vaithak commented Sep 13, 2023

This fixes #625 for the case when a functor is indirectly differentiated because of a call expression inside a function.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

lib/Differentiator/ReverseModeVisitor.cpp Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
lib/Differentiator/ReverseModeVisitor.cpp Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #626 (9286fdc) into master (59fd672) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #626      +/-   ##
==========================================
+ Coverage   94.03%   94.04%   +0.01%     
==========================================
  Files          43       43              
  Lines        6218     6230      +12     
==========================================
+ Hits         5847     5859      +12     
  Misses        371      371              
Files Changed Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.76% <100.00%> (+0.02%) ⬆️
Files Changed Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.76% <100.00%> (+0.02%) ⬆️

@vgvassilev vgvassilev requested a review from parth-07 September 13, 2023 12:18
@github-actions
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 71dd694 into vgvassilev:master Sep 17, 2023
77 checks passed
@@ -1412,12 +1413,20 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
// statements there later.
std::size_t insertionPoint = getCurrentBlock(direction::reverse).size();

// `CXXOperatorCallExpr` have the `base` expression as the first argument.
size_t skipFirstArg = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Apologies for the late review.

What is the main issue if we do not skip the first arg? I suppose it might be required if we modify the functor's member variables in the call operator.

Copy link
Collaborator Author

@vaithak vaithak Sep 18, 2023

Choose a reason for hiding this comment

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

The first arg in the operator call is the base expression which is not needed in calling the pullback function, I used the logic of skipping the first arg from this in forward mode: https://github.com/vgvassilev/clad/blob/master/lib/Differentiator/BaseForwardModeVisitor.cpp#L980

@vaithak vaithak deleted the functor-fix branch March 13, 2024 13:22
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.

Failure in differentiating call expression to a function object
3 participants