MCPcopy Create free account
hub / github.com/ARM-software/armnn / MergeWith

Method MergeWith

src/armnn/SubgraphViewSelector.cpp:65–113  ·  view source on GitHub ↗

Merges this subgraph with another.

Source from the content-addressed store, hash-verified

63
64 /// Merges this subgraph with another.
65 void MergeWith(PartialSubgraph* other)
66 {
67 if (m_Parent == nullptr)
68 {
69 other = other->GetRepresentative();
70 if (this == other)
71 {
72 // Already merged - no-op
73 return;
74 }
75 m_Parent = other;
76
77 // Update others' dependency sets to point to the new representative rather than us.
78 // Keeping these up-to-date means we can rely on these sets containing representatives when
79 // we perform a lookup in HasAntecedent() and so don't need to resolve the representative for each element
80 // of the set. See description at the top of this class for more rationale.
81 for (PartialSubgraph* a : m_Antecedents)
82 {
83 size_t numErased = a->m_Dependants.erase(this);
84 if (numErased != 1)
85 {
86 throw armnn::Exception("number of dependents erased must only be 1.");
87 }
88 a->m_Dependants.insert(m_Parent);
89 }
90 for (PartialSubgraph* a : m_Dependants)
91 {
92 size_t numErased = a->m_Antecedents.erase(this);
93 if (numErased != 1)
94 {
95 throw armnn::Exception("number of antecedents erased must only be 1.");
96 }
97 IgnoreUnused(numErased);
98 a->m_Antecedents.insert(m_Parent);
99 }
100
101 // Merge our dependency sets into our new representative.
102 // We no longer need to maintain our own sets, as requests will always be forwarded to the representative.
103 m_Parent->m_Antecedents.insert(m_Antecedents.begin(), m_Antecedents.end());
104 m_Antecedents.clear();
105 m_Parent->m_Dependants.insert(m_Dependants.begin(), m_Dependants.end());
106 m_Dependants.clear();
107 }
108 else
109 {
110 // Defer request to the representative
111 GetRepresentative()->MergeWith(other);
112 }
113 }
114
115 /// Checks if this subgraph has been merged with the given subgraph.
116 bool IsMergedWith(PartialSubgraph* other)

Callers 1

AssignSplitIdFunction · 0.80

Calls 6

GetRepresentativeMethod · 0.80
ExceptionClass · 0.50
IgnoreUnusedFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected