|
tvm
|
namespace of symbolic analysis. More...
Classes | |
| class | Analyzer |
| Managed reference to AnalyzerObj. More... | |
| class | AnalyzerObj |
| Analyzer that contains bunch of sub-analyzers. More... | |
| class | CanonicalSimplifier |
| Canonical-form based simplifier. More... | |
| class | ConstIntBound |
| reference class to ConstIntBoundObj More... | |
| class | ConstIntBoundAnalyzer |
| Analyzer to get constant integer bound over expression. More... | |
| class | ConstIntBoundObj |
| Constant integer up and lower bound(inclusive). Useful for value bound analysis. More... | |
| class | ConstraintContext |
| Constraint context. More... | |
| class | IntSet |
| Managed reference to IntSetObj. More... | |
| class | IntSetAnalyzer |
| Integer set analyzer. More... | |
| class | IntSetObj |
| Base class of all Integer set containers. represent a set of integers in one dimension. More... | |
| class | IterMapExpr |
| Managed reference to IterMapExprNode. More... | |
| class | IterMapExprNode |
| Base class of all iter map expressions. More... | |
| class | IterMapResult |
| Managed reference to IterMapResultObj. More... | |
| class | IterMapResultObj |
| Result of DetectIterMap. More... | |
| class | IterMark |
| Managed reference to IterMarkExprNode. More... | |
| class | IterMarkNode |
| Mark the source as an iterator in [0, extent). More... | |
| class | IterSplitExpr |
| Managed reference to IterSplitExprNode. More... | |
| class | IterSplitExprNode |
| Split of an iterator. More... | |
| class | IterSumExpr |
| Managed reference to IterSumExprNode. More... | |
| class | IterSumExprNode |
| Fuse multiple iterators by summing them with scaling. More... | |
| class | ModularSet |
| reference of ModularSetObj More... | |
| class | ModularSetAnalyzer |
| Analyzer to get modular information over expression. More... | |
| class | ModularSetObj |
| Range of a linear integer function. Use to do specify the possible index values. More... | |
| class | RewriteSimplifier |
| Rewrite-rule based simplifier. More... | |
| class | TransitiveComparisonAnalyzer |
| Using previously specified knowns, compare the expressions provided. More... | |
| class | Z3Prover |
Typedefs | |
| using | ExprIntSetMap = std::unordered_map< PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > |
| Map from Expr to IntSet. | |
Enumerations | |
| enum | DivMode { kTruncDiv , kFloorDiv } |
| enum class | ProofStrength : int { kDefault = 0 , kSymbolicBound = 1 } |
| The strength used in top-level condition proves. More... | |
| enum class | CompareResult : int { kInconsistent = 0 , kEQ = 1 , kLT = 2 , kLE = 3 , kGT = 4 , kGE = 5 , kNE = 6 , kUnknown = 7 } |
| Structure for representing result of known. More... | |
| enum | SignType { kPositive , kNegative , kZero , kUnknown } |
| Sign type of an integer expression. More... | |
| enum | IterMapLevel { Bijective = 0 , Surjective = 1 , NoCheck = 3 } |
| Mapping level for iterators. More... | |
Functions | |
| constexpr CompareResult | operator& (CompareResult lhs, CompareResult rhs) |
| constexpr CompareResult | operator| (CompareResult lhs, CompareResult rhs) |
| IntSet | DeduceBound (PrimExpr v, PrimExpr cond, const ffi::Map< Var, IntSet > &hint_map, const ffi::Map< Var, IntSet > &relax_map) |
| Deduce the bound of the target variable in a expression, give the domain of each variables. Return undefined IntSet to represent failure. | |
| IntSet | DeduceBound (PrimExpr v, PrimExpr cond, const std::unordered_map< const VarNode *, IntSet > &hint_map, const std::unordered_map< const VarNode *, IntSet > &relax_map) |
| Same as DeduceBound with unordered_map signature. | |
| ffi::Map< Var, IntSet > | ConvertDomMap (const std::unordered_map< const VarNode *, IntSet > &dom_map) |
| Convert std::unordered_map<const VarNode*, IntSet> to ffi::Map<Var, IntSet> | |
| IntSet | EvalSet (PrimExpr e, const ffi::Map< Var, IntSet > &dom_map) |
| Find an symbolic integer set that contains all possible values of e given the domain of each variables. | |
| IntSet | EvalSet (PrimExpr e, const std::unordered_map< const VarNode *, IntSet > &dom_map) |
| Same as EvalSet, but takes unordered_map. | |
| IntSet | EvalSet (IntSet s, const std::unordered_map< const VarNode *, IntSet > &dom_map) |
| Find an symbolic integer set that contains is union over all the possible conditional values in dom_map. | |
| IntSet | EvalSet (Range r, const std::unordered_map< const VarNode *, IntSet > &dom_map) |
| Same as EvalSet, but takes unordered_map. | |
| ffi::Array< IntSet > | EvalSet (const ffi::Array< Range > ®ion, const ffi::Map< Var, IntSet > &dom_map) |
| Same as EvalSet, but takes ffi::Array<Range> | |
| ExprIntSetMap | EvalSetForEachSubExpr (PrimExpr e, const std::unordered_map< const VarNode *, IntSet > &dom_map) |
| Find the integer set of every sub-expression, given the domain of each iteration variables. | |
| IntSet | Union (const ffi::Array< IntSet > &sets) |
| Create a union set of all sets, possibly relaxed. | |
| ffi::Array< IntSet > | UnionRegion (const ffi::Array< ffi::Array< IntSet > > &nd_int_sets) |
| The union of N-dimensional integer sets. | |
| IntSet | UnionLowerBound (const ffi::Array< IntSet > &sets) |
| Create a lower-bound of union set, where some of the segments may be dropped. | |
| ffi::Array< IntSet > | UnionRegionLowerBound (const ffi::Array< ffi::Array< IntSet > > &nd_int_sets) |
| The union of N-dimensional integer sets. | |
| IntSet | Intersect (const ffi::Array< IntSet > &sets) |
| Create an intersected set of all sets. | |
| TVM_TIRX_DLL IntSet | Intersect (const IntSet &lhs, const IntSet &rhs, const Analyzer &analyzer) |
| Intersect two integer sets using the analyzer's bindings and constraints. | |
| ffi::Map< Var, sym::IntSet > | AsIntSet (const ffi::Map< Var, Range > &var_dom) |
| Converts the Ranges to IntSets. | |
| TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > | EstimateRegionStrictBound (const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer) |
| Analyze the region with affine map, given the domain of variables and their predicate. The result should be strict, i.e. no region is discarded or relaxed. | |
| TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > | EstimateRegionLowerBound (const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer) |
| Analyze the region with affine map, given the domain of variables and their predicate. Some subregion may be discarded during the lower-bound analysis. | |
| TVM_TIRX_DLL ffi::Array< IntSet > | EstimateRegionUpperBound (const ffi::Array< Range > ®ion, const ffi::Map< Var, Range > &var_dom, const PrimExpr &predicate, const sym::Analyzer &analyzer) |
| Analyze the region with affine map, given the domain of variables and their predicate Relaxation of the region may be used in upper-bound analysis, i.e. some extra region may be added to the result. | |
| IterMapResult | DetectIterMap (const ffi::Array< PrimExpr > &indices, const ffi::Map< PrimVar, Range > &input_iters, const PrimExpr &predicate, IterMapLevel check_level, const sym::Analyzer &analyzer, bool simplify_trivial_iterators=true) |
| Detect if indices can be written as [y_0 + c_0, y_1 + c_1, ..., y_n + c_n]. | |
| ffi::Array< PrimExpr > | IterMapSimplify (const ffi::Array< PrimExpr > &indices, const ffi::Map< PrimVar, Range > &input_iters, const PrimExpr &input_pred, IterMapLevel check_level, const sym::Analyzer &analyzer, bool simplify_trivial_iterators=true) |
| Use IterVarMap detector to rewrite and simplify the indices. | |
| ffi::Map< Var, PrimExpr > | InverseAffineIterMap (const ffi::Array< IterSumExpr > &iter_map, const ffi::Array< PrimExpr > outputs) |
| Apply the inverse of the affine transformation to the outputs. | |
| ffi::Array< ffi::Array< IterMark > > | SubspaceDivide (const ffi::Array< PrimExpr > &bindings, const ffi::Map< PrimVar, Range > &input_iters, const ffi::Array< PrimVar > &sub_iters, const PrimExpr &predicate, IterMapLevel check_level, const sym::Analyzer &analyzer, bool simplify_trivial_iterators=true) |
| Detect if bindings can be written as [a_0*e_0 + b_0 + c_0, a_1*e_1 + b_1, ..., a_n*e_n + b_n]. | |
| PrimExpr | NormalizeIterMapToExpr (const PrimExpr &expr) |
| Given an expression that may contain IterMapExpr, transform it to normal PrimExpr. | |
| IterSumExpr | NormalizeToIterSum (PrimExpr index, const ffi::Map< PrimVar, Range > &input_iters, const sym::Analyzer &analyzer) |
| Rewrite index as IterSumExpr. | |
| ffi::Array< PrimExpr > | DetectLinearEquation (const PrimExpr &e, const ffi::Array< PrimVar > &vars) |
| Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n] Where coeff[i] and base are invariant of var[j] for all i and j. | |
| ffi::Array< ffi::Optional< PrimExpr > > | DetectClipBound (const PrimExpr &e, const ffi::Array< PrimVar > &vars) |
| Detect if expression corresponds to clip bound of the vars. | |
namespace of symbolic analysis.
| using tvm::sym::ExprIntSetMap = typedef std::unordered_map<PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual> |
|
strong |
| enum tvm::sym::DivMode |
|
strong |
The strength used in top-level condition proves.
Do not use level beyond kDefault in internal recursive rewriting in sym analysis and only use it at top-level simplification to avoid speed issues.
| Enumerator | |
|---|---|
| kDefault | default strength, can be used in. |
| kSymbolicBound | Prove using symbolic bound analysis. |
| enum tvm::sym::SignType |
| ffi::Map< Var, sym::IntSet > tvm::sym::AsIntSet | ( | const ffi::Map< Var, Range > & | var_dom | ) |
Converts the Ranges to IntSets.
| var_dom | The ranges of variables |
| ffi::Map< Var, IntSet > tvm::sym::ConvertDomMap | ( | const std::unordered_map< const VarNode *, IntSet > & | dom_map | ) |
Convert std::unordered_map<const VarNode*, IntSet> to ffi::Map<Var, IntSet>
| dom_map | The domain map to convert. |
| IntSet tvm::sym::DeduceBound | ( | PrimExpr | v, |
| PrimExpr | cond, | ||
| const ffi::Map< Var, IntSet > & | hint_map, | ||
| const ffi::Map< Var, IntSet > & | relax_map | ||
| ) |
Deduce the bound of the target variable in a expression, give the domain of each variables. Return undefined IntSet to represent failure.
| v | The target variable to be deduced. |
| cond | The conditional expression. |
| hint_map | The domain of variable, used to help deduce. |
| relax_map | The domain of each variable, used to relax the domain, The deduce bound must implies e for all value in relax_map |
| IntSet tvm::sym::DeduceBound | ( | PrimExpr | v, |
| PrimExpr | cond, | ||
| const std::unordered_map< const VarNode *, IntSet > & | hint_map, | ||
| const std::unordered_map< const VarNode *, IntSet > & | relax_map | ||
| ) |
Same as DeduceBound with unordered_map signature.
| v | The target variable to be deduced. |
| cond | The conditional expression. |
| hint_map | The domain of variable, used to help deduce. |
| relax_map | The domain of each variable, used to relax the domain, The deduce bound mush implies e for all value in relax_map |
| ffi::Array< ffi::Optional< PrimExpr > > tvm::sym::DetectClipBound | ( | const PrimExpr & | e, |
| const ffi::Array< PrimVar > & | vars | ||
| ) |
Detect if expression corresponds to clip bound of the vars.
| e | The expression to be detected. |
| vars | List of variables to be used in detection. |
| IterMapResult tvm::sym::DetectIterMap | ( | const ffi::Array< PrimExpr > & | indices, |
| const ffi::Map< PrimVar, Range > & | input_iters, | ||
| const PrimExpr & | predicate, | ||
| IterMapLevel | check_level, | ||
| const sym::Analyzer & | analyzer, | ||
| bool | simplify_trivial_iterators = true |
||
| ) |
Detect if indices can be written as [y_0 + c_0, y_1 + c_1, ..., y_n + c_n].
Here y = some-quasi-affine-iter-map(input_iters) and c are symbolic constants.
We also requires that y_i and y_j to be independent for i != j.
For returned value rv, the following is always true:
| indices | The indices to detect pattern for. |
| input_iters | Map from variable to iterator's range. |
| predicate | The predicate constraints on the input iterators |
| check_level | The iter mapping checking level. |
| analyzer | Analyzer used to get context information. |
| simplify_trivial_iterators | If true, iterators with extent of 1 will be replaced with a constant value. |
| ffi::Array< PrimExpr > tvm::sym::DetectLinearEquation | ( | const PrimExpr & | e, |
| const ffi::Array< PrimVar > & | vars | ||
| ) |
Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n] Where coeff[i] and base are invariant of var[j] for all i and j.
| e | The expression to be detected. |
| vars | List of variables to be used in detection. |
| TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > tvm::sym::EstimateRegionLowerBound | ( | const ffi::Array< Range > & | region, |
| const ffi::Map< Var, Range > & | var_dom, | ||
| const PrimExpr & | predicate, | ||
| const sym::Analyzer & | analyzer | ||
| ) |
Analyze the region with affine map, given the domain of variables and their predicate. Some subregion may be discarded during the lower-bound analysis.
| region | The region to be analyzed |
| var_dom | The ranges of the variables |
| predicate | The predicate for the affine map |
| analyzer | The analyzer used |
| TVM_TIRX_DLL ffi::Optional< ffi::Array< IntSet > > tvm::sym::EstimateRegionStrictBound | ( | const ffi::Array< Range > & | region, |
| const ffi::Map< Var, Range > & | var_dom, | ||
| const PrimExpr & | predicate, | ||
| const sym::Analyzer & | analyzer | ||
| ) |
Analyze the region with affine map, given the domain of variables and their predicate. The result should be strict, i.e. no region is discarded or relaxed.
| region | The region to be analyzed |
| var_dom | The ranges of the variables |
| predicate | The predicate for the affine map |
| analyzer | The analyzer used |
| TVM_TIRX_DLL ffi::Array< IntSet > tvm::sym::EstimateRegionUpperBound | ( | const ffi::Array< Range > & | region, |
| const ffi::Map< Var, Range > & | var_dom, | ||
| const PrimExpr & | predicate, | ||
| const sym::Analyzer & | analyzer | ||
| ) |
Analyze the region with affine map, given the domain of variables and their predicate Relaxation of the region may be used in upper-bound analysis, i.e. some extra region may be added to the result.
| region | The region to be analyzed |
| var_dom | The ranges of the variables |
| predicate | The predicate for the affine map |
| analyzer | The analyzer used |
| ffi::Array< IntSet > tvm::sym::EvalSet | ( | const ffi::Array< Range > & | region, |
| const ffi::Map< Var, IntSet > & | dom_map | ||
| ) |
Same as EvalSet, but takes ffi::Array<Range>
| region | The range to be evaluated. |
| dom_map | The domain of each variable. |
| IntSet tvm::sym::EvalSet | ( | IntSet | s, |
| const std::unordered_map< const VarNode *, IntSet > & | dom_map | ||
| ) |
Find an symbolic integer set that contains is union over all the possible conditional values in dom_map.
| s | The initial set. |
| dom_map | The domain of each variable. |
Find an symbolic integer set that contains all possible values of e given the domain of each variables.
| e | The expression to be evaluated. |
| dom_map | The domain of each variable. |
| IntSet tvm::sym::EvalSet | ( | PrimExpr | e, |
| const std::unordered_map< const VarNode *, IntSet > & | dom_map | ||
| ) |
Same as EvalSet, but takes unordered_map.
| e | The expression to be evaluated. |
| dom_map | The domain of each variable. |
Same as EvalSet, but takes unordered_map.
| r | The range to be evaluated. |
| dom_map | The domain of each variable. |
| ExprIntSetMap tvm::sym::EvalSetForEachSubExpr | ( | PrimExpr | e, |
| const std::unordered_map< const VarNode *, IntSet > & | dom_map | ||
| ) |
Find the integer set of every sub-expression, given the domain of each iteration variables.
| e | The expression to be evaluated. |
| dom_map | The domain of each variable. |
Create an intersected set of all sets.
| sets | The sets to be intersected |
| TVM_TIRX_DLL IntSet tvm::sym::Intersect | ( | const IntSet & | lhs, |
| const IntSet & | rhs, | ||
| const Analyzer & | analyzer | ||
| ) |
Intersect two integer sets using the analyzer's bindings and constraints.
| lhs | The first set. |
| rhs | The second set. |
| analyzer | The analyzer used to prove whether the intersection is empty. |
| ffi::Map< Var, PrimExpr > tvm::sym::InverseAffineIterMap | ( | const ffi::Array< IterSumExpr > & | iter_map, |
| const ffi::Array< PrimExpr > | outputs | ||
| ) |
Apply the inverse of the affine transformation to the outputs.
Similar to the back-propagation, starting from the outputs, it visits the DAG of the expressions in reverse topology order and applies the inverse of the affine transformation until it reaches the input. The affine iter map is required to be bijective.
For example, iter_map = [l0 // 16, l0 % 16], outputs = [output_0, output_1], the affine transformation specified by iter_map will be applied to outputs and the result will be {l0: ((output_0*16) + output_1)}.
The range of outputs should be the same as the output range of the affine transmation.
| iter_map | The bijective affine iter map. |
| outputs | The outputs of the affine transformation. |
| ffi::Array< PrimExpr > tvm::sym::IterMapSimplify | ( | const ffi::Array< PrimExpr > & | indices, |
| const ffi::Map< PrimVar, Range > & | input_iters, | ||
| const PrimExpr & | input_pred, | ||
| IterMapLevel | check_level, | ||
| const sym::Analyzer & | analyzer, | ||
| bool | simplify_trivial_iterators = true |
||
| ) |
Use IterVarMap detector to rewrite and simplify the indices.
| indices | The indices to detect pattern for. |
| input_iters | Map from variable to iterator's range. |
| input_pred | The predicate constraints on the input iterators |
| check_level | The iter mapping checking level. |
| analyzer | Analyzer used to get context information. |
| simplify_trivial_iterators | If true, iterators with unit extents are simplified |
Given an expression that may contain IterMapExpr, transform it to normal PrimExpr.
| expr | The input expression, which may contain IterMapExpr. |
| IterSumExpr tvm::sym::NormalizeToIterSum | ( | PrimExpr | index, |
| const ffi::Map< PrimVar, Range > & | input_iters, | ||
| const sym::Analyzer & | analyzer | ||
| ) |
Rewrite index as IterSumExpr.
((i0 // b0) % a0) * s0 + ((i0 // b1) % a1) * s1 ... + base
The iterators are ordered such that s0 > s1 ... if we can prove the relation.
Note that base may contain expressions that cannot be detected as the right pattern.
| index | The input index |
| input_iters | The input iterators. |
| analyzer | The input analyzer. |
|
inlineconstexpr |
|
inlineconstexpr |
| ffi::Array< ffi::Array< IterMark > > tvm::sym::SubspaceDivide | ( | const ffi::Array< PrimExpr > & | bindings, |
| const ffi::Map< PrimVar, Range > & | input_iters, | ||
| const ffi::Array< PrimVar > & | sub_iters, | ||
| const PrimExpr & | predicate, | ||
| IterMapLevel | check_level, | ||
| const sym::Analyzer & | analyzer, | ||
| bool | simplify_trivial_iterators = true |
||
| ) |
Detect if bindings can be written as [a_0*e_0 + b_0 + c_0, a_1*e_1 + b_1, ..., a_n*e_n + b_n].
where a = some-quasi-affine-iter-map(input_iters set_minus sub_iters) b = some-quasi-affine-iter-map(sub_iters) c is constant symbols e is the extent of b
For example, z*12 + y*3 + x + c = (z*4+y)*3 + x, if sub_iters={x}
| bindings | The input bindings |
| input_iters | Map from variable to iterator's range. |
| sub_iters | Iterators of subspace. |
| predicate | The predicate constraints on the input iterators |
| check_level | The iter mapping checking level. |
| analyzer | Analyzer used to get context information. |
| simplify_trivial_iterators | If true, iterators with extent of 1 will be replaced with a constant value. |
Create a union set of all sets, possibly relaxed.
| sets | The sets to be combined |
Create a lower-bound of union set, where some of the segments may be dropped.
| sets | The sets to be combined |
| ffi::Array< IntSet > tvm::sym::UnionRegion | ( | const ffi::Array< ffi::Array< IntSet > > & | nd_int_sets | ) |
The union of N-dimensional integer sets.
| nd_int_sets | A list of N-dimensional integer sets |