diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2021-05-05 15:03:50 +0100 |
---|---|---|
committer | Kevin May <kevin.may@arm.com> | 2021-05-06 07:49:22 +0000 |
commit | f7ac72c85c90c61be14fff16c9c2ff638fa32c40 (patch) | |
tree | ac1455193dcbb3226aa612a3fdf87f913c0cd4fd /delegate/src/DelegateUtils.hpp | |
parent | a18c70843189cbabf72f4e502bf35b5df2d359bf (diff) | |
download | armnn-f7ac72c85c90c61be14fff16c9c2ff638fa32c40.tar.gz |
IVGCVSW-5418 'ExecuteNetwork test for MobileBERT'
* Refactored the code for checking constant inputs.
* Added a unit test for ADD operator with constant input.
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: Ie7207e5a1ce77ea305552859de32a66e07c68a6f
Diffstat (limited to 'delegate/src/DelegateUtils.hpp')
-rw-r--r-- | delegate/src/DelegateUtils.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/delegate/src/DelegateUtils.hpp b/delegate/src/DelegateUtils.hpp index 76d21f6332..fa38ee3e90 100644 --- a/delegate/src/DelegateUtils.hpp +++ b/delegate/src/DelegateUtils.hpp @@ -555,6 +555,46 @@ TfLiteStatus ConnectConstant(armnn::IConnectableLayer* layer, return kTfLiteOk; } +TfLiteStatus ProcessInputs(armnn::IConnectableLayer* layer, + armnnDelegate::DelegateData& delegateData, + TfLiteContext* tfLiteContext, + TfLiteNode* tfLiteNode) +{ + const TfLiteTensor* tfLiteTensors = tfLiteContext->tensors; + // Process input tensors + // If input tensor is a Constant tensor create a constant layer and connect it to the network + for (unsigned int inputIndex = 0; inputIndex < layer->GetNumInputSlots(); ++inputIndex) + { + const TfLiteTensor& tfLiteInputTensor = tfLiteTensors[tfLiteNode->inputs->data[inputIndex]]; + if(tflite::IsConstantTensor(&tfLiteInputTensor)) + { + armnn::TensorInfo inputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteInputTensor); + bool isSupported = false; + FORWARD_LAYER_SUPPORT_FUNC(__func__, + tfLiteContext, + IsConstantSupported, + delegateData.m_Backends, + isSupported, + inputTensorInfo); + if (!isSupported) + { + return kTfLiteError; + } + auto constantInput = CreateConstTensor(&tfLiteInputTensor, + inputTensorInfo, + armnn::Optional<armnn::PermutationVector&>()); + armnn::IConnectableLayer* constantLayer = delegateData.m_Network->AddConstantLayer(constantInput); + armnn::IOutputSlot& outputSlot = constantLayer->GetOutputSlot(0); + outputSlot.SetTensorInfo(inputTensorInfo); + + delegateData.m_OutputSlotForNode[static_cast<unsigned long>(inputIndex)] = &outputSlot; + + } + + } + return kTfLiteOk; +} + unsigned int ComputeWrappedIndex(int index, unsigned int numDimensions) { int numDims = armnn::numeric_cast<int>(numDimensions); |