ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::PGroups Struct Reference

#include <PartitionIR.h>

Public Member Functions

std::unique_ptr< PGroupsmake_copy (void) const
 return a copy of PGroups
 
GroupKey group_of (luci::CircleNode *node) const
 return group key of node, empty string if not found
 
const PGrouppgroup_of (luci::CircleNode *node) const
 return holding pgroup of node, nullptr if not found
 

Data Fields

std::vector< std::unique_ptr< PGroup > > pgroups
 
std::map< const luci::CircleNode *, GroupKeynode2group
 
std::map< uint32_t, PGroup * > id2pgroup
 
GroupKey default_group
 

Detailed Description

Definition at line 61 of file PartitionIR.h.

Member Function Documentation

◆ group_of()

GroupKey luci::PGroups::group_of ( luci::CircleNode node) const

return group key of node, empty string if not found

Definition at line 70 of file PartitionIR.cpp.

71{
72 assert(node != nullptr);
73
74 LOGGER(l);
75
76 auto it = node2group.find(node);
77 if (it == node2group.end())
78 {
79 INFO(l) << "PGroups::group_of " << node << "(" << node->name() << ") not found" << std::endl;
80 return "";
81 }
82 return it->second;
83}
#define LOGGER(name)
Definition Log.h:65
#define INFO(name)
Definition Log.h:68
NodeName name(void) const
std::map< const luci::CircleNode *, GroupKey > node2group
Definition PartitionIR.h:66

References INFO, LOGGER, luci::CircleNode::name(), and node2group.

◆ make_copy()

std::unique_ptr< PGroups > luci::PGroups::make_copy ( void  ) const

return a copy of PGroups

Definition at line 29 of file PartitionIR.cpp.

30{
31 auto d_pgroups = std::make_unique<luci::PGroups>();
32
33 for (auto &s_pgroup : pgroups)
34 {
35 // make a copy of s_pgroup to d_pgroup
36 std::unique_ptr<luci::PGroup> d_pgroup = std::make_unique<luci::PGroup>();
37
38 d_pgroup->group = s_pgroup->group;
39 d_pgroup->id = s_pgroup->id;
40
41 for (auto &pnode : s_pgroup->pnodes)
42 {
43 auto pnodec = std::make_unique<luci::PNode>();
44 pnodec->node = pnode->node;
45 pnodec->group = pnode->group;
46 pnodec->pgroup = d_pgroup.get();
47 d_pgroup->pnodes.push_back(std::move(pnodec));
48 }
49
50 for (auto &input : s_pgroup->inputs)
51 d_pgroup->inputs.push_back(input);
52
53 for (auto &output : s_pgroup->outputs)
54 d_pgroup->outputs.push_back(output);
55
56 // copy node2group
57 for (auto it = node2group.begin(); it != node2group.end(); ++it)
58 d_pgroups->node2group[it->first] = it->second;
59
60 // build id2pgroup
61 d_pgroups->id2pgroup[d_pgroup->id] = d_pgroup.get();
62
63 d_pgroups->pgroups.push_back(std::move(d_pgroup));
64 // note: d_pgroup is now nullptr as it's moved
65 }
66
67 return d_pgroups;
68}
std::vector< std::unique_ptr< PGroup > > pgroups
Definition PartitionIR.h:63

References node2group, and pgroups.

Referenced by luci::merge_pgroups().

◆ pgroup_of()

const PGroup * luci::PGroups::pgroup_of ( luci::CircleNode node) const

return holding pgroup of node, nullptr if not found

Definition at line 85 of file PartitionIR.cpp.

86{
87 assert(node != nullptr);
88
89 for (auto &pgroup : pgroups)
90 {
91 for (auto &pnode : pgroup->pnodes)
92 {
93 if (node == pnode->node)
94 return pgroup.get();
95 }
96 }
97 // node maybe graph input (CircleInput)
98 return nullptr;
99}

References pgroups.

Referenced by luci::remove_unused_inputoutputs().

Field Documentation

◆ default_group

GroupKey luci::PGroups::default_group

Definition at line 72 of file PartitionIR.h.

Referenced by luci::produce_pgroups().

◆ id2pgroup

std::map<uint32_t, PGroup *> luci::PGroups::id2pgroup

Definition at line 69 of file PartitionIR.h.

◆ node2group

std::map<const luci::CircleNode *, GroupKey> luci::PGroups::node2group

Definition at line 66 of file PartitionIR.h.

Referenced by luci::dump(), group_of(), make_copy(), and luci::produce_pgroups().

◆ pgroups

std::vector<std::unique_ptr<PGroup> > luci::PGroups::pgroups

The documentation for this struct was generated from the following files: