tvm
Classes | Namespaces | Enumerations | Functions
analysis.h File Reference

The set of Relax specific analysis on IR. More...

#include <tvm/arith/analyzer.h>
#include <tvm/ir/diagnostic.h>
#include <tvm/ir/module.h>
#include <tvm/relax/expr.h>
#include <tvm/relax/struct_info.h>
#include <tvm/relay/op_attr_types.h>
#include <tvm/tir/function.h>
#include <functional>
#include <utility>
Include dependency graph for analysis.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tvm::relax::VarUsageInfo
 A utility struct returned by CollectVarUsage. More...
 

Namespaces

 tvm
 runtime implementation for LibTorch/TorchScript.
 
 tvm::relax
 

Enumerations

enum class  tvm::relax::BaseCheckResult { tvm::relax::kFailL0 = 0 , tvm::relax::kFailL1 = 1 , tvm::relax::kFailL2 = 2 , tvm::relax::kPass = 3 }
 Fine grained result of base check. More...
 

Functions

bool tvm::relax::CanProveShapeEqual (const Array< PrimExpr > &lhs, const Array< PrimExpr > &rhs, arith::Analyzer *ana)
 Can prove the two symbolic shape arrays equals to each other. More...
 
bool tvm::relax::CanProveShapeEqual (const Expr &lhs, const Expr &rhs, arith::Analyzer *ana)
 Can prove the two symbolic shape expressions equals to each other. More...
 
Type tvm::relax::GetStaticType (const StructInfo &info)
 Get the corresponding static type from a given struct info. More...
 
StructInfo tvm::relax::StructInfoFromType (const Type &type)
 Get the corresponding struct info from static type. More...
 
StructInfo tvm::relax::DeriveCallRetStructInfo (const FuncStructInfo &finfo, const Call &call, const BlockBuilder &ctx, arith::Analyzer *ana=nullptr)
 
StructInfo tvm::relax::EraseToWellDefined (const StructInfo &info, std::function< Optional< PrimExpr >(const tir::Var &var)> f_shape_var_map=nullptr, std::function< Optional< Expr >(const Var &var)> f_var_map=nullptr, arith::Analyzer *ana=nullptr)
 Erase the info to a corresponding more coarse grained struct info that is still well-defined(with all the vars in scope). More...
 
StructInfo tvm::relax::EraseToWellDefined (const StructInfo &info, Map< tir::Var, PrimExpr > shape_var_map, Map< Var, Expr > var_map, arith::Analyzer *ana=nullptr)
 EraseToWellDefined variant with map. More...
 
BaseCheckResult tvm::relax::StructInfoBaseCheck (const StructInfo &base, const StructInfo &derived, arith::Analyzer *ana=nullptr)
 Run a base check to see if base subsumes derived. More...
 
bool tvm::relax::IsBaseOf (const StructInfo &base, const StructInfo &derived, arith::Analyzer *ana=nullptr)
 Check the relation of two struct info to see if one subsumes another one. More...
 
PrimExpr tvm::relax::StructInfoBaseCheckPrecondition (const StructInfo &base, const StructInfo &derived)
 Return the condition for which base is a superset of derived. More...
 
StructInfo tvm::relax::StructInfoLCA (const StructInfo &lhs, const StructInfo &rhs, arith::Analyzer *ana=nullptr)
 Unify the two struct info to their least common ancestor. More...
 
Array< tir::Var > tvm::relax::TIRVarsInStructInfo (const StructInfo &sinfo)
 Get the TIR variables that appear in the input struct info. The returned list is deduplicated - each TIR variable will appear at most once. More...
 
Array< tir::Var > tvm::relax::DefinableTIRVarsInStructInfo (const StructInfo &sinfo)
 Get the TIR variables that appear in the input struct info. More...
 
Array< PrimExpr > tvm::relax::CollectNonNegativeExpressions (const StructInfo &sinfo)
 Collect expressions whose usage requires them to be non-negative. More...
 
