Tenncor
Classes | Typedefs | Enumerations | Functions | Variables
opt Namespace Reference

Classes

struct  CandArg
 Encapsulation of match output argument. More...
 
struct  CommHasher
 Hash variadic/commutative arguments that ignores order. More...
 
struct  CommVoter
 Implement voter for commutative functors. More...
 
struct  iConverter
 Converter interface for building TEQ graphs. More...
 
struct  iConverterBuilder
 Interface for TEQ extensions to construct conversion rules. More...
 
struct  iVoter
 Rule tree node that identify and selects matching candidates. More...
 
struct  Matcher
 
struct  OptCtx
 Encapsulation of all conversion rules. More...
 
struct  OrdrHasher
 Hash voter arguments while preserving order of arguments. More...
 
struct  OrdrVoter
 Implement voter for ordered (non-commutative) functors. More...
 
struct  RulesContext
 Global statements shared between all rule statements. More...
 
struct  SegVArgs
 Variadic/communtative branch voter arguments. More...
 
struct  Symbol
 Generic representation of a conversion rule. More...
 
struct  SymbolHash
 Hasher to encode rule key. More...
 
struct  VariadicVoter
 Implement voter for variadic groups. More...
 
struct  VoterArg
 Argument voter for functors. More...
 
struct  VoterPool
 Parsed representation of a rule tree. More...
 

Typedefs

using CtxValT = std::set< teq::TensptrT >
 Set of tensors that potentially matches some id. More...
 
using ContexT = std::map< std::string, CtxValT >
 Map of rule graph leaf identifiers to corresponding matches. More...
 
using CtxsT = std::unordered_set< ContexT, boost::hash< ContexT > >
 Set of contexts that serve as a candidates of a conversion rule. More...
 
using CandsT = std::unordered_map< Symbol, CtxsT, SymbolHash >
 Map of convers symbols to its potential candidate conversion rules. More...
 
using CandArgsT = std::vector< CandArg >
 Vector of candidate arguments. More...
 
using ConvptrT = std::shared_ptr< iConverter >
 Smart pointer of converter. More...
 
using VoterArgsT = std::vector< VoterArg >
 Vector of voter arguments for branching nodes. More...
 
using VotptrT = std::shared_ptr< iVoter >
 Smart pointer of rule tree. More...
 
using CstConvertF = std::function< teq::TensptrT(teq::iTensor *)>
 
using ImmutablesT = std::vector< teq::LeafptrT >
 Vector of presumably immutable leaves. More...
 
using HFunctorsT = std::vector< std::vector< teq::FuncptrT > >
 Matrix of functors. More...
 

Enumerations

enum  CAND_TYPE { SCALAR = 0, CONST, INTERM, CONVRT }
 Conversion type. More...
 

Functions

bool operator== (const Symbol &lhs, const Symbol &rhs)
 Compare equality of Symbols. More...
 
void sort_vargs (VoterArgsT &args)
 Normalize voter arguments to facilitate matching. More...
 
bool operator== (const VoterArgsT &lhs, const VoterArgsT &rhs)
 Compare equality of ordered voter arguments. More...
 
bool operator== (const SegVArgs &lhs, const SegVArgs &rhs)
 Compare equality of commutative arguments. More...
 
teq::TensptrsT optimize (teq::TensptrsT roots, const OptCtx &opts)
 
OptCtx parse (std::string content, const iConverterBuilder &builder)
 Return all parsed optimization rules of string content. More...
 
OptCtx parse_file (std::string filename, const iConverterBuilder &builder)
 Return all parsed optimization rules of a file. More...
 
void replace_parents (const teq::ParentFinder &pfinder, teq::iTensor *source, teq::TensptrT target)
 
template<typename T >
std::vector< T > remove_duplicates (teq::TensptrsT &roots, std::vector< T > tens, const teq::ParentFinder &pfinder, tag::TagRegistry &registry=tag::get_reg())
 
void populate_graph (ImmutablesT &immutables, HFunctorsT &functors, const teq::TensptrsT &roots)
 
