tvm
Loading...
Searching...
No Matches
analyzer.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
24#ifndef TVM_SYM_ANALYZER_H_
25#define TVM_SYM_ANALYZER_H_
26
27#include <tvm/ffi/cast.h>
28#include <tvm/ffi/object.h>
29#include <tvm/ffi/reflection/registry.h>
30#include <tvm/ffi/string.h>
31#include <tvm/ir/expr.h>
32#include <tvm/ir/with_context.h>
33#include <tvm/sym/int_set.h>
34
35#include <limits>
36#include <memory>
37#include <unordered_map>
38#include <utility>
39#include <vector>
40
41namespace tvm {
43namespace sym {
44//-------------------------------------------------------
45// Base integer analysis API.
46//
47// We have multiple type of analyzers to do relaxed
48// integer set analysis(bound analysis, modulo) and
49// equivalence checking and simplification.
50//
51// Importantly, each analyzer may need result from
52// another analyzer.
53//-------------------------------------------------------
54
55// Forward declare the analyzer object and its reference handle.
56class AnalyzerObj;
57class Analyzer;
58class ConstraintContext;
59
66
74enum class ProofStrength : int {
76 kDefault = 0,
81};
82
89class ConstIntBoundObj : public ffi::Object {
90 public:
91 int64_t min_value;
92 int64_t max_value;
93
94 static void RegisterReflection() {
95 namespace refl = tvm::ffi::reflection;
96 refl::ObjectDef<ConstIntBoundObj>()
97 .def_ro("min_value", &ConstIntBoundObj::min_value)
98 .def_ro("max_value", &ConstIntBoundObj::max_value);
99 }
100
102 static const constexpr int64_t kPosInf = std::numeric_limits<int64_t>::max();
107 static const constexpr int64_t kNegInf = -kPosInf;
108
109 static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
110 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.ConstIntBound", ConstIntBoundObj, ffi::Object);
111};
112
117class ConstIntBound : public ffi::ObjectRef {
118 public:
124 TVM_TIRX_DLL ConstIntBound(int64_t min_value, int64_t max_value);
125
126 static const constexpr int64_t kPosInf = ConstIntBoundObj::kPosInf;
127 static const constexpr int64_t kNegInf = ConstIntBoundObj::kNegInf;
129};
130
135 public:
137 std::unordered_map<PrimExpr, ConstIntBound, ffi::ObjectPtrHash, ffi::ObjectPtrEqual>;
144
152
160 TVM_TIRX_DLL void Update(const Var& var, const ConstIntBound& info, bool allow_override = false);
161
169 TVM_TIRX_DLL void Bind(const Var& var, const Range& range, bool allow_override = false);
170
176 TVM_TIRX_DLL bool IsBound(const Var& var) const;
177
178 private:
179 friend class AnalyzerObj;
180 friend class ConstraintContext;
181 explicit ConstIntBoundAnalyzer(AnalyzerObj* parent);
183 void CopyFrom(const ConstIntBoundAnalyzer& other);
190 std::function<void()> EnterConstraint(const PrimExpr& constraint);
191 struct Entry;
192 class Impl;
194 std::unique_ptr<Impl> impl_;
195};
196
209class ModularSetObj : public ffi::Object {
210 public:
212 int64_t coeff;
214 int64_t base;
215
216 static void RegisterReflection() {
217 namespace refl = tvm::ffi::reflection;
218 refl::ObjectDef<ModularSetObj>()
219 .def_ro("coeff", &ModularSetObj::coeff)
220 .def_ro("base", &ModularSetObj::base);
221 }
222
223 static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
224 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.ModularSet", ModularSetObj, ffi::Object);
225};
226
231class ModularSet : public ffi::ObjectRef {
232 public:
233 TVM_TIRX_DLL ModularSet(int64_t coeff, int64_t base);
234
236};
237
242 public:
256 TVM_TIRX_DLL void Update(const Var& var, const ModularSet& info, bool allow_override = false);
257
258 private:
259 friend class AnalyzerObj;
260 friend class ConstraintContext;
261 explicit ModularSetAnalyzer(AnalyzerObj* parent);
263 void CopyFrom(const ModularSetAnalyzer& other);
270 std::function<void()> EnterConstraint(const PrimExpr& constraint);
271 struct Entry;
272 class Impl;
274 std::unique_ptr<Impl> impl_;
275};
276
281 public:
288
296 TVM_TIRX_DLL void Update(const Var& var, const PrimExpr& new_expr, bool allow_override = false);
297
305 TVM_TIRX_DLL std::function<void()> EnterConstraint(const PrimExpr& constraint,
306 bool is_assume = false);
307
321 // No extensions enabled
322 kNone = 0,
323
324 /* When simplifying an inequality, attempt to use scope-based knowns.
325 *
326 * Example:
327 * if_then_else(i<j && j<k, i<k, false) => if_then_else(i<j && j<k, true, false)
328 */
330
331 /* When simplifying a boolean expression, convert to an AND of ORs
332 * (conjunctive normal form).
333 *
334 * Example:
335 * (a && b) || c => (a || c) && (b || c)
336 */
338
339 /* When simplifying a boolean AND or a boolean OR, simplify each
340 * branch under the assumption that the other branch does not
341 * already dominate the result. That is, simplify each branch of
342 * (A && B) under the assumption that the other branch is true,
343 * and simplify each branch of (A || B) under the assumption that
344 * the other branch is false.
345 *
346 * Example:
347 * (n < 10) && (n < 5) => (n < 10)
348 * (n < 10) || (n < 5) => (n < 5)
349 */
351
352 /* Special handling for expressions `(A+B)*C < (A*B)*D`
353 *
354 * Expressions of the form `(A+B)*C < (A*B)*D` can occur occur
355 * when comparing the number of operations required for two
356 * different orderings in which matrix multiplications can be
357 * performed. Proving or disproving this conditional allows an
358 * optimal order of execution to be selected, even for dynamic
359 * argument shapes.
360 *
361 * The default behavior of `ConstIntBounds` assumes that each term
362 * in an expression is independent, and is insufficient to prove
363 * these inequalities. For example, the maximum value of `(A+B)*C
364 * - (A*B)*D` is determined by taking the maximum value of
365 * `(A+B)*C` and subtracting the minimum value of `(A*B)*D`.
366 * While this algorithm can be applied in all cases, the bound it
367 * provides is looser than strictly required.
368 *
369 * This extension adds a check for this case. When `A`, `B`, `C`,
370 * and `D` are all positive values, as is the case for tensor
371 * shapes, the inequality can be written as `1/A + 1/B < D/C`. If
372 * this inequality holds for the minimum values of `A`, `B`, and
373 * `D`, along with the maximum value of `C`, then the inequality
374 * holds for all values.
375 *
376 * This extension requires little to no performance overhead, and
377 * may be enabled by default in future releases.
378 */
380 };
381
388
391
393 TVM_TIRX_DLL ffi::ObjectRef GetStatsCounters() const;
394
397
413
414 private:
415 friend class AnalyzerObj;
416 friend class ConstraintContext;
418 explicit RewriteSimplifier(AnalyzerObj* parent);
420 void CopyFrom(const RewriteSimplifier& other);
421 class Impl;
423 ffi::ObjectPtr<Impl> impl_;
424};
425
430 public:
437
445 TVM_TIRX_DLL void Update(const Var& var, const PrimExpr& new_expr, bool allow_override = false);
446
447 private:
448 friend class AnalyzerObj;
449 friend class ConstraintContext;
450 explicit CanonicalSimplifier(AnalyzerObj* parent);
452 void CopyFrom(const CanonicalSimplifier& other);
453 class Impl;
455 ffi::ObjectPtr<Impl> impl_;
456};
457
463enum class CompareResult : int {
464 kInconsistent = 0,
465 kEQ = 1,
466 kLT = 2,
467 kLE = 3,
468 kGT = 4,
469 kGE = 5,
470 kNE = 6,
471 kUnknown = 7
472};
473
475 return CompareResult(static_cast<int>(lhs) & static_cast<int>(rhs));
476}
478 return CompareResult(static_cast<int>(lhs) | static_cast<int>(rhs));
479}
480
488 public:
489 /* \brief Using previously specified knowns, compare the expressions provided
490 *
491 * \param lhs The left-hand side of the comparison
492 *
493 * \param rhs The right-hand side of the comparison
494 *
495 * \param propagate_inequalities If true, attempt to find a sequence
496 * of transitive inequalities that allow the lhs and rhs to be
497 * compared. If false, only use the known comparison that have been
498 * directly provided. Using `propagate_inequalities = false` is
499 * roughly equivalent to comparing against all known inequality
500 * expressions using `prim::ExprDeepEqual`, but also allows for constant
501 * offsets on either side of the inequality.
502 *
503 * \return The most specific result that can be proven about the
504 * comparison. If nothing can be proven, returns kUnknown.
505 */
507 bool propagate_inequalities = true);
508
515 TVM_TIRX_DLL void Bind(const Var& var, const PrimExpr& expr, bool allow_override = false);
516
523 TVM_TIRX_DLL void Bind(const Var& var, const Range& range, bool allow_override = false);
524
531 TVM_TIRX_DLL std::function<void()> EnterConstraint(const PrimExpr& constraint);
532
533 private:
534 friend class AnalyzerObj;
535 friend class ConstraintContext;
538 void CopyFrom(const TransitiveComparisonAnalyzer& other);
539 class Impl;
541 std::unique_ptr<Impl> impl_;
542};
543
548 public:
557 TVM_TIRX_DLL IntSet operator()(const PrimExpr& expr, const ffi::Map<Var, IntSet>& dom_map);
558
568
576 TVM_TIRX_DLL void Update(const Var& var, const IntSet& new_interval_set,
577 bool allow_override = false);
578
586 TVM_TIRX_DLL void Bind(const Var& var, const Range& new_range, bool allow_override = false);
587
588 std::function<void()> EnterConstraint(const PrimExpr& constraint);
589
590 private:
591 friend class AnalyzerObj;
592 explicit IntSetAnalyzer(AnalyzerObj* parent);
594 void CopyFrom(const IntSetAnalyzer& other);
595 class Impl;
597 Impl* impl_;
598};
599
600class Z3Prover {
601 public:
609 TVM_TIRX_DLL void Bind(const Var& var, const Range& new_range, bool allow_override = false);
610
618 TVM_TIRX_DLL void Bind(const Var& var, const PrimExpr& expr, bool allow_override = false);
619
626
633 TVM_TIRX_DLL bool CanProve(const PrimExpr& expr);
634
642 std::function<void()> EnterConstraint(const PrimExpr& constraint, bool is_assume = false);
643
650 ffi::String GetSMTLIB2(const ffi::Optional<PrimExpr> expr);
651
657 ffi::String GetStats();
658
664 void SetTimeoutMs(unsigned timeout_ms);
665
671 void SetRLimit(unsigned rlimit);
672
679 ffi::String GetModel(const PrimExpr& expr);
680
692 TVM_TIRX_DLL int64_t CountSatisfyingValues(const Var& var, int64_t max_count = 2048,
693 int64_t min_consecutive = 1);
694
695 private:
696 friend class AnalyzerObj;
697 friend class Analyzer;
698 explicit Z3Prover(AnalyzerObj* parent);
700 void CopyFrom(const Z3Prover& other);
701 class Impl;
702 std::unique_ptr<Impl> impl_;
703};
704
715class TVM_TIRX_DLL AnalyzerObj : public ffi::Object {
716 public:
752 void MarkGlobalNonNegValue(const PrimExpr& value);
765 void Bind(const Var& var, const PrimExpr& expr, bool allow_override = false);
778 void Bind(const Var& var, const Range& range, bool allow_override = false);
787 void Bind(const ffi::Map<Var, Range>& variables, bool allow_override = false);
800 bool CanProveGreaterEqual(const PrimExpr& expr, int64_t lower_bound);
813 bool CanProveLess(const PrimExpr& expr, int64_t upper_bound);
823 bool CanProveEqual(const PrimExpr& lhs, const PrimExpr& rhs);
853 bool CanProve(const PrimExpr& cond, ProofStrength strength = ProofStrength::kDefault);
854
868 PrimExpr Simplify(const PrimExpr& expr, int steps = 2);
869
889
899 static constexpr bool _type_mutable = true;
900 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.Analyzer", AnalyzerObj, ffi::Object);
901};
902
916class Analyzer : public ffi::ObjectRef {
917 public:
919 Analyzer() : Analyzer(ffi::make_object<AnalyzerObj>()) {}
920 explicit Analyzer(ffi::ObjectPtr<AnalyzerObj> n) : ffi::ObjectRef(std::move(n)) {
921 TVM_FFI_ICHECK(this->get() != nullptr);
922 }
924};
925
943 private:
944 // declare friend to enable with.
945 friend class With<ConstraintContext>;
952 ConstraintContext(const Analyzer& analyzer, PrimExpr constraint)
953 : ConstraintContext(analyzer, std::move(constraint), false) {}
961 ConstraintContext(const Analyzer& analyzer, PrimExpr constraint, bool is_assume)
962 : analyzer_(analyzer), constraint_(std::move(constraint)), is_assume_(is_assume) {}
970 ConstraintContext(AnalyzerObj* analyzer, PrimExpr constraint)
971 : ConstraintContext(ffi::GetRef<Analyzer>(analyzer), std::move(constraint), false) {}
978 ConstraintContext(AnalyzerObj* analyzer, PrimExpr constraint, bool is_assume)
979 : ConstraintContext(ffi::GetRef<Analyzer>(analyzer), std::move(constraint), is_assume) {}
980 // enter the scope.
981 TVM_TIRX_DLL void EnterWithScope();
982 // exit the scope.
983 TVM_TIRX_DLL void ExitWithScope();
985 Analyzer analyzer_;
987 PrimExpr constraint_;
989 std::vector<std::function<void()>> recovery_functions_;
991 bool is_assume_;
992};
993
994} // namespace sym
995} // namespace tvm
996#endif // TVM_SYM_ANALYZER_H_
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Range container
Definition expr.h:1025
Managed reference to VarNode.
Definition expr.h:714
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Analyzer that contains bunch of sub-analyzers.
Definition analyzer.h:715
RewriteSimplifier rewrite_simplify
sub-analyzer rewrite simplify
Definition analyzer.h:722
bool CanProve(const PrimExpr &cond, ProofStrength strength=ProofStrength::kDefault)
Whether can we prove condition.
Analyzer Clone() const
Deep-copy this analyzer into a new, independent Analyzer.
bool CanProveGreaterEqual(const PrimExpr &expr, int64_t lower_bound)
Whether can we prove expr >= val.
IntSetAnalyzer int_set
sub-analyzer: int set
Definition analyzer.h:726
void Bind(const Var &var, const PrimExpr &expr, bool allow_override=false)
Notify all the sub-analyzers that var is created and binded to expr.
Z3Prover z3_prover
sub-analyzer using Z3
Definition analyzer.h:730
TransitiveComparisonAnalyzer transitive_comparisons
sub-analyzer transitive comparisons
Definition analyzer.h:728
void Bind(const ffi::Map< Var, Range > &variables, bool allow_override=false)
Bind all the vars in the Map.
CanonicalSimplifier canonical_simplify
sub-analyzer canonical simplify
Definition analyzer.h:724
bool CanProveEqual(const PrimExpr &lhs, const PrimExpr &rhs)
Whether can we prove lhs == rhs.
void Bind(const Var &var, const Range &range, bool allow_override=false)
Notify all the sub-analyzers that var is created and bound to a range.
void MarkGlobalNonNegValue(const PrimExpr &value)
Mark the value as non-negative value globally in analyzer.
PrimExpr Simplify(const PrimExpr &expr, int steps=2)
Simplify expr.
ConstIntBoundAnalyzer const_int_bound
sub-analyzer: const integer bound
Definition analyzer.h:718
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.Analyzer", AnalyzerObj, ffi::Object)
AnalyzerObj()
constructor
bool CanProveLessEqualThanSymbolicShapeValue(const PrimExpr &lhs, const PrimExpr &shape)
Whether we can prove lhs is smaller than possibly symbolic shape.
bool CanProveLess(const PrimExpr &expr, int64_t upper_bound)
Whether can we prove expr < val.
ModularSetAnalyzer modular_set
sub-analyzer: modular set
Definition analyzer.h:720
Managed reference to AnalyzerObj.
Definition analyzer.h:916
Analyzer()
Default-construct a fresh analyzer (allocates an AnalyzerObj).
Definition analyzer.h:919
Analyzer(ffi::ObjectPtr< AnalyzerObj > n)
Definition analyzer.h:920
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Analyzer, ffi::ObjectRef, AnalyzerObj)
Canonical-form based simplifier.
Definition analyzer.h:429
TVM_TIRX_DLL void Update(const Var &var, const PrimExpr &new_expr, bool allow_override=false)
Update binding of var to a new expression.
TVM_TIRX_DLL PrimExpr operator()(const PrimExpr &expr)
analyze the expr
Analyzer to get constant integer bound over expression.
Definition analyzer.h:134
TVM_TIRX_DLL bool IsBound(const Var &var) const
Check if a variable is bound to a range.
TVM_TIRX_DLL ConstIntBound operator()(const PrimExpr &expr) const
analyze the expr
TVM_TIRX_DLL void Bind(const Var &var, const Range &range, bool allow_override=false)
Bind variable to a range.
TVM_TIRX_DLL ConstIntBound operator()(const PrimExpr &expr, BoundMapType *bound)
analyze the expr with the intermediate memorized to avoid redundant computation
TVM_TIRX_DLL void Update(const Var &var, const ConstIntBound &info, bool allow_override=false)
Update constant int bound information of var.
std::unordered_map< PrimExpr, ConstIntBound, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > BoundMapType
Definition analyzer.h:137
Constant integer up and lower bound(inclusive). Useful for value bound analysis.
Definition analyzer.h:89
static const constexpr int64_t kPosInf
Number to represent +inf.
Definition analyzer.h:102
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.ConstIntBound", ConstIntBoundObj, ffi::Object)
static void RegisterReflection()
Definition analyzer.h:94
int64_t min_value
Definition analyzer.h:91
int64_t max_value
Definition analyzer.h:92
static const constexpr int64_t kNegInf
Number to represent -inf.
Definition analyzer.h:107
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition analyzer.h:109
reference class to ConstIntBoundObj
Definition analyzer.h:117
TVM_TIRX_DLL ConstIntBound(int64_t min_value, int64_t max_value)
constructor by fields.
static const constexpr int64_t kNegInf
Definition analyzer.h:127
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ConstIntBound, ffi::ObjectRef, ConstIntBoundObj)
static const constexpr int64_t kPosInf
Definition analyzer.h:126
Constraint context.
Definition analyzer.h:942
Integer set analyzer.
Definition analyzer.h:547
TVM_TIRX_DLL void Bind(const Var &var, const Range &new_range, bool allow_override=false)
Update binding of var to a new expression.
std::function< void()> EnterConstraint(const PrimExpr &constraint)
TVM_TIRX_DLL IntSet operator()(const PrimExpr &expr, const ffi::Map< Var, IntSet > &dom_map)
Find a symbolic integer set that contains all possible values of expr given the domain of each variab...
TVM_TIRX_DLL IntSet operator()(const PrimExpr &expr)
Find a symbolic integer set that contains all possible values of expr given the domain of each variab...
TVM_TIRX_DLL void Update(const Var &var, const IntSet &new_interval_set, bool allow_override=false)
Update binding of var to a new expression.
Managed reference to IntSetObj.
Definition int_set.h:63
Analyzer to get modular information over expression.
Definition analyzer.h:241
TVM_TIRX_DLL void Update(const Var &var, const ModularSet &info, bool allow_override=false)
Update constant int bound information of var.
TVM_TIRX_DLL ModularSet operator()(const PrimExpr &expr)
analyze the expr
Range of a linear integer function. Use to do specify the possible index values.
Definition analyzer.h:209
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("sym.ModularSet", ModularSetObj, ffi::Object)
int64_t base
The base.
Definition analyzer.h:214
int64_t coeff
linear co-efficient
Definition analyzer.h:212
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition analyzer.h:223
static void RegisterReflection()
Definition analyzer.h:216
reference of ModularSetObj
Definition analyzer.h:231
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ModularSet, ffi::ObjectRef, ModularSetObj)
TVM_TIRX_DLL ModularSet(int64_t coeff, int64_t base)
Rewrite-rule based simplifier.
Definition analyzer.h:280
TVM_TIRX_DLL PrimExpr operator()(const PrimExpr &expr)
analyze the expr
Extension
Flags to enable more computationally-intensive simplifications.
Definition analyzer.h:320
@ kComparisonOfProductAndSum
Definition analyzer.h:379
@ kConvertBooleanToAndOfOrs
Definition analyzer.h:337
@ kApplyConstraintsToBooleanBranches
Definition analyzer.h:350
@ kTransitivelyProveInequalities
Definition analyzer.h:329
@ kNone
Definition analyzer.h:322
TVM_TIRX_DLL void Update(const Var &var, const PrimExpr &new_expr, bool allow_override=false)
Update binding of var to a new expression.
TVM_TIRX_DLL std::function< void()> EnterConstraint(const PrimExpr &constraint, bool is_assume=false)
Update the internal state to enter constraint.
TVM_TIRX_DLL void SetEnabledExtensions(Extension flags)
Enable an optional extension or extensions.
TVM_TIRX_DLL void SetMaximumRewriteSteps(int64_t maximum)
Set the maximum allowed number of rewrite steps.
TVM_TIRX_DLL Extension GetEnabledExtensions() const
Return the currently enabled extensions.
TVM_TIRX_DLL void ResetStatsCounters()
Reset the statistics counters.
TVM_TIRX_DLL ffi::ObjectRef GetStatsCounters() const
Return the statistics counters.
Using previously specified knowns, compare the expressions provided.
Definition analyzer.h:487
TVM_TIRX_DLL void Bind(const Var &var, const Range &range, bool allow_override=false)
Bind a variable as being within a specified range.
TVM_TIRX_DLL std::function< void()> EnterConstraint(const PrimExpr &constraint)
Update the internal state to enter constraint.
TVM_TIRX_DLL void Bind(const Var &var, const PrimExpr &expr, bool allow_override=false)
Bind a variable as being equal to a known expression.
TVM_TIRX_DLL CompareResult TryCompare(const PrimExpr &lhs, const PrimExpr &rhs, bool propagate_inequalities=true)
Definition analyzer.h:600
ffi::String GetStats()
Get statistics about Z3 prover.
ffi::String GetSMTLIB2(const ffi::Optional< PrimExpr > expr)
Get the SMTLIB2 representation of the current context.
TVM_TIRX_DLL bool IsEnabled() const
Whether the Z3 backend is compiled into this build (USE_Z3=ON).
ffi::String GetModel(const PrimExpr &expr)
Get the Z3 model for the given expression if satisfiable.
std::function< void()> EnterConstraint(const PrimExpr &constraint, bool is_assume=false)
Update the internal state to enter constraint.
void SetTimeoutMs(unsigned timeout_ms)
Set timeout in milliseconds for Z3 prover.
TVM_TIRX_DLL void Bind(const Var &var, const PrimExpr &expr, bool allow_override=false)
Update binding of var to a new expression.
TVM_TIRX_DLL bool CanProve(const PrimExpr &expr)
Whether can we prove expr is always true.
void SetRLimit(unsigned rlimit)
Set resource limitation for Z3 prover.
TVM_TIRX_DLL void Bind(const Var &var, const Range &new_range, bool allow_override=false)
Update binding of var to a new expression.
TVM_TIRX_DLL int64_t CountSatisfyingValues(const Var &var, int64_t max_count=2048, int64_t min_consecutive=1)
Count the number of integer values that satisfy the current constraints.
Integer set.
Base expr nodes in TVM.
@ kUnknown
Definition int_set.h:47
CompareResult
Structure for representing result of known.
Definition analyzer.h:463
DivMode
Definition analyzer.h:60
@ kFloorDiv
Floor division.
Definition analyzer.h:64
@ kTruncDiv
Truncated division.
Definition analyzer.h:62
constexpr CompareResult operator|(CompareResult lhs, CompareResult rhs)
Definition analyzer.h:477
ProofStrength
The strength used in top-level condition proves.
Definition analyzer.h:74
@ kSymbolicBound
Prove using symbolic bound analysis.
@ kDefault
default strength, can be used in.
constexpr CompareResult operator&(CompareResult lhs, CompareResult rhs)
Definition analyzer.h:474
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
#define TVM_TIRX_DLL
Definition base.h:83
RAII wrapper function to enter and exit a context object similar to python's with syntax.