|
tvm
|
namespace of symbolic analysis. More...
Namespaces | |
| namespace | detail |
Classes | |
| class | AllowUIntAsIndex |
| Scoped no-overflow assumption for unsigned index arithmetic. More... | |
| class | Analyzer |
| Managed reference to AnalyzerObj. More... | |
| class | AnalyzerObj |
| Coordinated symbolic analyses over an explicitly synchronized premise environment. More... | |
| class | BindingConstraint |
| Managed reference to BindingConstraintObj. More... | |
| class | BindingConstraintObj |
| The value captured when a variable is bound. A mutable-read RHS is retained as data; it must not be re-evaluated or treated as an enduring equality by a consumer. More... | |
| class | CanonicalSimplifier |
| Canonical-form based simplifier. More... | |
| class | ConstIntBound |
| Managed reference to ConstIntBoundObj. More... | |
| class | ConstIntBoundAnalyzer |
| Analyzer to get constant integer bound over expression. More... | |
| class | ConstIntBoundObj |
| Inclusive constant integer bounds, representing [min_value, max_value]. More... | |
| class | Constraint |
| A binding, range, or predicate, without inference or normalization. More... | |
| class | ConstraintContext |
| Managed reference to ConstraintContextObj. Copies share the same context. More... | |
| class | ConstraintContextObj |
| Tracks the constraints relevant to each point in a traversal. More... | |
| class | ConstraintObj |
| Base node for a symbolic premise; it owns no analyzer state. 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 IterMapExprObj. More... | |
| class | IterMapExprObj |
| 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 IterMarkObj. More... | |
| class | IterMarkObj |
| Mark the source as an iterator in [0, extent). More... | |
| class | IterSplitExpr |
| Managed reference to IterSplitExprObj. More... | |
| class | IterSplitExprObj |
| Split of an iterator. More... | |
| class | IterSumExpr |
| Managed reference to IterSumExprObj. More... | |
| class | IterSumExprObj |
| Fuse multiple iterators by summing them with scaling. More... | |
| class | ModularSet |
| Managed reference to ModularSetObj. More... | |
| class | ModularSetAnalyzer |
| Analyzer to get modular information over expression. More... | |
| class | ModularSetObj |
| Integer congruence class {coeff * x + base | x in Z}. More... | |
| class | PredicateConstraint |
| Managed reference to PredicateConstraintObj. More... | |
| class | PredicateConstraintObj |
| A boolean premise. Its validity and lifetime are supplied by the collector. More... | |
| class | RangeConstraint |
| Managed reference to RangeConstraintObj. More... | |
| class | RangeConstraintObj |
| A variable lies in a half-open range. The range need not enumerate every attainable value. More... | |
| class | RewriteSimplifier |
| Rewrite-rule based simplifier. More... | |
| class | Z3Prover |
| Optional Z3-backed prover over the analyzer's accepted premises. More... | |
Typedefs | |
| using | ExprIntSetMap = std::unordered_map< PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > |
| Map from Expr to IntSet. | |
Enumerations | |
| enum | DivMode { kTruncDiv , kFloorDiv } |
| Integer division semantics used by symbolic analysis. More... | |
| enum class | ProofStrength : int { kDefault = 0 , kSymbolicBound = 1 } |
| The strength used for top-level condition proofs. More... | |
| enum class | CompareResult : int { kInconsistent = 0 , kEQ = 1 , kLT = 2 , kLE = 3 , kGT = 4 , kGE = 5 , kNE = 6 , kUnknown = 7 } |
| Possible orderings of two expressions, represented as a bit set. 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) |
| Intersect the possible orderings. | |
| constexpr CompareResult | operator| (CompareResult lhs, CompareResult rhs) |
| Unite the possible orderings. | |
| TVM_TIRX_DLL 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. | |
| TVM_TIRX_DLL IntSet | EvalSet (IntSet s, const ffi::Map< Var, IntSet > &dom_map) |
| Find an symbolic integer set that contains is union over all the possible conditional values in dom_map. | |
| TVM_TIRX_DLL IntSet | EvalSet (Range r, const ffi::Map< Var, IntSet > &dom_map) |
| Evaluate the range over the domain of each variable. | |
| TVM_TIRX_DLL ffi::Array< IntSet > | EvalSet (const ffi::Array< Range > ®ion, const ffi::Map< Var, IntSet > &dom_map) |
| Same as EvalSet, but takes ffi::Array<Range> | |
| TVM_TIRX_DLL ExprIntSetMap | EvalSetForEachSubExpr (PrimExpr e, const ffi::Map< Var, IntSet > &dom_map) |
| Find the integer set of every sub-expression, given the domain of each iteration variables. | |
| TVM_TIRX_DLL IntSet | Union (const ffi::Array< IntSet > &sets) |
| Create a union set of all sets, possibly relaxed. | |
| TVM_TIRX_DLL ffi::Array< IntSet > | UnionRegion (const ffi::Array< ffi::Array< IntSet > > &nd_int_sets) |
| The union of N-dimensional integer sets. | |
| TVM_TIRX_DLL IntSet | UnionLowerBound (const ffi::Array< IntSet > &sets) |
| Create a lower-bound of union set, where some of the segments may be dropped. | |
| TVM_TIRX_DLL ffi::Array< IntSet > | UnionRegionLowerBound (const ffi::Array< ffi::Array< IntSet > > &nd_int_sets) |
| The union of N-dimensional integer sets. | |
| TVM_TIRX_DLL 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. | |
| TVM_TIRX_DLL 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. | |
| TVM_TIRX_DLL 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 an expression, given the domain of each variable. Return IntSet::Nothing() to represent failure. | |
| TVM_TIRX_DLL 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]. | |
| TVM_TIRX_DLL 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. | |
| TVM_TIRX_DLL 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. | |
| TVM_TIRX_DLL 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]. | |
| TVM_TIRX_DLL PrimExpr | NormalizeIterMapToExpr (const PrimExpr &expr) |
| Given an expression that may contain IterMapExpr, transform it to normal PrimExpr. | |
| TVM_TIRX_DLL IterSumExpr | NormalizeToIterSum (PrimExpr index, const ffi::Map< PrimVar, Range > &input_iters, const sym::Analyzer &analyzer) |
| Rewrite index as IterSumExpr. | |
namespace of symbolic analysis.
| using tvm::sym::ExprIntSetMap = typedef std::unordered_map<PrimExpr, IntSet, ffi::ObjectPtrHash, ffi::ObjectPtrEqual> |
|
strong |
Possible orderings of two expressions, represented as a bit set.
EQ, LT, and GT are independent bits. Intersection combines facts that all hold; union combines alternative possibilities. Zero indicates inconsistency.
| enum tvm::sym::DivMode |
|
strong |
The strength used for top-level condition proofs.
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 analysis followed by the optional Z3 fallback. |
| kSymbolicBound | Prove using symbolic bound analysis. |
| enum tvm::sym::SignType |
| TVM_TIRX_DLL 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 |
| TVM_TIRX_DLL 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 an expression, given the domain of each variable. Return IntSet::Nothing() 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 imply e for all value in relax_map |
| TVM_TIRX_DLL 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. |
| 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 |
| TVM_TIRX_DLL 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. |
| TVM_TIRX_DLL IntSet tvm::sym::EvalSet | ( | IntSet | s, |
| const ffi::Map< Var, 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. |
| TVM_TIRX_DLL IntSet tvm::sym::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.
| e | The expression to be evaluated. |
| dom_map | The domain of each variable. |
| TVM_TIRX_DLL IntSet tvm::sym::EvalSet | ( | Range | r, |
| const ffi::Map< Var, IntSet > & | dom_map | ||
| ) |
Evaluate the range over the domain of each variable.
| r | The range to be evaluated. |
| dom_map | The domain of each variable. |
| TVM_TIRX_DLL ExprIntSetMap tvm::sym::EvalSetForEachSubExpr | ( | PrimExpr | e, |
| const ffi::Map< Var, 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. |
| TVM_TIRX_DLL IntSet tvm::sym::Intersect | ( | const ffi::Array< IntSet > & | sets | ) |
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. |
| TVM_TIRX_DLL 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. |
| TVM_TIRX_DLL 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 |
| TVM_TIRX_DLL PrimExpr tvm::sym::NormalizeIterMapToExpr | ( | const PrimExpr & | expr | ) |
Given an expression that may contain IterMapExpr, transform it to normal PrimExpr.
| expr | The input expression, which may contain IterMapExpr. |
| TVM_TIRX_DLL 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 |
Intersect the possible orderings.
| lhs | First set of orderings. |
| rhs | Second set of orderings. |
|
inlineconstexpr |
Unite the possible orderings.
| lhs | First set of orderings. |
| rhs | Second set of orderings. |
| TVM_TIRX_DLL 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. |
| TVM_TIRX_DLL IntSet tvm::sym::Union | ( | const ffi::Array< IntSet > & | sets | ) |
Create a union set of all sets, possibly relaxed.
| sets | The sets to be combined |
| TVM_TIRX_DLL IntSet tvm::sym::UnionLowerBound | ( | const ffi::Array< IntSet > & | sets | ) |
Create a lower-bound of union set, where some of the segments may be dropped.
| sets | The sets to be combined |
| TVM_TIRX_DLL 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 |
| TVM_TIRX_DLL ffi::Array< IntSet > tvm::sym::UnionRegionLowerBound | ( | 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 |