TVM  0.9.4
tvm::internal::VariableVectorPartition< VarVector > Class Template Reference

#include <tvm/internal/VariableVectorPartition.h>

Classes

class  iterator
 

Public Member Functions

 VariableVectorPartition (const VarVector &v, const VariableCountingVector &partition)
 
iterator begin ()
 
iterator end ()
 

Detailed Description

template<class VarVector>
class tvm::internal::VariableVectorPartition< VarVector >

A helper class to iterate over a container of VariablePtr c where the variables are split according to a given partition p expressed as a VariableCountingVector. The iteration is made over c, but the iterator points to (sub)variables in p.

For example, let's consider x, y, z, 3 variables with size 8 and x1, x2, x3 (resp. y1, y2, y3 and z1, z2, z3) such that x = [x1,x2,x3] (same for y and z). If u is a subvariable of x such that u = x2, v = y and w is a subvariable of z such that w = [z2, z3], then iterating over VariableVectorPartition({w,u,v}, {x1, x2, x3, y1, y2, y3, z1, z2, z3}) will yield the sequence {z2, z3, x2, y1, y2, y3}.

  <- u->      <------- v------->      <---- w---->

<-x1-><-x2-><-x3-><-y1-><-y2-><-y3-><-z1-><-z2-><-z3->

This is particularly useful when p is the result of the union of several collections of variables with intersecting subvariables, leading to a partition of the union with finer grain that any of the original collections. Then we can iterate over any of these collections using this class and get variables that will be either fully contained by or disjoint from any variable of any collection. As a very simplistic example, let's have x = [x1,x2,x3] and u and v two subvariables of x such that u=[x1,x2] and v=[x2,x3]. Let c1 be a collection containing u and c2 a collection containing v, and p the VariableCountingVector obtained by adding u and v. p is equivalent to [x1,x2,x3] Iterating over c1 with respect to p yields x1 then x2. Each of this variable is clearly either in or out of c2, and we can rely on that to perform computations. Likewise, iterating on c2 yields x2 then x3, which can be compared to c1.

The partition and container need to be compatible, i.e. any variable of the container can be written as a union of variables in the partition. This requirement is not fully checked.

Template Parameters
VarVectorA container of VariablePtr with begin(), end() and forward iterator.

Constructor & Destructor Documentation

◆ VariableVectorPartition()

template<class VarVector >
tvm::internal::VariableVectorPartition< VarVector >::VariableVectorPartition ( const VarVector &  v,
const VariableCountingVector partition 
)
inline
Parameters
vThe variable container we want to iterate over.
partitionThe way to split the variables. Need to have the split option on. The default use should be to put all relevant variables in partition, including all the variables in v, to make sure the partition is granularity is small enough and compatible with v.

Member Function Documentation

◆ begin()

template<class VarVector >
iterator tvm::internal::VariableVectorPartition< VarVector >::begin ( )
inline

◆ end()

template<class VarVector >
iterator tvm::internal::VariableVectorPartition< VarVector >::end ( )
inline

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