-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for diff of ref return types in rev mode
- Loading branch information
Showing
11 changed files
with
544 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ enum class DiffMode { | |
reverse, | ||
hessian, | ||
jacobian, | ||
reverse_mode_forward_pass, | ||
error_estimation | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef CLAD_DIFFERENTIATOR_REVERSEMODEFORWPASSVISITOR_H | ||
#define CLAD_DIFFERENTIATOR_REVERSEMODEFORWPASSVISITOR_H | ||
|
||
#include "clad/Differentiator/ParseDiffArgsTypes.h" | ||
#include "clad/Differentiator/ReverseModeVisitor.h" | ||
|
||
#include "clang/AST/StmtVisitor.h" | ||
#include "clang/Sema/Sema.h" | ||
|
||
#include "llvm/ADT/SmallVector.h" | ||
|
||
namespace clad { | ||
class ReverseModeForwPassVisitor : public ReverseModeVisitor { | ||
private: | ||
Stmts m_Globals; | ||
|
||
llvm::SmallVector<clang::QualType, 8> | ||
ComputeParamTypes(const DiffParams& diffParams); | ||
clang::QualType ComputeReturnType(); | ||
llvm::SmallVector<clang::ParmVarDecl*, 8> BuildParams(DiffParams& diffParams); | ||
clang::QualType GetParameterDerivativeType(clang::QualType yType, | ||
clang::QualType xType); | ||
|
||
public: | ||
ReverseModeForwPassVisitor(DerivativeBuilder& builder); | ||
DerivativeAndOverload Derive(const clang::FunctionDecl* FD, | ||
const DiffRequest& request); | ||
|
||
StmtDiff ProcessSingleStmt(const clang::Stmt* S); | ||
|
||
StmtDiff VisitStmt(const clang::Stmt* S) override; | ||
StmtDiff VisitCompoundStmt(const clang::CompoundStmt* CS) override; | ||
StmtDiff VisitDeclRefExpr(const clang::DeclRefExpr* DRE) override; | ||
StmtDiff VisitReturnStmt(const clang::ReturnStmt* RS) override; | ||
}; | ||
} // namespace clad | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.