Array< tir::Var > tvm::relax::DefinedSymbolicVars (const Expr &expr)
 Get the TIR variables that defined in the input function. The returned list is deduplicated - each TIR variable will appear at most once. More...
 
Array< tir::Var > tvm::relax::FreeSymbolicVars (const Expr &expr)
 Get the TIR variables that are used but not defined in the input function. The returned list is deduplicated - each TIR variable will appear at most once. More...
 
tvm::Array< Var > tvm::relax::BoundVars (const Expr &expr)
 Get all bound variables from expression expr. More...
 
tvm::Array< Var > tvm::relax::FreeVars (const Expr &expr)
 Get free type parameters from expression expr. More...
 
tvm::Array< Var > tvm::relax::AllVars (const Expr &expr)
 Get all variables from expression expr. More...
 
tvm::Array< GlobalVartvm::relax::AllGlobalVars (const Expr &expr)
 Get all global variables from expression expr. More...
 
tvm::Array< tvm::Array< GlobalVar > > tvm::relax::DetectRecursion (const IRModule &m)
 Find all sets of recursive or mutually recursive functions in the module. More...
 
Map< Var, Expr > tvm::relax::AnalyzeVar2Value (const IRModule &m)
 Analyze var -> value mapping from VarBindings. More...
 
Map< Var, Expr > tvm::relax::AnalyzeVar2Value (const Expr &expr)
 Analyze var -> value mapping from VarBindings. More...
 
Map< Var, Expr > tvm::relax::AnalyzeVar2Value (const DataflowBlock &dfb)
 Analyze var -> value mapping from VarBindings. More...
 
Map< String, Array< Binding > > tvm::relax::NameToBinding (const Function &fn)
 Return a mapping from variable name to its Bindings. More...
 
Map< Var, Array< Var > > tvm::relax::DataflowBlockUseDef (const DataflowBlock &dfb)
 Get the use-def chain of variables inside a dataflow block. More...
 
std::pair< Map< Var, Array< Var > >, Array< Var > > tvm::relax::FunctionUseDef (const Expr &expr)
 Get the use-def chain of variables inside a function. More...
 
VarUsageInfo tvm::relax::CollectVarUsage (const Expr &expr)
 Collect variable bindings and usage. More...
 
Expr tvm::relax::RemoveAllUnused (Expr expr)
 Remove unused statements inside DataflowBlocks. More...
 
relay::OpPatternKind tvm::relax::AnalyzeOpPatternKind (const tir::PrimFunc &func)
 Annotate Op Pattern Kind for PrimFunc, which is used in relax FuseOps. More...
 
bool tvm::relax::HasReshapePattern (const tir::PrimFunc &func)
 Check if the given PrimFunc is essentially doing a reshape operation. The reshape operation also includes expand_dims, squeeze, flatten, etc. More...
 
Optional< Expr > tvm::relax::FindImpureCall (const Expr &expr, const Optional< Expr > &own_name=Optional< Expr >(nullptr))
 Check if the given expression (likely a function body) contains any impure calls. More...
 
bool tvm::relax::ContainsImpureCall (const Expr &expr, const Optional< Expr > &own_name=Optional< Expr >(nullptr))
 Check if the given expression (likely a function body) contains any impure calls. More...
 
bool tvm::relax::WellFormed (Variant< IRModule, Function > obj, bool check_struct_info=true)
 Check if the IRModule is well formed. More...
 
Map< tir::Block, Map< ObjectRef, tir::IndexMap > > tvm::relax::SuggestLayoutTransforms (const Function &fn, Array< tir::IndexMap > write_buffer_transformations)
 Using the layout transforms on the outputs, suggest layout transformation on the blocks and buffers for the PrimFunc. More...
 
Array< Var > tvm::relax::ComputableAtCompileTime (const Function &func)
 

Detailed Description

The set of Relax specific analysis on IR.