WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
sleipnir::detail::ExpressionGraph Class Reference

This class is an adaptor type that performs value updates of an expression's computational graph in a way that skips duplicates. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/ExpressionGraph.hpp>

Public Member Functions

 ExpressionGraph (ExpressionPtr &root)
 Generates the deduplicated computational graph for the given expression.
 
void Update ()
 Update the values of all nodes in this computational tree based on the values of their dependent nodes.
 
wpi::SmallVector< ExpressionPtrGenerateGradientTree (std::span< const ExpressionPtr > wrt) const
 Returns the variable's gradient tree.
 
void ComputeAdjoints (function_ref< void(int row, double adjoint)> func)
 Updates the adjoints in the expression graph, effectively computing the gradient.
 

Detailed Description

This class is an adaptor type that performs value updates of an expression's computational graph in a way that skips duplicates.

Constructor & Destructor Documentation

◆ ExpressionGraph()

sleipnir::detail::ExpressionGraph::ExpressionGraph ( ExpressionPtr & root)
inlineexplicit

Generates the deduplicated computational graph for the given expression.

Parameters
rootThe root node of the expression.

Member Function Documentation

◆ ComputeAdjoints()

void sleipnir::detail::ExpressionGraph::ComputeAdjoints ( function_ref< void(int row, double adjoint)> func)
inline

Updates the adjoints in the expression graph, effectively computing the gradient.

Parameters
funcA function that takes two arguments: an int for the gradient row, and a double for the adjoint (gradient value).

◆ GenerateGradientTree()

wpi::SmallVector< ExpressionPtr > sleipnir::detail::ExpressionGraph::GenerateGradientTree ( std::span< const ExpressionPtr > wrt) const
inline

Returns the variable's gradient tree.

Parameters
wrtVariables with respect to which to compute the gradient.

◆ Update()

void sleipnir::detail::ExpressionGraph::Update ( )
inline

Update the values of all nodes in this computational tree based on the values of their dependent nodes.


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