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

Tracks the constraints relevant to each point in a traversal. More...

#include <constraint.h>

Inheritance diagram for tvm::sym::ConstraintContextObj:
Collaboration diagram for tvm::sym::ConstraintContextObj:

Public Member Functions

 ConstraintContextObj ()=default
 Construct an empty root context.
 
 ConstraintContextObj (ffi::ObjectPtr< ConstraintContextObj > parent, int64_t parent_prefix_size)
 Capture an inherited prefix and start an empty local sequence.
 
 ConstraintContextObj (const ConstraintContextObj &)=delete
 
ConstraintContextObj & operator= (const ConstraintContextObj &)=delete
 
void Append (const Constraint &constraint)
 Append a premise locally, preserving every previously captured prefix.
 
int64_t LocalSize () const
 Count the local entries.
 
ConstraintContext Snapshot () const
 Captures the constraints currently visible in this context. Later additions to this context do not affect the returned context, which can be extended independently. Constraint objects and referenced expressions remain shared. For an existing integer expression x:
 
template<typename F >
void ForEach (F &&f) const
 Read constraints in inherited/local order. Later appends do not enter this iteration. The reference passed to the callback is valid only during that invocation; copy the handle to retain the premise.
 
ffi::Array< Constraint > ToArray () const
 Returns an independent array of the constraints in this context. Includes inherited constraints in order. Later additions to the context do not change the returned array. Edits to the array do not change this context. Constraint objects remain shared and must not be mutated through aliases.
 
 TVM_FFI_DECLARE_OBJECT_INFO_FINAL ("sym.ConstraintContext", ConstraintContextObj, ffi::Object)
 

Static Public Member Functions

static void RegisterReflection ()
 Register the context methods exposed through FFI reflection.
 

Static Public Attributes

static constexpr bool _type_mutable = true
 Allow appending through a const context handle.
 

Friends

class AnalyzerObj
 

Detailed Description

Tracks the constraints relevant to each point in a traversal.

Holds variable bindings, value ranges, and predicates collected during traversal. Callbacks can inspect these constraints when processing the current expression or statement. Captured constraint and expression nodes must not be changed through aliases: appending preserves earlier prefixes, but snapshots do not deep-copy their contents.

Constructor & Destructor Documentation

◆ ConstraintContextObj() [1/3]

tvm::sym::ConstraintContextObj::ConstraintContextObj ( )
default

Construct an empty root context.

◆ ConstraintContextObj() [2/3]

tvm::sym::ConstraintContextObj::ConstraintContextObj ( ffi::ObjectPtr< ConstraintContextObj >  parent,
int64_t  parent_prefix_size 
)
inline

Capture an inherited prefix and start an empty local sequence.

Parameters
parentNon-null parent context.
parent_prefix_sizeNumber of parent-local entries to capture.
Exceptions
ffi::ErrorIf parent is null or the prefix is outside [0, parent->LocalSize()].

◆ ConstraintContextObj() [3/3]

tvm::sym::ConstraintContextObj::ConstraintContextObj ( const ConstraintContextObj &  )
delete

Member Function Documentation

◆ Append()

void tvm::sym::ConstraintContextObj::Append ( const Constraint &  constraint)
inline

Append a premise locally, preserving every previously captured prefix.

Parameters
constraintPremise to retain as supplied, without validation or inference. Its node and referenced expressions must not later be mutated through aliases.

◆ ForEach()

template<typename F >
void tvm::sym::ConstraintContextObj::ForEach ( F &&  f) const
inline

Read constraints in inherited/local order. Later appends do not enter this iteration. The reference passed to the callback is valid only during that invocation; copy the handle to retain the premise.

Template Parameters
FCallable accepting a const Constraint&.
Parameters
fCallback invoked once per captured premise, in inherited/local order.

◆ LocalSize()

int64_t tvm::sym::ConstraintContextObj::LocalSize ( ) const
inline

Count the local entries.

Returns
Local sequence length, excluding captured ancestors.

◆ operator=()

ConstraintContextObj & tvm::sym::ConstraintContextObj::operator= ( const ConstraintContextObj &  )
delete

◆ RegisterReflection()

static void tvm::sym::ConstraintContextObj::RegisterReflection ( )
static

Register the context methods exposed through FFI reflection.

◆ Snapshot()

ConstraintContext tvm::sym::ConstraintContextObj::Snapshot ( ) const
inline

Captures the constraints currently visible in this context. Later additions to this context do not affect the returned context, which can be extended independently. Constraint objects and referenced expressions remain shared. For an existing integer expression x:

context->Append(sym::PredicateConstraint(x >= 0));
auto saved = context->Snapshot();
context->Append(sym::PredicateConstraint(x < 16));
// saved contains x >= 0; context contains both predicates.
Managed reference to ConstraintContextObj. Copies share the same context.
Definition constraint.h:306
Managed reference to PredicateConstraintObj.
Definition constraint.h:170
Returns
An independently extensible context capturing the current prefix.

◆ ToArray()

ffi::Array< Constraint > tvm::sym::ConstraintContextObj::ToArray ( ) const
inline

Returns an independent array of the constraints in this context. Includes inherited constraints in order. Later additions to the context do not change the returned array. Edits to the array do not change this context. Constraint objects remain shared and must not be mutated through aliases.

Returns
A copy-on-write array containing the captured premises.

◆ TVM_FFI_DECLARE_OBJECT_INFO_FINAL()

tvm::sym::ConstraintContextObj::TVM_FFI_DECLARE_OBJECT_INFO_FINAL ( "sym.ConstraintContext"  ,
ConstraintContextObj  ,
ffi::Object   
)

Friends And Related Symbol Documentation

◆ AnalyzerObj

friend class AnalyzerObj
friend

Member Data Documentation

◆ _type_mutable

constexpr bool tvm::sym::ConstraintContextObj::_type_mutable = true
staticconstexpr

Allow appending through a const context handle.


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