|
TVM
0.9.4
|
#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 VariableVector & | variables () const |
| const std::vector< uint8_t > | simple () const |
| bool | split () const |
| bool | isDisjointUnion () |
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:
|
inline |
| split | If 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. |
| void tvm::internal::VariableCountingVector::add | ( | const VariableVector & | v | ) |
| bool tvm::internal::VariableCountingVector::add | ( | VariablePtr | v | ) |
Add a variable. Return true if this changes the vector.
| void tvm::internal::VariableCountingVector::clear | ( | ) |
| bool tvm::internal::VariableCountingVector::isDisjointUnion | ( | ) |
Check that none of the added variables intersect.
| bool tvm::internal::VariableCountingVector::remove | ( | const Variable & | v | ) |
Remove a variable. Return true if this changes the vector.
| void tvm::internal::VariableCountingVector::remove | ( | const VariableVector & | v | ) |
| void tvm::internal::VariableCountingVector::set | ( | const VectorConstRef & | val | ) |
| 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.
|
inline |
| const VariableVector& tvm::internal::VariableCountingVector::variables | ( | ) | const |
Return the vector of variables resulting from the different add and remove.