8 #include <boost/uuid/uuid.hpp> 9 #include <boost/uuid/uuid_generators.hpp> 10 #include <boost/uuid/uuid_io.hpp> 21 using TensSetT = std::unordered_set<TensKey,TensKeyHash>;
42 std::set<std::string>& olabels =
44 labels_.insert(olabels.begin(), olabels.end());
68 auto it = gtens.find(
TensKey(tens.lock().get()));
70 if (gtens.end() != it && it->expired())
72 gtens.erase(tens.lock().get());
78 std::unordered_map<std::string,TensSetT>
groups_;
102 using AGroupsT = std::map<std::string,std::unordered_set<std::string>>;
105 using AdjMapT = std::unordered_map<teq::iTensor*,AGroupsT>;
120 if (
false == estd::has(
content_, leaf))
130 if (
false == estd::has(
content_, func))
136 for (
auto& child : children)
138 auto tens = child.get_tensor();
139 if (
false == estd::has(
content_, tens.get()))
155 std::unordered_map<teq::iTensor*,teq::TensptrT>
children_;
178 #endif // TAG_GROUP_HPP std::unordered_set< teq::iTensor * > TensSetT
Hash set of raw tensor pointers.
Definition: itensor.hpp:63
void visit(teq::iLeaf *leaf) override
Implementation of iTraveler.
Definition: group.hpp:118
void beautify_groups(SubgraphAssocsT &out, const AdjMapT &adjs)
void absorb(TagptrT &&other) override
Implementation of iTag.
Definition: group.hpp:40
virtual const ArgsT & get_children(void) const =0
Return children nodes as a vector of raw pointers.
std::unordered_map< teq::iTensor *, teq::TensptrT > children_
Children of the group.
Definition: group.hpp:155
const std::string groups_key
Identifier of groups tag.
Definition: group.hpp:88
Subgraph(std::string group)
Definition: group.hpp:115
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
Registry for associating tensors to tag collectives.
Definition: tag.hpp:165
GroupTag(std::string init_label)
Definition: group.hpp:31
std::unordered_map< teq::iTensor *, AGroupsT > AdjMapT
Map tensors to groups.
Definition: group.hpp:105
void visit(teq::iFunctor *func) override
Implementation of iTraveler.
Definition: group.hpp:128
GroupRegistry(TagRegistry ®istry=get_reg())
Definition: group.hpp:60
std::unique_ptr< iTag > TagptrT
Unique pointer of tag.
Definition: tag.hpp:40
void adjacencies(AdjMapT &out, teq::TensptrsT roots, GroupRegistry ®istry=get_group_reg())
std::map< std::string, std::vector< std::string > > TagRepsT
Map tag key to a series of labels.
Definition: tag.hpp:21
Subgraph group encapsulation.
Definition: group.hpp:113
std::string register_tagr(std::string tag_key, TagrF tagr)
Definition: tag.hpp:232
std::string group_
Group label.
Definition: group.hpp:148
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
size_t tag_id(void) const override
Implementation of iTag.
Definition: group.hpp:34
std::unordered_set< SgraphptrT > SubgraphsT
Set of subgraphs.
Definition: group.hpp:162
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
std::vector< TensptrT > TensptrsT
Vector of tensor smart pointers.
Definition: itensor.hpp:60
TagRegistry & tag_reg_
Internal tag registry used to retrieve tensor-group association.
Definition: group.hpp:81
Tensor ref key wrapper.
Definition: tag.hpp:114
TagRegistry & get_reg(void)
Return reference to global tag registry.
void recursive_group_tag(teq::TensptrT tens, std::string group, teq::TensSetT stops, GroupRegistry ®istry=get_group_reg())
std::map< std::string, std::unordered_set< std::string > > AGroupsT
Definition: group.hpp:102
void group_tag(teq::TensrefT tens, std::string tag)
Bidirectionally assocate tensor and group.
Definition: group.hpp:63
teq::TensSetT content_
Group content.
Definition: group.hpp:151
void filter_head(SubgraphAssocsT &out, const SubgraphAssocsT &assocs)
void add_tag(teq::TensrefT tens, TagptrT tag)
Add tag to collective referenced by tens.
Definition: tag.hpp:168
GroupRegistry & get_group_reg(void)
Return reference to global group registry.
std::unordered_set< TensKey, TensKeyHash > TensSetT
Tensor ref set.
Definition: group.hpp:21
std::shared_ptr< Subgraph > SgraphptrT
Smart pointer of the subgraph.
Definition: group.hpp:159
TagRepsT get_tags(void) const override
Implementation of iTag.
std::weak_ptr< iTensor > TensrefT
Tensor weak pointers.
Definition: itensor.hpp:54
std::unordered_map< std::string, TensSetT > groups_
Map group label to tensors.
Definition: group.hpp:78
static size_t tag_id_
Definition: group.hpp:53
std::set< std::string > labels_
Definition: group.hpp:51
Leaf of the graph commonly representing the variable in an equation.
Definition: ileaf.hpp:19