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

Method Create

delegate/classic/src/armnn_delegate.cpp:348–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext,
349 const TfLiteDelegateParams* parameters,
350 const Delegate* delegate)
351{
352 const auto startTime = armnn::GetTimeNow();
353 ARMNN_LOG(info) << "ArmnnSubgraph creation";
354
355 TfLiteIntArray* executionPlan;
356 if (tfLiteContext->GetExecutionPlan(tfLiteContext, &executionPlan) != kTfLiteOk)
357 {
358 return nullptr;
359 }
360
361 // Initialize DelegateData holds network and output slots information
362 DelegateData delegateData(delegate->m_Options.GetBackends());
363
364 // Build ArmNN Network
365 armnn::NetworkOptions networkOptions = delegate->m_Options.GetOptimizerOptions().GetModelOptions();
366 armnn::NetworkId networkId;
367 delegateData.m_Network = armnn::INetwork::Create(networkOptions);
368
369 delegateData.m_OutputSlotForNode = std::vector<armnn::IOutputSlot*>(tfLiteContext->tensors_size, nullptr);
370
371 std::vector<armnn::BindingPointInfo> inputBindings;
372 std::vector<armnn::BindingPointInfo> outputBindings;
373
374 // Add input layer
375 auto status = AddInputLayer(delegateData, tfLiteContext, parameters->input_tensors, inputBindings);
376 if (status != kTfLiteOk)
377 {
378 throw armnn::Exception("TfLiteArmnnDelegate: Unable to add Inputs to the network!");
379 }
380
381 // Parse TfLite delegate nodes to ArmNN
382 const auto parseStartTime = armnn::GetTimeNow();
383 for (int i = 0; i < parameters->nodes_to_replace->size; ++i)
384 {
385 const int nodeIndex = parameters->nodes_to_replace->data[i];
386
387 TfLiteNode* tfLiteNode = nullptr;
388 TfLiteRegistration* tfLiteRegistration = nullptr;
389 if (tfLiteContext->GetNodeAndRegistration(
390 tfLiteContext, nodeIndex, &tfLiteNode, &tfLiteRegistration) != kTfLiteOk)
391 {
392 throw armnn::Exception(&"TfLiteArmnnDelegate: Unable to get node registration: " [ nodeIndex]);
393 }
394
395 if (VisitNode(delegateData, tfLiteContext, tfLiteRegistration, tfLiteNode, nodeIndex) != kTfLiteOk)
396 {
397 throw armnn::Exception(&"TfLiteArmnnDelegate: Unable to parse node: " [ nodeIndex]);
398 }
399 }
400 ARMNN_LOG(info) << "Parse nodes to ArmNN time: " << std::setprecision(2)
401 << std::fixed << armnn::GetTimeDuration(parseStartTime).count() << " ms";
402
403 // Add Output layer
404 status = AddOutputLayer(delegateData, tfLiteContext, parameters->output_tensors, outputBindings);
405 if (status != kTfLiteOk)

Callers

nothing calls this directly

Calls 15

GetTimeNowFunction · 0.85
AddInputLayerFunction · 0.85
GetTimeDurationFunction · 0.85
AddOutputLayerFunction · 0.85
OptimizeFunction · 0.85
GetModelOptionsMethod · 0.80
emptyMethod · 0.80
GetImportEnabledMethod · 0.80
GetExportEnabledMethod · 0.80
LoadNetworkMethod · 0.80
ExceptionClass · 0.50

Tested by

no test coverage detected