Tenncor
|
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 ®istry=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... | |
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
using opt::CandArgsT = typedef std::vector<CandArg> |
Vector of candidate arguments.
using opt::CandsT = typedef std::unordered_map<Symbol,CtxsT,SymbolHash> |
Map of convers symbols to its potential candidate conversion rules.
using opt::ContexT = typedef std::map<std::string,CtxValT> |
Map of rule graph leaf identifiers to corresponding matches.
using opt::ConvptrT = typedef std::shared_ptr<iConverter> |
Smart pointer of converter.
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
using opt::CtxsT = typedef std::unordered_set<ContexT,boost::hash<ContexT> > |
Set of contexts that serve as a candidates of a conversion rule.
using opt::CtxValT = typedef std::set<teq::TensptrT> |
Set of tensors that potentially matches some id.
using opt::HFunctorsT = typedef std::vector<std::vector<teq::FuncptrT> > |
Matrix of functors.
using opt::ImmutablesT = typedef std::vector<teq::LeafptrT> |
Vector of presumably immutable leaves.
using opt::VoterArgsT = typedef std::vector<VoterArg> |
Vector of voter arguments for branching nodes.
using opt::VotptrT = typedef std::shared_ptr<iVoter> |
Smart pointer of rule tree.
enum opt::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. |
bool opt::is_equal | ( | teq::CoordptrT | a, |
teq::CoordptrT | b | ||
) |
Return true if a is equal to b.
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
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
bool opt::is_scalar | ( | teq::iLeaf * | leaf | ) |
Return true if leaf contains a scalar.
bool opt::lt | ( | teq::CoordptrT | a, |
teq::CoordptrT | b | ||
) |
Return true if a < b according to some internal ordinal rule.
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
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
|
inline |
Compare equality of ordered voter arguments.
Compare equality of commutative arguments.
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)
OptCtx opt::parse | ( | std::string | content, |
const iConverterBuilder & | builder | ||
) |
Return all parsed optimization rules of string content.
OptCtx opt::parse_file | ( | std::string | filename, |
const iConverterBuilder & | builder | ||
) |
Return all parsed optimization rules of a file.
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
void opt::remove_all_duplicates | ( | teq::TensptrsT & | roots, |
ImmutablesT & | immutables, | ||
HFunctorsT & | functors | ||
) |
Delete and update equivalent immutable leaves and functors according to remove_duplicates
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
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
void opt::sort_vargs | ( | VoterArgsT & | args | ) |
Normalize voter arguments to facilitate matching.
std::string opt::to_string | ( | teq::CoordptrT | c | ) |
Return brief hashable string representation of coordinate mapper.
const std::string opt::group_prefix = "group:" |
String to prefix group types.