void remove_all_duplicates (teq::TensptrsT &roots, ImmutablesT &immutables, HFunctorsT &functors)
 
bool is_scalar (teq::iLeaf *leaf)
 Return true if leaf contains a scalar. More...
 
std::string to_string (teq::CoordptrT c)
 Return brief hashable string representation of coordinate mapper. More...
 
bool lt (teq::CoordptrT a, teq::CoordptrT b)
 Return true if a < b according to some internal ordinal rule. More...
 
bool is_equal (teq::CoordptrT a, teq::CoordptrT b)
 Return true if a is equal to b. More...
 
bool lt (teq::TensSetT priorities, teq::iLeaf *a, teq::iLeaf *b)
 
bool is_equal (teq::iLeaf *a, teq::iLeaf *b)
 
bool lt (teq::TensSetT priorities, teq::iFunctor *a, teq::iFunctor *b)
 
bool is_equal (teq::iFunctor *a, teq::iFunctor *b)
 

Variables

const std::string group_prefix = "group:"
 String to prefix group types. More...
 

Detailed Description

candidate.hpp opt

Purpose: Define TEQ graph intermediate representations

iconverter.hpp opt

Purpose: Define converter interface for building TEQ graphs given candidate IR graph

ivoter.hpp opt

Purpose: Define rule voter interface to identify graph nodes

matcher.hpp opt

Purpose: Implement matcher traveler for gathering conversion candidates from a TEQ graph

optimize.hpp opt

Purpose: Implement algorithm that applies conversion rules to graph roots

parse.hpp opt

Purpose: Define interfaces to build extensions of TEQ graphs and wrap around C parser

rmdups.hpp opt

Purpose: Define TEQ functor duplication removal algorithm

stats.hpp opt

Purpose: Define comparator and conversion for TEQ objects for OPT normalization and logging

voter.hpp opt

Purpose: Implement rule voter to identify functor types

Typedef Documentation

◆ CandArgsT

using opt::CandArgsT = typedef std::vector<CandArg>

Vector of candidate arguments.

◆ CandsT

using opt::CandsT = typedef std::unordered_map<Symbol,CtxsT,SymbolHash>

Map of convers symbols to its potential candidate conversion rules.

◆ ContexT

using opt::ContexT = typedef std::map<std::string,CtxValT>

Map of rule graph leaf identifiers to corresponding matches.

◆ ConvptrT

using opt::ConvptrT = typedef std::shared_ptr<iConverter>

Smart pointer of converter.

◆ CstConvertF

using opt::CstConvertF = typedef std::function<teq::TensptrT(teq::iTensor*)>

Function that takes raw tensor pointer and cast to constant tensor If input tensor is not constant return null

◆ CtxsT

using opt::CtxsT = typedef std::unordered_set<ContexT,boost::hash<ContexT> >

Set of contexts that serve as a candidates of a conversion rule.

◆ CtxValT

using opt::CtxValT = typedef std::set<teq::TensptrT>

Set of tensors that potentially matches some id.

◆ HFunctorsT

using opt::HFunctorsT = typedef std::vector<std::vector<teq::FuncptrT> >

Matrix of functors.

◆ ImmutablesT

using opt::ImmutablesT = typedef std::vector<teq::LeafptrT>

Vector of presumably immutable leaves.

◆ VoterArgsT

using opt::VoterArgsT = typedef std::vector<VoterArg>

Vector of voter arguments for branching nodes.

◆ VotptrT

using opt::VotptrT = typedef std::shared_ptr<iVoter>

Smart pointer of rule tree.

Enumeration Type Documentation

◆ CAND_TYPE

Conversion type.

Enumerator
SCALAR 

Convert to a scalar.

CONST 

Convert to a non-scalar constant.

INTERM 

Intermediate conversion.

CONVRT 

Full conversion to a subgraph.

Function Documentation

◆ is_equal() [1/3]

bool opt::is_equal ( teq::CoordptrT  a,
teq::CoordptrT  b 
)

Return true if a is equal to b.

◆ is_equal() [2/3]

bool opt::is_equal ( teq::iLeaf a,
teq::iLeaf b 
)

Return true if a and b are both tagged immutable and share the same shape and data values

◆ is_equal() [3/3]

bool opt::is_equal ( teq::iFunctor a,
teq::iFunctor b 
)

Return true if a and b are the same opcode and have identical function arguments (same children, shapers, and coorders) Argument order matters unless the op is tagged as commutative

◆ is_scalar()

bool opt::is_scalar ( teq::iLeaf leaf)

Return true if leaf contains a scalar.

◆ lt() [1/3]

bool opt::lt ( teq::CoordptrT  a,
teq::CoordptrT  b 
)

Return true if a < b according to some internal ordinal rule.

◆ lt() [2/3]

bool opt::lt ( teq::TensSetT  priorities,
teq::iLeaf a,
teq::iLeaf b 
)

Return true if a.type_code < b.type_code or a.shape < b.shape if all above properties are equal, return true if a is in priorities otherwise false

◆ lt() [3/3]

bool opt::lt ( teq::TensSetT  priorities,
teq::iFunctor a,
teq::iFunctor b 
)

Return true if a.opcode < b.opcode or a.shape < b.shape or a.nchildren < b.nchildren if all above properties are equal, return true if a is in priorities otherwise false

◆ operator==() [1/3]

bool opt::operator== ( const Symbol lhs,
const Symbol rhs 
)
inline

Compare equality of Symbols.

◆ operator==() [2/3]

bool opt::operator== ( const VoterArgsT lhs,
const VoterArgsT rhs 
)
inline

Compare equality of ordered voter arguments.

◆ operator==() [3/3]

bool opt::operator== ( const SegVArgs lhs,
const SegVArgs rhs 
)
inline

Compare equality of commutative arguments.

◆ optimize()

teq::TensptrsT opt::optimize ( teq::TensptrsT  roots,
const OptCtx opts 
)

Return optimized roots where optimization rules are applied to subgraphs Optimized graph roots are moved back to their corresponding root tensors Additionally two or more tensors sharing symbolically identical representations are "joined" (with the exception of tensors in roots set)

◆ parse()

OptCtx opt::parse ( std::string  content,
const iConverterBuilder builder 
)

Return all parsed optimization rules of string content.

◆ parse_file()

OptCtx opt::parse_file ( std::string  filename,
const iConverterBuilder builder 
)

Return all parsed optimization rules of a file.

◆ populate_graph()

void opt::populate_graph ( ImmutablesT immutables,
HFunctorsT functors,
const teq::TensptrsT roots 
)

Populate immutables with immutable leaves and functors with functors ordered by functor max height in ascending order

◆ remove_all_duplicates()

void opt::remove_all_duplicates ( teq::TensptrsT roots,
ImmutablesT immutables,
HFunctorsT functors 
)

Delete and update equivalent immutable leaves and functors according to remove_duplicates

◆ remove_duplicates()

template<typename T >
std::vector<T> opt::remove_duplicates ( teq::TensptrsT roots,
std::vector< T >  tens,
const teq::ParentFinder pfinder,
tag::TagRegistry registry = tag::get_reg() 
)

Return non-duplicate nodes of a HeightMatrix row (tens) If T is a functor, a functor X is duplicate if their any of their child have another parent of the same opcode as X that has identical arguments as X (order matters if X is non-commutative) If T is a leaf, a leaf X is duplicate if the leaf is a constant and there exists another constant that has the same shape and data

◆ replace_parents()

void opt::replace_parents ( const teq::ParentFinder pfinder,
teq::iTensor source,
teq::TensptrT  target 
)

Replace source tensor's position with target's position in the sense that all parents of source (found in pfinder) take on target as the new child in place of source's

◆ sort_vargs()

void opt::sort_vargs ( VoterArgsT args)

Normalize voter arguments to facilitate matching.

◆ to_string()

std::string opt::to_string ( teq::CoordptrT  c)

Return brief hashable string representation of coordinate mapper.

Variable Documentation

◆ group_prefix

const std::string opt::group_prefix = "group:"

String to prefix group types.