|
tvm
|
Coordinated symbolic analyses over an explicitly synchronized premise environment. More...
#include <analyzer.h>
Public Member Functions | |
| AnalyzerObj () | |
| Construct an analyzer with no accepted premises and default query settings. | |
| void | SetZ3DefaultFallback (bool enabled) |
| Set whether DEFAULT-strength queries try Z3 after native analysis fails. | |
| void | SyncConstraintContext (const ConstraintContext &context) |
| Synchronize all derived facts to the supplied premise environment. | |
| ConstraintContext | GetConstraintContext () const |
| Snapshot the accepted premise environment. | |
| bool | CanProveGreaterEqual (const PrimExpr &expr, int64_t lower_bound) |
| Attempt to prove expr >= lower_bound. | |
| bool | CanProveLess (const PrimExpr &expr, int64_t upper_bound) |
| Attempt to prove expr < upper_bound. | |
| bool | CanProveEqual (const PrimExpr &lhs, const PrimExpr &rhs) |
| Attempt to prove lhs == rhs. | |
| bool | CanProveLessEqualThanSymbolicShapeValue (const PrimExpr &lhs, const PrimExpr &shape) |
| Attempt to prove lhs <= a possibly symbolic shape. | |
| bool | CanProve (const PrimExpr &cond, ProofStrength strength=ProofStrength::kDefault) |
| Attempt to prove a condition under the current premises. | |
| PrimExpr | Simplify (const PrimExpr &expr, int steps=2) |
| Simplify expr. | |
| Analyzer | Clone () const |
| Copy accepted facts and query settings into an independent analyzer. | |
| TVM_FFI_DECLARE_OBJECT_INFO_FINAL ("sym.Analyzer", AnalyzerObj, ffi::Object) | |
Public Attributes | |
| ConstIntBoundAnalyzer | const_int_bound |
| sub-analyzer: const integer bound | |
| ModularSetAnalyzer | modular_set |
| sub-analyzer: modular set | |
| RewriteSimplifier | rewrite_simplify |
| sub-analyzer rewrite simplify | |
| CanonicalSimplifier | canonical_simplify |
| sub-analyzer canonical simplify | |
| IntSetAnalyzer | int_set |
| sub-analyzer: int set | |
| Z3Prover | z3_prover |
| sub-analyzer using Z3 | |
Static Public Attributes | |
| static constexpr bool | _type_mutable = true |
| Analyzer methods update facts, constraints, caches, and stats. | |
Friends | |
| class | detail::TempConstraintScope |
Coordinated symbolic analyses over an explicitly synchronized premise environment.
Queries may update caches, solver state, and statistics, but do not append persistent premises. Proof methods are conservative: false means not proved. Sub-analyzers borrow their owner and must not outlive it. This mutable object must not be queried or synchronized concurrently from multiple threads.
| tvm::sym::AnalyzerObj::AnalyzerObj | ( | ) |
Construct an analyzer with no accepted premises and default query settings.
| bool tvm::sym::AnalyzerObj::CanProve | ( | const PrimExpr & | cond, |
| ProofStrength | strength = ProofStrength::kDefault |
||
| ) |
Attempt to prove a condition under the current premises.
| cond | The expression to be proved. |
| strength | Proof effort; kSymbolicBound additionally enables symbolic bound analysis. |
Attempt to prove lhs == rhs.
| lhs | The input lhs. |
| rhs | The input rhs. |
| bool tvm::sym::AnalyzerObj::CanProveGreaterEqual | ( | const PrimExpr & | expr, |
| int64_t | lower_bound | ||
| ) |
Attempt to prove expr >= lower_bound.
Bounds help distinguish truncating and floor division/remainder semantics.
| expr | The expression. |
| lower_bound | The lower bound. |
| bool tvm::sym::AnalyzerObj::CanProveLess | ( | const PrimExpr & | expr, |
| int64_t | upper_bound | ||
| ) |
Attempt to prove expr < upper_bound.
Bounds help distinguish truncating and floor division/remainder semantics.
| expr | The expression. |
| upper_bound | The upper bound. |
| bool tvm::sym::AnalyzerObj::CanProveLessEqualThanSymbolicShapeValue | ( | const PrimExpr & | lhs, |
| const PrimExpr & | shape | ||
| ) |
Attempt to prove lhs <= a possibly symbolic shape.
By calling this function, the caller gives an extra hint that shape > 0, because it appeared in buffer shape.
This is useful to prove condition such as 32 <= 32 * n where the 32 * n is known to be a shape. Use this routine to reduce the symbolic comparisons in buffer compaction.
The underlying analyzer will use the kSymbolicBound proof.
| lhs | The input lhs. |
| shape | The symbolic shape. |
| Analyzer tvm::sym::AnalyzerObj::Clone | ( | ) | const |
Copy accepted facts and query settings into an independent analyzer.
Backend state is independent: subsequent synchronization, simplification, and query settings on either analyzer do not affect the other. Premise and expression nodes are shared and must not be mutated through aliases. Query scratch, solver instances, and accumulated statistics are not copied. Copying an Analyzer handle alone instead shares the same mutable state.
| ConstraintContext tvm::sym::AnalyzerObj::GetConstraintContext | ( | ) | const |
Snapshot the accepted premise environment.
| void tvm::sym::AnalyzerObj::SetZ3DefaultFallback | ( | bool | enabled | ) |
Set whether DEFAULT-strength queries try Z3 after native analysis fails.
Enabled by default. This setting is local to the analyzer and preserved by Clone. Stronger proof queries and direct Z3 APIs are unaffected. Disabling the fallback does not clear accepted premises or existing solver state.
| enabled | Whether to allow the DEFAULT-strength Z3 fallback. |
Simplify expr.
| expr | The expression to be simplified. |
| steps | Number of alternating rewrite/canonical passes after an initial canonical pass. The default of two runs canonical, rewrite, then canonical. Nonpositive values run only the initial canonical pass. Processing may stop early at a constant expression. |
| void tvm::sym::AnalyzerObj::SyncConstraintContext | ( | const ConstraintContext & | context | ) |
Synchronize all derived facts to the supplied premise environment.
Unchanged positions need no replay; recognized additive prefixes update incrementally, and other transitions clear and replay all backends. Query settings and cumulative rewrite counters survive synchronization.
The context must bind each Var identity at most once across value and range bindings. Unsupported or effectful premises may be ignored conservatively. Captured constraint and expression nodes must not be mutated through aliases. Appending to the caller's context after this call takes effect only after a later synchronization. Synchronization during a query or another synchronization is rejected. If ingestion throws, discard this analyzer: partially applied backend state is not rolled back.
| context | Ordered premises to snapshot and accept. |
| tvm::sym::AnalyzerObj::TVM_FFI_DECLARE_OBJECT_INFO_FINAL | ( | "sym.Analyzer" | , |
| AnalyzerObj | , | ||
| ffi::Object | |||
| ) |
|
friend |
|
staticconstexpr |
Analyzer methods update facts, constraints, caches, and stats.
Marking the object mutable makes the Analyzer ObjectRef expose a non-const operator->, so APIs can take const Analyzer& while still allowing calls such as analyzer->SyncConstraintContext(...). const Analyzer& keeps the handle itself from being rebound; it does not make the underlying AnalyzerObj immutable.
| CanonicalSimplifier tvm::sym::AnalyzerObj::canonical_simplify |
sub-analyzer canonical simplify
| ConstIntBoundAnalyzer tvm::sym::AnalyzerObj::const_int_bound |
sub-analyzer: const integer bound
| IntSetAnalyzer tvm::sym::AnalyzerObj::int_set |
sub-analyzer: int set
| ModularSetAnalyzer tvm::sym::AnalyzerObj::modular_set |
sub-analyzer: modular set
| RewriteSimplifier tvm::sym::AnalyzerObj::rewrite_simplify |
sub-analyzer rewrite simplify
| Z3Prover tvm::sym::AnalyzerObj::z3_prover |
sub-analyzer using Z3