24 #ifndef TVM_RELAX_ANALYSIS_H_
25 #define TVM_RELAX_ANALYSIS_H_
Algebra expression simplifications.
Managed reference class to IRModuleNode.
Definition: module.h:366
Reference to PrimExprNode.
Definition: expr.h:115
Managed reference to RelayExprNode.
Definition: expr.h:442
Managed reference to TypeNode.
Definition: type.h:93
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:629
Definition: block_builder.h:264
Managed reference to FuncStructInfoNode.
Definition: struct_info.h:362
Managed reference to StructInfoNode.
Definition: expr.h:129
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Managed reference to PrimFuncNode.
Definition: function.h:145
a named variable in TIR
Definition: var.h:89
A new diagnostic interface for TVM error reporting.
IRModule that holds the functions and type definitions.
BaseCheckResult
Fine grained result of base check.
Definition: analysis.h:192
@ kPass
LSet is superset of RSet.
@ kFailL2
WLSet is not superset of RSet because of mismatch in value information.
@ kFailL1
LSet is not superset of RSet by only looking at static information.
@ kFailL0
The two value sets have no intersection at all: Interset(LSet, RSet) = empty.
tvm::Array< Var > AllVars(const Expr &expr)
Get all variables from expression expr.
bool WellFormed(Variant< IRModule, Function > obj, bool check_struct_info=true)
Check if the IRModule is well formed.
BaseCheckResult StructInfoBaseCheck(const StructInfo &base, const StructInfo &derived, arith::Analyzer *ana=nullptr)
Run a base check to see if base subsumes derived.
StructInfo StructInfoLCA(const StructInfo &lhs, const StructInfo &rhs, arith::Analyzer *ana=nullptr)
Unify the two struct info to their least common ancestor.
Array< tir::Var > FreeSymbolicVars(const Expr &expr)
Get the TIR variables that are used but not defined in the input function. The returned list is dedup...
Array< tir::Var > TIRVarsInStructInfo(const StructInfo &sinfo)
Get the TIR variables that appear in the input struct info. The returned list is deduplicated - each ...
Expr RemoveAllUnused(Expr expr)
Remove unused statements inside DataflowBlocks.
Map< String, Array< Binding > > NameToBinding(const Function &fn)
Return a mapping from variable name to its Bindings.
tvm::Array< GlobalVar > AllGlobalVars(const Expr &expr)
Get all global variables from expression expr.
tvm::Array< tvm::Array< GlobalVar > > DetectRecursion(const IRModule &m)
Find all sets of recursive or mutually recursive functions in the module.
Map< tir::Block, Map< ObjectRef, tir::IndexMap > > 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 f...
bool 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.
std::pair< Map< Var, Array< Var > >, Array< Var > > FunctionUseDef(const Expr &expr)
Get the use-def chain of variables inside a function.
Type GetStaticType(const StructInfo &info)
Get the corresponding static type from a given struct info.
StructInfo StructInfoFromType(const Type &type)
Get the corresponding struct info from static type.
bool CanProveShapeEqual(const Array< PrimExpr > &lhs, const Array< PrimExpr > &rhs, arith::Analyzer *ana)
Can prove the two symbolic shape arrays equals to each other.
tvm::Array< Var > BoundVars(const Expr &expr)
Get all bound variables from expression expr.
bool HasReshapePattern(const tir::PrimFunc &func)
Check if the given PrimFunc is essentially doing a reshape operation. The reshape operation also incl...
Array< tir::Var > DefinedSymbolicVars(const Expr &expr)
Get the TIR variables that defined in the input function. The returned list is deduplicated - each TI...
tvm::Array< Var > FreeVars(const Expr &expr)
Get free type parameters from expression expr.
Array< PrimExpr > CollectNonNegativeExpressions(const StructInfo &sinfo)
Collect expressions whose usage requires them to be non-negative.
Array< tir::Var > DefinableTIRVarsInStructInfo(const StructInfo &sinfo)
Get the TIR variables that appear in the input struct info.
StructInfo DeriveCallRetStructInfo(const FuncStructInfo &finfo, const Call &call, const BlockBuilder &ctx, arith::Analyzer *ana=nullptr)
Optional< Expr > 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.
bool 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.
Array< Var > ComputableAtCompileTime(const Function &func)
StructInfo 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...
relay::OpPatternKind AnalyzeOpPatternKind(const tir::PrimFunc &func)
Annotate Op Pattern Kind for PrimFunc, which is used in relax FuseOps.
Map< Var, Array< Var > > DataflowBlockUseDef(const DataflowBlock &dfb)
Get the use-def chain of variables inside a dataflow block.
PrimExpr StructInfoBaseCheckPrecondition(const StructInfo &base, const StructInfo &derived)
Return the condition for which base is a superset of derived.
Map< Var, Expr > AnalyzeVar2Value(const IRModule &m)
Analyze var -> value mapping from VarBindings.
VarUsageInfo CollectVarUsage(const Expr &expr)
Collect variable bindings and usage.
OpPatternKind
operator pattern used in graph fusion
Definition: op_attr_types.h:45
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
The Expr and related elements in DataFlow construction.
A utility struct returned by CollectVarUsage.
Definition: analysis.h:463
Map< Var, Expr > bound_values
Definition: analysis.h:468
Array< Var > outputs
Definition: analysis.h:480
Map< Var, Array< Var > > downstream_usage
Definition: analysis.h:474