-
Notifications
You must be signed in to change notification settings - Fork 126
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 support for call expressions in vector forward mode AD #638
Conversation
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 19. Check the log or trigger a new build to see more.
d96c3d6
to
e04b101
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
e04b101
to
3c154c9
Compare
This change looks good overall. I would like to avoid diamond hierarchy if possible, but I am not sure if it would be. So many things can easily go wrong when diamon hierarchy is used. |
4beb275
to
3d0d5e0
Compare
Fixed the inheritance structure to remove the diamond problem, now, the structure is pretty simple:
The common code in both PushForwardMode modes is pushed into Closed by mistake, reopened. |
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
#include "VectorForwardModeVisitor.h" | ||
|
||
namespace clad { | ||
class VectorPushForwardModeVisitor : public VectorForwardModeVisitor { |
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: class 'VectorPushForwardModeVisitor' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class VectorPushForwardModeVisitor : public VectorForwardModeVisitor {
^
returnType, paramTypes, originalFnType->getExtProtoInfo()); | ||
llvm::SaveAndRestore<DeclContext*> saveContext(m_Sema.CurContext); | ||
llvm::SaveAndRestore<Scope*> saveScope(m_CurScope); | ||
auto* DC = const_cast<DeclContext*>(m_Function->getDeclContext()); |
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: do not use const_cast [cppcoreguidelines-pro-type-const-cast]
auto* DC = const_cast<DeclContext*>(m_Function->getDeclContext());
^
3d0d5e0
to
8ef4f4e
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
namespace clad { | ||
/// A visitor for processing the function code in forward mode. | ||
/// Used to compute derivatives by clad::differentiate. | ||
class PushForwardModeVisitor : public BaseForwardModeVisitor { |
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: class 'PushForwardModeVisitor' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class PushForwardModeVisitor : public BaseForwardModeVisitor {
^
28b48c6
to
1241f64
Compare
@vaithak, can you rebase this PR on top of master? |
1241f64
to
c0db619
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.
LGTM!
Two main changes in this PR:
ForwardModeVisitor
to a more apt namePushForwardModeVisitor
.VisitCallExpr
of BaseForwardModeVistor andthe PushForwardModeVisitor
class generic enough to add support for vector mode with very little code repetition,Also added appropriate tests for the new functionality.
Edited: Modified the inheritance diagram as per updated changes.