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

Method IdentifyOperatorsToDelegate

delegate/classic/src/armnn_delegate.cpp:181–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181TfLiteIntArray* Delegate::IdentifyOperatorsToDelegate(TfLiteContext* tfLiteContext)
182{
183 TfLiteIntArray* executionPlan = nullptr;
184 if (tfLiteContext->GetExecutionPlan(tfLiteContext, &executionPlan) != kTfLiteOk)
185 {
186 TF_LITE_KERNEL_LOG(tfLiteContext, "TfLiteArmnnDelegate: Unable to get graph execution plan.");
187 return nullptr;
188 }
189
190 // Delegate data with null network
191 DelegateData delegateData(m_Options.GetBackends());
192
193 TfLiteIntArray* nodesToDelegate = TfLiteIntArrayCreate(executionPlan->size);
194 nodesToDelegate->size = 0;
195
196 std::set<int32_t> unsupportedOperators;
197
198 for (int i = 0; i < executionPlan->size; ++i)
199 {
200 const int nodeIndex = executionPlan->data[i];
201
202 // If TfLite nodes can be delegated to ArmNN
203 TfLiteNode* tfLiteNode = nullptr;
204 TfLiteRegistration* tfLiteRegistration = nullptr;
205 if (tfLiteContext->GetNodeAndRegistration(
206 tfLiteContext, nodeIndex, &tfLiteNode, &tfLiteRegistration) != kTfLiteOk)
207 {
208 TF_LITE_KERNEL_LOG(tfLiteContext,
209 "TfLiteArmnnDelegate: Unable to get node and registration for node %d.",
210 nodeIndex);
211 continue;
212 }
213
214 TfLiteStatus visitStatus;
215
216 try
217 {
218 visitStatus = ArmnnSubgraph::VisitNode(
219 delegateData, tfLiteContext, tfLiteRegistration, tfLiteNode, nodeIndex);
220 }
221 catch(std::exception& ex)
222 {
223 ARMNN_LOG(error) << "ArmNN Failed to visit node with error: " << ex.what();
224 visitStatus = kTfLiteError;
225 TF_LITE_KERNEL_LOG(tfLiteContext,
226 "Exception text: %s",
227 ex.what());
228 }
229
230 if ( visitStatus != kTfLiteOk)
231 {
232 // node is not supported by ArmNN
233 unsupportedOperators.insert(tfLiteRegistration->builtin_code);
234 continue;
235 }
236
237 nodesToDelegate->data[nodesToDelegate->size++] = nodeIndex;
238 }

Callers 1

DoPrepareFunction · 0.45

Calls 7

emptyMethod · 0.80
ExceptionClass · 0.50
whatMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected