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

Method OptimizeSubgraphView

src/backends/tosaReference/TosaRefBackend.cpp:82–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgraph,
83 const ModelOptions& modelOptions) const
84{
85 OptimizationViews optimizationViews(modelOptions);
86
87 auto handler = std::make_unique<TosaSerializationHandler>();
88
89 std::vector<std::string> graphInputs;
90 std::vector<std::string> graphOutputs;
91 std::vector<TosaSerializationOperator*> operators;
92 std::vector<TosaSerializationTensor*> tensors;
93 OpBlockSequencer<Layer, TosaSerializationBasicBlock> sequencer;
94
95 // These sets are created to check the duplication of tensor and input
96 std::unordered_set<std::string> graphInputsSet;
97 std::unordered_set<std::string> uniqueTensorNamesSet;
98
99 auto it = subgraph.begin();
100 while (it != subgraph.end())
101 {
102 Layer& base = *(PolymorphicDowncast<Layer*>(*it));
103 ++it;
104
105 if (base.GetType() == LayerType::Input ||
106 base.GetType() == LayerType::Output)
107 {
108 continue;
109 }
110
111 TosaSerializationBasicBlock* mappings = GetTosaMappingFromLayer(&base);
112
113 // Loop through inputs to see if there are any graph inputs, if so save them.
114 // If it's an input to the graph "input" can be found in the string.
115 for (const std::string& blockInputName : mappings->GetInputs())
116 {
117 if ((blockInputName.find("input") != std::string::npos) && !graphInputsSet.count(blockInputName))
118 {
119 graphInputs.push_back(blockInputName);
120 graphInputsSet.insert(blockInputName);
121 }
122 }
123
124 // Loop through outputs to see if there are any graph outputs, if so save them.
125 // If it's an output to the graph "output" can be found in the string.
126 for (const std::string& blockOutputName : mappings->GetOutputs())
127 {
128 if (blockOutputName.find("output") != std::string::npos)
129 {
130 graphOutputs.push_back(blockOutputName);
131 }
132 }
133
134 sequencer.Add(&base, mappings);
135 }
136
137 for (auto & pair : sequencer.Finish())
138 {
139 auto blockOperators = pair.block->GetOperators();

Callers

nothing calls this directly

Calls 15

GetTosaMappingFromLayerFunction · 0.85
SubgraphViewClass · 0.85
push_backMethod · 0.80
AddMethod · 0.80
AddPrecompiledLayerMethod · 0.80
GetINetworkMethod · 0.80
GetOutputSlotMethod · 0.80
GetIOutputSlotMethod · 0.80
AddSubstitutionMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected