Sleipnir C++ API
Loading...
Searching...
No Matches
slp::detail::AdjointExpressionGraph Class Reference

#include <sleipnir/autodiff/adjoint_expression_graph.hpp>

Public Member Functions

 AdjointExpressionGraph (const Variable &root)
 
void update_values ()
 
VariableMatrix generate_gradient_tree (const VariableMatrix &wrt) const
 
void append_adjoint_triplets (small_vector< Eigen::Triplet< double > > &triplets, int row, const VariableMatrix &wrt) const
 

Detailed Description

This class is an adaptor type that performs value updates of an expression's adjoint graph.

Constructor & Destructor Documentation

◆ AdjointExpressionGraph()

slp::detail::AdjointExpressionGraph::AdjointExpressionGraph ( const Variable root)
inlineexplicit

Generates the adjoint graph for the given expression.

Parameters
rootThe root node of the expression.

Member Function Documentation

◆ append_adjoint_triplets()

void slp::detail::AdjointExpressionGraph::append_adjoint_triplets ( small_vector< Eigen::Triplet< double > > &  triplets,
int  row,
const VariableMatrix wrt 
) const
inline

Updates the adjoints in the expression graph (computes the gradient) then appends the adjoints of wrt to the sparse matrix triplets.

Parameters
tripletsThe sparse matrix triplets.
rowThe row of wrt.
wrtVector of variables with respect to which to compute the Jacobian.

◆ generate_gradient_tree()

VariableMatrix slp::detail::AdjointExpressionGraph::generate_gradient_tree ( const VariableMatrix wrt) const
inline

Returns the variable's gradient tree.

This function lazily allocates variables, so elements of the returned VariableMatrix will be empty if the corresponding element of wrt had no adjoint. Ensure Variable::expr isn't nullptr before calling member functions.

Parameters
wrtVariables with respect to which to compute the gradient.
Returns
The variable's gradient tree.

◆ update_values()

void slp::detail::AdjointExpressionGraph::update_values ( )
inline

Update the values of all nodes in this adjoint graph based on the values of their dependent nodes.


The documentation for this class was generated from the following file: