tvm
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
tvm::sym::AnalyzerObj Class Reference

Coordinated symbolic analyses over an explicitly synchronized premise environment. More...

#include <analyzer.h>

Inheritance diagram for tvm::sym::AnalyzerObj:
Collaboration diagram for tvm::sym::AnalyzerObj:

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AnalyzerObj()

tvm::sym::AnalyzerObj::AnalyzerObj ( )

Construct an analyzer with no accepted premises and default query settings.

Member Function Documentation

◆ CanProve()

bool tvm::sym::AnalyzerObj::CanProve ( const PrimExpr &  cond,
ProofStrength  strength = ProofStrength::kDefault 
)

Attempt to prove a condition under the current premises.

Parameters
condThe expression to be proved.
strengthProof effort; kSymbolicBound additionally enables symbolic bound analysis.
Returns
True if proved; false includes unsupported or inconclusive queries.
Note
Analyzer will call into sub-analyzers to get the result. Do not use strength beyond default in sub-analyzers and only use it in top-level predicate analysis. When built with Z3, all strengths try it after native analysis fails. SetZ3DefaultFallback(false) disables this fallback only for DEFAULT-strength queries. Z3's existing resource limit and timeout apply; unknown means cannot prove.

◆ CanProveEqual()

bool tvm::sym::AnalyzerObj::CanProveEqual ( const PrimExpr &  lhs,
const PrimExpr &  rhs 
)

Attempt to prove lhs == rhs.

Parameters
lhsThe input lhs.
rhsThe input rhs.
Returns
True if equality is proved; false does not establish inequality.
Note
Analyzer will call into sub-analyzers to get the result.

◆ CanProveGreaterEqual()

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.

Parameters
exprThe expression.
lower_boundThe lower bound.
Returns
True if proved; false if unknown or false.
Note
Analyzer will call into sub-analyzers to get the result.

◆ CanProveLess()

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.

Parameters
exprThe expression.
upper_boundThe upper bound.
Returns
True if proved; false if unknown or false.
Note
Analyzer will call into sub-analyzers to get the result.

◆ CanProveLessEqualThanSymbolicShapeValue()

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.

Parameters
lhsThe input lhs.
shapeThe symbolic shape.
Returns
True if proved using the caller's positive-shape guarantee; false otherwise.

◆ Clone()

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.

Returns
A new analyzer with independent backend state and the same accepted premises.

◆ GetConstraintContext()

ConstraintContext tvm::sym::AnalyzerObj::GetConstraintContext ( ) const

Snapshot the accepted premise environment.

Returns
A context that can be extended independently. Constraint and expression nodes are shared and must not be mutated through aliases. Appending to this context does not update the analyzer until SyncConstraintContext is called.

◆ SetZ3DefaultFallback()

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.

Parameters
enabledWhether to allow the DEFAULT-strength Z3 fallback.

◆ Simplify()

PrimExpr tvm::sym::AnalyzerObj::Simplify ( const PrimExpr &  expr,
int  steps = 2 
)

Simplify expr.

Parameters
exprThe expression to be simplified.
stepsNumber 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.
Returns
An equivalent expression under the current premises.
Note
Analyzer will call into sub-analyzers to get the result.

◆ SyncConstraintContext()

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.

Parameters
contextOrdered premises to snapshot and accept.
Exceptions
ffi::ErrorIf bindings repeat a Var identity, synchronization is reentrant, or an analyzer invariant fails. Backend ingestion errors may also propagate.

◆ TVM_FFI_DECLARE_OBJECT_INFO_FINAL()

tvm::sym::AnalyzerObj::TVM_FFI_DECLARE_OBJECT_INFO_FINAL ( "sym.Analyzer"  ,
AnalyzerObj  ,
ffi::Object   
)

Friends And Related Symbol Documentation

◆ detail::TempConstraintScope

friend class detail::TempConstraintScope
friend

Member Data Documentation

◆ _type_mutable

constexpr bool tvm::sym::AnalyzerObj::_type_mutable = true
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.

◆ canonical_simplify

CanonicalSimplifier tvm::sym::AnalyzerObj::canonical_simplify

sub-analyzer canonical simplify

◆ const_int_bound

ConstIntBoundAnalyzer tvm::sym::AnalyzerObj::const_int_bound

sub-analyzer: const integer bound

◆ int_set

IntSetAnalyzer tvm::sym::AnalyzerObj::int_set

sub-analyzer: int set

◆ modular_set

ModularSetAnalyzer tvm::sym::AnalyzerObj::modular_set

sub-analyzer: modular set

◆ rewrite_simplify

RewriteSimplifier tvm::sym::AnalyzerObj::rewrite_simplify

sub-analyzer rewrite simplify

◆ z3_prover

Z3Prover tvm::sym::AnalyzerObj::z3_prover

sub-analyzer using Z3


The documentation for this class was generated from the following file: