24 #ifndef TVM_ARITH_ANALYZER_H_ 25 #define TVM_ARITH_ANALYZER_H_ 33 #include <unordered_map> 90 v->Visit(
"min_value", &min_value);
91 v->Visit(
"max_value", &max_value);
104 static const constexpr int64_t kNegInf = -kPosInf;
106 static constexpr
const char* _type_key =
"arith.ConstIntBound";
133 using BoundMapType = std::unordered_map<PrimExpr, ConstIntBound, ObjectPtrHash, ObjectPtrEqual>;
156 TVM_DLL
void Update(
const Var&
var,
const ConstIntBound& info,
bool allow_override =
false);
164 TVM_DLL
void Bind(
const Var&
var,
const Range& range,
bool allow_override =
false);
177 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
204 v->Visit(
"coeff", &coeff);
205 v->Visit(
"base", &base);
212 static constexpr
const char* _type_key =
"arith.ModularSet";
222 TVM_DLL
ModularSet(int64_t coeff, int64_t base);
245 TVM_DLL
void Update(
const Var&
var,
const ModularSet& info,
bool allow_override =
false);
258 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
284 TVM_DLL
void Update(
const Var&
var,
const PrimExpr& new_expr,
bool allow_override =
false);
292 TVM_DLL std::function<void()> EnterConstraint(
const PrimExpr& constraint);
315 kTransitivelyProveInequalities = (1 << 0),
323 kConvertBooleanToAndOfOrs = (1 << 1),
336 kApplyConstraintsToBooleanBranches = (1 << 2),
344 TVM_DLL
void SetEnabledExtensions(
Extension flags);
347 TVM_DLL
Extension GetEnabledExtensions()
const;
379 TVM_DLL
void Update(
const Var& var,
const PrimExpr& new_expr,
bool allow_override =
false);
408 return CompareResult(static_cast<int>(lhs) & static_cast<int>(rhs));
411 return CompareResult(static_cast<int>(lhs) | static_cast<int>(rhs));
440 bool propagate_inequalities =
true);
448 TVM_DLL
void Bind(
const Var& var,
const PrimExpr& expr,
bool allow_override =
false);
456 TVM_DLL
void Bind(
const Var& var,
const Range& range,
bool allow_override =
false);
464 TVM_DLL std::function<void()> EnterConstraint(
const PrimExpr& constraint);
473 std::unique_ptr<Impl> impl_;
502 : analyzer_(analyzer), constraint_(constraint) {}
504 void EnterWithScope();
506 void ExitWithScope();
512 std::vector<std::function<void()>> recovery_functions_;
547 TVM_DLL
void Update(
const Var& var,
const IntSet& new_interval_set,
bool allow_override =
false);
556 TVM_DLL
void Bind(
const Var& var,
const Range& new_range,
bool allow_override =
false);
558 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
612 void Bind(
const Var& var,
const PrimExpr& expr,
bool allow_override =
false);
625 void Bind(
const Var& var,
const Range& range,
bool allow_override =
false);
647 bool CanProveGreaterEqual(
const PrimExpr& expr, int64_t lower_bound);
660 bool CanProveLess(
const PrimExpr& expr, int64_t upper_bound);
703 #endif // TVM_ARITH_ANALYZER_H_ void VisitAttrs(tvm::AttrVisitor *v)
Definition: analyzer.h:89
static const constexpr int64_t kPosInf
Number to represent +inf.
Definition: analyzer.h:99
int64_t max_value
Definition: analyzer.h:87
void VisitAttrs(tvm::AttrVisitor *v)
Definition: analyzer.h:203
default strength, can be used in.
Constant integer up and lower bound(inclusive). Useful for value bound analysis.
Definition: analyzer.h:84
constexpr CompareResult operator &(CompareResult lhs, CompareResult rhs)
Definition: analyzer.h:407
int64_t coeff
linear co-efficient
Definition: analyzer.h:199
PrimExpr min_value(const DataType &dtype, Span span=Span())
std::unordered_map< PrimExpr, ConstIntBound, ObjectPtrHash, ObjectPtrEqual > BoundMapType
Definition: analyzer.h:133
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:124
Type Bind(const Type &type, const Map< TypeVar, Type > &args_map)
Bind free type variables in the type.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Extension
Flags to enable more computationally-intensive simplifications.
Definition: analyzer.h:306
bool SEqualReduce(const ModularSetNode *other, SEqualReducer equal) const
Definition: analyzer.h:208
Range of a linear integer function. Use to do specify the possible index values.
Definition: analyzer.h:196
Canonical-form based simplifier.
Definition: analyzer.h:363
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
a named variable in TIR
Definition: var.h:88
base class of all object containers.
Definition: object.h:167
constexpr CompareResult operator|(CompareResult lhs, CompareResult rhs)
Definition: analyzer.h:410
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
ProofStrength
The strength used in top-level condition proves.
Definition: analyzer.h:69
Range constainer.
Definition: expr.h:715
reference of ModularSetNode
Definition: analyzer.h:220
Floor division.
Definition: analyzer.h:59
Truncated division.
Definition: analyzer.h:57
IntSetAnalyzer int_set
sub-analyzer: int set
Definition: analyzer.h:595
Analyzer to get constant integer bound over expression.
Definition: analyzer.h:131
Using previously specified knowns, compare the expressions provided.
Definition: analyzer.h:420
Managed reference to IntSetNode.
Definition: int_set.h:68
RewriteSimplifier rewrite_simplify
sub-analyzer rewrite simplify
Definition: analyzer.h:591
CanonicalSimplifier canonical_simplify
sub-analyzer canonical simplify
Definition: analyzer.h:593
Analyzer to get modular information over expression.
Definition: analyzer.h:230
int64_t base
The base.
Definition: analyzer.h:201
PrimExpr max(PrimExpr a, PrimExpr b, Span span=Span())
take maximum of two values
static const constexpr int64_t kNegInf
Number to represent -inf.
Definition: analyzer.h:104
TransitiveComparisonAnalyzer transitive_comparisons
sub-analyzer transitive comparisons
Definition: analyzer.h:597
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:713
RAII wrapper function to enter and exit a context object similar to python's with syntax...
Definition: with.h:58
DivMode
Definition: analyzer.h:55
Constraint context.
Definition: analyzer.h:492
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
Base class of all object reference.
Definition: object.h:511
Integer set analyzer.
Definition: analyzer.h:518
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
int64_t min_value
Definition: analyzer.h:86
PrimExpr max_value(const DataType &dtype, Span span=Span())
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1271
Prove using symbolic bound analysis.
ConstIntBoundAnalyzer const_int_bound
sub-analyzer: const integer bound
Definition: analyzer.h:587
Rewrite-rule based simplifier.
Definition: analyzer.h:268
ModularSetAnalyzer modular_set
sub-analyzer: modular set
Definition: analyzer.h:589
reference class to ConstIntBoundNode
Definition: analyzer.h:114
Reference to PrimExprNode.
Definition: expr.h:114
bool SEqualReduce(const ConstIntBoundNode *other, SEqualReducer equal) const
Definition: analyzer.h:94
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:579
CompareResult
Structure for representing result of known.
Definition: analyzer.h:396
RAII wrapper function to enter and exit a context object similar to python's with syntax...