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 gradient computation of higher order functions #645

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

vaithak
Copy link
Collaborator

@vaithak vaithak commented Oct 24, 2023

fixes #637

@vgvassilev vgvassilev requested a review from parth-07 October 24, 2023 21:01
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 Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Merging #645 (72a3890) into master (ac300de) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #645   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files          43       43           
  Lines        6295     6300    +5     
=======================================
+ Hits         5925     5930    +5     
  Misses        370      370           
Files Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.89% <100.00%> (+0.01%) ⬆️
Files Coverage Δ
lib/Differentiator/ReverseModeVisitor.cpp 95.89% <100.00%> (+0.01%) ⬆️

@vaithak
Copy link
Collaborator Author

vaithak commented Oct 24, 2023

The change seems to be failing with clang-16. I will update the clang locally to test the error as currently I have version 15 installed.
Works now 👍🏼

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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

addToCurrentBlock(add_assign, direction::reverse);
// FIXME: not sure if this is generic.
// Don't update derivatives of non-record types.
if (!decl->getType()->isRecordType()) {
Copy link
Owner

Choose a reason for hiding this comment

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

Can we check this with isa<RecordDecl>(decl)?

Copy link
Collaborator Author

@vaithak vaithak Oct 25, 2023

Choose a reason for hiding this comment

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

I had that earlier but it failed with clang-16. isRecordType does the same thing inside it, but performs the operation on the CanonicalType instead of the qualified type.
source code of isRecordType.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, ok. That means that if we did isa<RecordDecl>(decl->getCanonicalDecl()) would work?

Copy link
Collaborator Author

@vaithak vaithak Oct 25, 2023

Choose a reason for hiding this comment

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

Yup, that works. I saw isRecordType being used at different places in our codebase, so I used that.
Should I change this to use isa<RecordDecl>? Any reason to prefer that?

Copy link
Owner

Choose a reason for hiding this comment

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

Nope, let's use your current solution if it is used elsewhere.

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 1ae1f75 into vgvassilev:master Oct 25, 2023
77 checks passed
@vaithak vaithak deleted the high-order-fxn 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.

Feature request: Support for higher order functions
2 participants