16 #ifndef OPT_MATCHER_HPP 17 #define OPT_MATCHER_HPP 55 std::string const_str = leaf->
to_string();
83 for (
auto& child : children)
85 child.get_tensor()->accept(*
this);
88 if (std::all_of(children.begin(), children.end(),
91 auto ctens = child.get_tensor().get();
98 std::string const_str = func->
to_string();
107 if (std::all_of(children.begin(), children.end(),
110 auto ctens = child.get_tensor().get();
131 args.reserve(children.size());
132 for (
auto& child : children)
134 auto ctens = child.get_tensor();
142 out_cands = it->second->inspect(
args);
158 args.reserve(children.size());
159 for (
auto& sgcpair : sg->children_)
161 auto ctens = sgcpair.second;
169 CandsT group_cands = bit->second->inspect(
args);
171 group_cands.begin(), group_cands.end());
195 #endif // OPT_MATCHER_HPP VoterPool voters_
Conversion voters to identify candidates.
Definition: matcher.hpp:181
args
Definition: csv_to_png.py:105
Convert to a non-scalar constant.
Definition: candidate.hpp:37
void visit(teq::iFunctor *func) override
Implementation of iTraveler.
Definition: matcher.hpp:78
virtual const ArgsT & get_children(void) const =0
Return children nodes as a vector of raw pointers.
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
std::unordered_map< std::string, VotptrT > branches_
Map voter identifier to associated branch voters.
Definition: ivoter.hpp:256
std::shared_ptr< iCoordMap > CoordptrT
Type of iCoordMap smartpointer.
Definition: coord.hpp:106
std::string name_
String representation of operation.
Definition: ifunctor.hpp:21
Definition: candidate.hpp:19
std::unordered_set< ContexT, boost::hash< ContexT > > CtxsT
Set of contexts that serve as a candidates of a conversion rule.
Definition: candidate.hpp:29
std::vector< CandArg > CandArgsT
Vector of candidate arguments.
Definition: candidate.hpp:95
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
CoordptrT identity
Identity matrix instance.
virtual Opcode get_opcode(void) const =0
Return operation encoding.
Interface to travel through graph, treating iLeaf and iFunctor differently.
Definition: itensor.hpp:24
std::unordered_map< teq::iTensor *, SubgraphsT > SubgraphAssocsT
Root of the subgraph associated with the subgraph representations.
Definition: group.hpp:165
std::unordered_map< Symbol, CtxsT, SymbolHash > CandsT
Map of convers symbols to its potential candidate conversion rules.
Definition: candidate.hpp:76
Encapsulation of match output argument.
Definition: candidate.hpp:79
std::function< std::string(teq::iTensor *)> scalarize_
Function that returns constant representation of tensor.
Definition: matcher.hpp:190
std::unordered_set< SgraphptrT > SubgraphsT
Set of subgraphs.
Definition: group.hpp:162
Matcher(const VoterPool &voters)
Definition: matcher.hpp:46
bool is_scalar(teq::iLeaf *leaf)
Return true if leaf contains a scalar.
std::unordered_set< std::string > immutables_
Set of immutable ids under rule tree.
Definition: ivoter.hpp:253
tag::SubgraphAssocsT group_head_
Root of grouped subgraphs.
Definition: matcher.hpp:187
Generic representation of a conversion rule.
Definition: candidate.hpp:45
virtual std::string to_string(void) const =0
Return the string representation of the tensor.
PropertyRegistry & get_property_reg(void)
Return reference to global property registry.
const std::string immutable_tag
Identifier for immutable property.
Definition: prop.hpp:20
std::unordered_map< teq::iTensor *, CandsT > candidates_
Map real TEQ tensors to candidates identified as TEQ graph is visited.
Definition: matcher.hpp:184
void visit(teq::iLeaf *leaf) override
Implementation of iTraveler.
Definition: matcher.hpp:49
std::shared_ptr< Subgraph > SgraphptrT
Smart pointer of the subgraph.
Definition: group.hpp:159
Definition: matcher.hpp:42
Definitive scalar constant.
Definition: def.h:29
const std::string group_prefix
String to prefix group types.
Definition: matcher.hpp:23
Parsed representation of a rule tree.
Definition: ivoter.hpp:250
Leaf of the graph commonly representing the variable in an equation.
Definition: ileaf.hpp:19