TVM  0.9.4
tvm::internal::VariableCountingVector Class Reference

#include <tvm/internal/VariableCountingVector.h>

Public Member Functions

 VariableCountingVector (bool split=false)
 
bool add (VariablePtr v)
 
void add (const VariableVector &v)
 
bool remove (const Variable &v)
 
void remove (const VariableVector &v)
 
void clear ()
 
void set (const VectorConstRef &val)
 
const VariableVectorvariables () const
 
const std::vector< uint8_t > simple () const
 
bool split () const
 
bool isDisjointUnion ()
 

Detailed Description

This class adds a counting logic over a VariableVector, that allows to add and remove subvariables without constraints, and tracks exactly how many time a (part of) variable was added and removed. This is in particular useful for computing the variables of a problem, where different part of a same variables can be added by different functions.

This class is used in places where one must deduce a VariableVector from the union of several variables or collections of variables with no constraints on how these variables relate to one another (in particular intersecting subvariables can be used). The process is then:

Constructor & Destructor Documentation

◆ VariableCountingVector()

tvm::internal::VariableCountingVector::VariableCountingVector ( bool  split = false)
inline
Parameters
splitIf true, variable parts who do not appear with the same count or were not added at the same time are separated. For example, if x is a variable of size 8, adding x[0:3] then x[4:7] will yield a single variable (x) when split = false but two variables (x[0:3], x[4:7]) otherwise. Adding x[0:4] then x[3:7] will also yield a single variable if split = false but 3 variables (x[0:2], x[3:4] and x[5:7]) otherwise.

Member Function Documentation

◆ add() [1/2]

void tvm::internal::VariableCountingVector::add ( const VariableVector v)

◆ add() [2/2]

bool tvm::internal::VariableCountingVector::add ( VariablePtr  v)

Add a variable. Return true if this changes the vector.

◆ clear()

void tvm::internal::VariableCountingVector::clear ( )

◆ isDisjointUnion()

bool tvm::internal::VariableCountingVector::isDisjointUnion ( )

Check that none of the added variables intersect.

◆ remove() [1/2]

bool tvm::internal::VariableCountingVector::remove ( const Variable v)

Remove a variable. Return true if this changes the vector.

◆ remove() [2/2]

void tvm::internal::VariableCountingVector::remove ( const VariableVector v)

◆ set()

void tvm::internal::VariableCountingVector::set ( const VectorConstRef val)

◆ simple()

const std::vector<uint8_t> tvm::internal::VariableCountingVector::simple ( ) const

Return a vector mirroring variables() where simple()[i] is true when variables()[i] appears because of a single initial add (even if the same variable was subsequently added/removed several times after or subvariables of it were added/removed).

This is conservative in the sense that some combinations of add/remove that would end up with a variable abiding the above criterion could be flagged as false. When using only add, this is exact, though.

Note
Only for VariableCountingVector with split = false

◆ split()

bool tvm::internal::VariableCountingVector::split ( ) const
inline

◆ variables()

const VariableVector& tvm::internal::VariableCountingVector::variables ( ) const

Return the vector of variables resulting from the different add and remove.


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