-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add Varied analysis to the reverse mode #1084
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1084 +/- ##
==========================================
+ Coverage 94.25% 94.34% +0.08%
==========================================
Files 55 50 -5
Lines 8445 8326 -119
==========================================
- Hits 7960 7855 -105
+ Misses 485 471 -14
... and 37 files with indirect coverage changes
|
There was a problem hiding this 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
There were too many comments to post at once. Showing the first 10 out of 29. Check the log or trigger a new build to see more.
There was a problem hiding this 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
There were too many comments to post at once. Showing the first 10 out of 16. Check the log or trigger a new build to see more.
There was a problem hiding this 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
There were too many comments to post at once. Showing the first 10 out of 18. Check the log or trigger a new build to see more.
There was a problem hiding this 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
65075a3
to
df82648
Compare
There was a problem hiding this 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
f5236aa
to
c2ca79b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a partial review. Please address the clang-tidy complaints as most of them are good. I'd also rely on @PetroZarytskyi here for a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work. I didn't mention pullbacks and call exprs because we already made huge progress there yesterday. Overall, the PR looks awesome. Its simplicity makes me feel that TBR was overcomplicated. I think we made the right decision to start with a simplified implementation.
There was a problem hiding this 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
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the resolved conversations as some are not really resolved by adding the requested change.
There was a problem hiding this 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
There was a problem hiding this 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
There were too many comments to post at once. Showing the first 10 out of 26. Check the log or trigger a new build to see more.
There was a problem hiding this 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
|
||
bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) { | ||
for (Decl* D : DS->decls()) { | ||
if (!isa<VarDecl>(D)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test here could be class C{} c;
that produces a DeclStmt whose Stmt is not a VarDecl.
There was a problem hiding this 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
test/Gradient/FunctionCalls.C
Outdated
@@ -441,14 +441,14 @@ double do_nothing(double* u, double* v, double* w) { | |||
return u[0]; | |||
} | |||
|
|||
// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v, double *_d_w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change was needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to remove non varied parameters from the adjoint, but it'd crash cms example, so I removed it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I follow, Does not that change the pullback signatures randomly? @PetroZarytskyi.
bool m_Varied = false; | ||
bool m_Marking = false; | ||
|
||
std::set<const clang::VarDecl*>& m_VariedDecls; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::set<const clang::VarDecl*>& m_VariedDecls; | |
VarsData& m_VariedDecls; |
There was a problem hiding this 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
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are almost there. Please add tests on the missing branches.
test/Gradient/FunctionCalls.C
Outdated
@@ -441,14 +441,14 @@ double do_nothing(double* u, double* v, double* w) { | |||
return u[0]; | |||
} | |||
|
|||
// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v, double *_d_w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I follow, Does not that change the pullback signatures randomly? @PetroZarytskyi.
|
||
bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) { | ||
for (Decl* D : DS->decls()) { | ||
if (Expr* init = cast<VarDecl>(D)->getInit()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we will crash if D
is not a VarDecl
.
47ec589
to
03255f3
Compare
There was a problem hiding this 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
enable_va_in_req = | ||
clad::HasOption(bitmasked_opts_value, clad::opts::enable_va); | ||
disable_va_in_req = | ||
clad::HasOption(bitmasked_opts_value, clad::opts::disable_va); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no member named 'disable_va' in 'clad::opts'; did you mean 'disable_aa'? [clang-diagnostic-error]
clad::HasOption(bitmasked_opts_value, clad::opts::disable_va); | |
clad::HasOption(bitmasked_opts_value, clad::opts::disable_aa); |
Additional context
include/clad/Differentiator/CladConfig.h:32: 'disable_aa' declared here
disable_aa = 1 << (ORDER_BITS + 6),
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds Varied analysis support in the reverse mode, fixes wrong jacobian results and updates tests.