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

Method Invoke

delegate/opaque/src/armnn_delegate.cpp:627–704  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627TfLiteStatus ArmnnSubgraph::Invoke(TfLiteOpaqueContext* tfLiteContext, TfLiteOpaqueNode* tfLiteNode)
628{
629 // Get array of input indices, inputIndexArray is set from the TfLiteOpaqueNodeInputs function
630 // This function turns inputIndexArray into an int array of indices. These indices point to the tensors for
631 // each input slot in the node.
632 const int* inputIndexArray;
633 int numInputs;
634 if(TfLiteOpaqueNodeInputs(tfLiteNode, &inputIndexArray, &numInputs) != kTfLiteOk)
635 {
636 throw armnn::Exception("TfLiteArmnnOpaqueDelegate: Unable to load subgraph inputs!");
637 }
638 // Prepare inputs
639 armnn::InputTensors inputTensors;
640 size_t inputIndex = 0;
641 for (int inputIdx = 0; inputIdx < numInputs; inputIdx++)
642 {
643 TfLiteOpaqueTensor* tensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputIndexArray[inputIdx]);
644
645 if(!IsValid(tensor))
646 {
647 return kTfLiteError;
648 }
649 // If tensor is not read only
650 if (TfLiteOpaqueTensorGetAllocationType(tensor) != kTfLiteMmapRo)
651 {
652 const armnn::BindingPointInfo& inputBinding = m_InputBindings[inputIndex];
653 armnn::TensorInfo inputTensorInfo = inputBinding.second;
654 inputTensorInfo.SetConstant(true);
655 const armnn::ConstTensor inputTensor(inputTensorInfo, TfLiteOpaqueTensorData(tensor));
656 inputTensors.emplace_back(inputIndexArray[inputIdx], inputTensor);
657
658 ++inputIndex;
659 }
660 }
661
662 // Get array of output indices, outputIndexArray is set from the TfLiteOpaqueNodeOutputs function
663 // This function turns outputIndexArray into an int array of indices. These indices point to the tensors for
664 // each output slot in the node.
665 const int* outputIndexArray;
666 int numOutputs;
667 if(TfLiteOpaqueNodeOutputs(tfLiteNode, &outputIndexArray, &numOutputs) != kTfLiteOk)
668 {
669 throw armnn::Exception("TfLiteArmnnOpaqueDelegate: Unable to load subgraph outputs!");
670 }
671 // Assign the tensors from the outputIndexArray to the armnn BindingPointInfo
672 armnn::OutputTensors outputTensors;
673 for (int outputIdx = 0; outputIdx < numOutputs; outputIdx++)
674 {
675 const armnn::BindingPointInfo& outputBinding = m_OutputBindings[outputIdx];
676 TfLiteOpaqueTensor* tensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputIndexArray[outputIdx]);
677 if(!IsValid(tensor))
678 {
679 return kTfLiteError;
680 }
681
682 const armnn::Tensor outputTensor(outputBinding.second, reinterpret_cast<TfLiteTensor*>(tensor)->data
683 .data);
684 outputTensors.emplace_back(outputIndexArray[outputIdx], outputTensor);

Callers 15

RedefineTestFunction · 0.45
Pooling2dTestFunction · 0.45
ArgMinMaxTestFunction · 0.45
PreluTestFunction · 0.45
UnpackTestFunction · 0.45
SoftmaxTestFunction · 0.45
PadTestFunction · 0.45
StridedSliceTestImplFunction · 0.45
ConvolutionTestFunction · 0.45
Convolution3dTestFunction · 0.45
TransposeConvTestFunction · 0.45

Calls 7

SetConstantMethod · 0.80
IsValidFunction · 0.70
ExceptionClass · 0.50
EnqueueWorkloadMethod · 0.45
whatMethod · 0.45
strMethod · 0.45
c_strMethod · 0.45

Tested by 15

RedefineTestFunction · 0.36
Pooling2dTestFunction · 0.36
ArgMinMaxTestFunction · 0.36
PreluTestFunction · 0.36
UnpackTestFunction · 0.36
SoftmaxTestFunction · 0.36
PadTestFunction · 0.36
StridedSliceTestImplFunction · 0.36
ConvolutionTestFunction · 0.36
Convolution3dTestFunction · 0.36
TransposeConvTestFunction · 0.36