24 #ifndef TVM_ARITH_ANALYZER_H_ 25 #define TVM_ARITH_ANALYZER_H_ 33 #include <unordered_map> 74 v->Visit(
"min_value", &min_value);
75 v->Visit(
"max_value", &max_value);
90 static constexpr
const char*
_type_key =
"arith.ConstIntBound";
117 using BoundMapType = std::unordered_map<PrimExpr, ConstIntBound, ObjectPtrHash, ObjectPtrEqual>;
140 TVM_DLL
void Update(
const Var&
var,
const ConstIntBound& info,
bool allow_override =
false);
148 TVM_DLL
void Bind(
const Var&
var,
const Range& range,
bool allow_override =
false);
161 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
188 v->Visit(
"coeff", &coeff);
189 v->Visit(
"base", &base);
196 static constexpr
const char*
_type_key =
"arith.ModularSet";
206 TVM_DLL
ModularSet(int64_t coeff, int64_t base);
229 TVM_DLL
void Update(
const Var&
var,
const ModularSet& info,
bool allow_override =
false);
242 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
268 TVM_DLL
void Update(
const Var&
var,
const PrimExpr& new_expr,
bool allow_override =
false);
276 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
308 TVM_DLL
void Update(
const Var&
var,
const PrimExpr& new_expr,
bool allow_override =
false);
346 : analyzer_(analyzer), constraint_(constraint) {}
348 void EnterWithScope();
350 void ExitWithScope();
356 std::vector<std::function<void()>> recovery_functions_;
391 TVM_DLL
void Update(
const Var&
var,
const IntSet& new_interval_set,
bool allow_override =
false);
400 TVM_DLL
void Bind(
const Var& var,
const Range& new_range,
bool allow_override =
false);
402 std::function<void()> EnterConstraint(
const PrimExpr& constraint);
467 void Bind(
const Var&
var,
const Range& range,
bool allow_override =
false);
489 bool CanProveGreaterEqual(
const PrimExpr& expr, int64_t lower_bound);
502 bool CanProveLess(
const PrimExpr& expr, int64_t upper_bound);
521 bool CanProve(
const PrimExpr& cond);
540 #endif // TVM_ARITH_ANALYZER_H_ void VisitAttrs(tvm::AttrVisitor *v)
Definition: analyzer.h:73
static const constexpr int64_t kPosInf
Number to represent +inf.
Definition: analyzer.h:83
int64_t max_value
Definition: analyzer.h:71
void VisitAttrs(tvm::AttrVisitor *v)
Definition: analyzer.h:187
Constant integer up and lower bound(inclusive). Useful for value bound analysis.
Definition: analyzer.h:68
int64_t coeff
linear co-efficient
Definition: analyzer.h:183
std::unordered_map< PrimExpr, ConstIntBound, ObjectPtrHash, ObjectPtrEqual > BoundMapType
Definition: analyzer.h:117
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
bool SEqualReduce(const ModularSetNode *other, SEqualReducer equal) const
Definition: analyzer.h:192
Range of a linear integer function. Use to do specify the possible index values.
Definition: analyzer.h:180
Canonical-form based simplifier.
Definition: analyzer.h:292
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
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
Range constainer.
Definition: expr.h:711
reference of ModularSetNode
Definition: analyzer.h:204
Floor division.
Definition: analyzer.h:59
Truncated division.
Definition: analyzer.h:57
IntSetAnalyzer int_set
sub-analyzer: int set
Definition: analyzer.h:439
Analyzer to get constant integer bound over expression.
Definition: analyzer.h:115
TVM_DECLARE_FINAL_OBJECT_INFO(ConstIntBoundNode, Object)
Managed reference to IntSetNode.
Definition: int_set.h:68
RewriteSimplifier rewrite_simplify
sub-analyzer rewrite simplify
Definition: analyzer.h:435
CanonicalSimplifier canonical_simplify
sub-analyzer canonical simplify
Definition: analyzer.h:437
Analyzer to get modular information over expression.
Definition: analyzer.h:214
int64_t base
The base.
Definition: analyzer.h:185
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:88
#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
Object & operator=(const Object &other)
Definition: object.h:251
Constraint context.
Definition: analyzer.h:336
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:362
int64_t min_value
Definition: analyzer.h:70
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
ConstIntBoundAnalyzer const_int_bound
sub-analyzer: const integer bound
Definition: analyzer.h:431
static constexpr const char * _type_key
Definition: analyzer.h:90
Rewrite-rule based simplifier.
Definition: analyzer.h:252
ModularSetAnalyzer modular_set
sub-analyzer: modular set
Definition: analyzer.h:433
reference class to ConstIntBoundNode
Definition: analyzer.h:98
Reference to PrimExprNode.
Definition: expr.h:112
bool SEqualReduce(const ConstIntBoundNode *other, SEqualReducer equal) const
Definition: analyzer.h:78
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:423
RAII wrapper function to enter and exit a context object similar to python's with syntax...