TVM  0.9.4
tvm::diagnostic::GraphProbe Class Reference

#include <tvm/diagnostic/GraphProbe.h>

Classes

struct  ProbeNode
 

Public Types

using Output = graph::internal::Log::Output
 
using Update = graph::internal::Log::Update
 
using OutputVal = std::tuple< Output, VariablePtr, Eigen::MatrixXd >
 

Public Member Functions

 GraphProbe (const graph::internal::Log &log=tvm::graph::internal::Logger::logger().log())
 
template<typename T , typename MethodT , typename EnumOutput , typename ConvertT = std::nullopt_t>
void registerAccessor (EnumOutput o, MethodT method, ConvertT convert=std::nullopt)
 
template<typename T >
void registerTVMFunction ()
 
template<typename T >
void registerTVMConstraint ()
 
template<typename T >
void registerTVMTaskDynamics ()
 
std::vector< OutputVallistOutputVal (const graph::CallGraph *const g, bool verbose=false) const
 
std::vector< OutputVallistOutputVal (const Output &o, bool verbose=false) const
 
std::unique_ptr< ProbeNodefollowUp (const Output &o, const std::function< bool(const Eigen::MatrixXd &)> &select=[](const Eigen::MatrixXd &) { return true;}) const
 
std::vector< std::unique_ptr< ProbeNode > > followUp (const graph::CallGraph *const g, const std::function< bool(const Eigen::MatrixXd &)> &select=[](const Eigen::MatrixXd &) { return true;}) const
 
void print (std::ostream &os, const std::unique_ptr< ProbeNode > &root) const
 
void print (std::ostream &os, const std::vector< std::unique_ptr< ProbeNode >> &roots) const
 

Static Public Attributes

static constexpr auto absInRange
 
static constexpr auto hasNan = [](const Eigen::MatrixXd & M) { return M.hasNaN(); }
 

Detailed Description

A class to explore the value computed in a call graph.

Because the tvm nodes only declare the dependencies between inputs, updates and outputs, but not the way to retrieve an output, it is necessary to register first the method used to access each output of interest. This is done atomically with the methods GraphNode::registerAccessor, or at higher level with the methods GraphNode::registerTVMFunction, GraphNode::registerTVMConstraint and GraphNode::registerTVMTaskDynamics. Access methods for base tvm classes are automatically registered in the constructor.

Member Typedef Documentation

◆ Output

◆ OutputVal

using tvm::diagnostic::GraphProbe::OutputVal = std::tuple<Output, VariablePtr, Eigen::MatrixXd>

◆ Update

Constructor & Destructor Documentation

◆ GraphProbe()

tvm::diagnostic::GraphProbe::GraphProbe ( const graph::internal::Log log = tvm::graph::internal::Logger::logger().log())

Constructor

Member Function Documentation

◆ followUp() [1/2]

std::vector<std::unique_ptr<ProbeNode> > tvm::diagnostic::GraphProbe::followUp ( const graph::CallGraph *const  g,
const std::function< bool(const Eigen::MatrixXd &)> &  select = [](const Eigen::MatrixXd &) { return true;} 
) const

Follow up backward the computation graph starting at the inputs of g, and trimming out branches where the value of an output does not pass the test given by select.

◆ followUp() [2/2]

std::unique_ptr<ProbeNode> tvm::diagnostic::GraphProbe::followUp ( const Output o,
const std::function< bool(const Eigen::MatrixXd &)> &  select = [](const Eigen::MatrixXd &) { return true;} 
) const

Follow up backward the computation graph starting at node o, and trimming out branches where the value of an output does not pass the test given by select.

◆ listOutputVal() [1/2]

std::vector<OutputVal> tvm::diagnostic::GraphProbe::listOutputVal ( const graph::CallGraph *const  g,
bool  verbose = false 
) const

List all the values of all the outputs present in the call graph g (if the associated methods were registered).

If verbose is true, display the outputs for which no methods were registered to retrieve their values.

◆ listOutputVal() [2/2]

std::vector<OutputVal> tvm::diagnostic::GraphProbe::listOutputVal ( const Output o,
bool  verbose = false 
) const

List all the values of all the outputs on which o depends (recursively) (if the associated methods were registered).

If verbose is true, display the outputs for which no methods were registered to retrieve their values.

◆ print() [1/2]

void tvm::diagnostic::GraphProbe::print ( std::ostream &  os,
const std::unique_ptr< ProbeNode > &  root 
) const

Print in os the tree starting at root.

◆ print() [2/2]

void tvm::diagnostic::GraphProbe::print ( std::ostream &  os,
const std::vector< std::unique_ptr< ProbeNode >> &  roots 
) const

Print in os the trees starting each at an element of root.

◆ registerAccessor()

template<typename T , typename MethodT , typename EnumOutput , typename ConvertT >
void tvm::diagnostic::GraphProbe::registerAccessor ( EnumOutput  o,
MethodT  method,
ConvertT  convert = std::nullopt 
)
inline

Register a method fn to retrieve the value associated to o

The method either takes a variable or does not

Template Parameters
Ttype of the node to which the method is attached. It must be given explicitly if the method is inherited from a base class, otherwise the method will be registered for this base class.

◆ registerTVMConstraint()

template<typename T >
void tvm::diagnostic::GraphProbe::registerTVMConstraint
inline

Register all methods associated to outputs inherited from tvm::constraint::abstract::Constraint

◆ registerTVMFunction()

template<typename T >
void tvm::diagnostic::GraphProbe::registerTVMFunction
inline

Register all methods associated to outputs inherited from tvm::function::abstract::Function

◆ registerTVMTaskDynamics()

template<typename T >
void tvm::diagnostic::GraphProbe::registerTVMTaskDynamics
inline

Register all methods associated to outputs inherited from tvm::task_dynamics::abstract::TaskDynamicsImpl

Member Data Documentation

◆ absInRange

constexpr auto tvm::diagnostic::GraphProbe::absInRange
staticconstexpr
Initial value:
= [](double rmin, double rmax) {
return [rmin, rmax](const Eigen::MatrixXd & M) { return hasElemAbsInRange(M, rmin, rmax); };
}
bool hasElemAbsInRange(const Eigen::MatrixBase< Derived > &A, typename Derived::Scalar emin, typename Derived::Scalar emax)
Definition: matrix.h:53

Factory returning a function checking if a matrix M has elements whose absolute value is between rmin and rmax.

This function can be used as a select function in GraphProbe::followUp.

◆ hasNan

constexpr auto tvm::diagnostic::GraphProbe::hasNan = [](const Eigen::MatrixXd & M) { return M.hasNaN(); }
staticconstexpr

Function checking if M contains NaN.

This function can be used as a select function in GraphProbe::followUp.


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