diff options
author | Ryan OShea <ryan.oshea3@arm.com> | 2023-01-17 15:19:20 +0000 |
---|---|---|
committer | Ryan OShea <ryan.oshea3@arm.com> | 2023-02-03 10:31:10 +0000 |
commit | 4c231de93b9b7c2af24e155550cb80b96f2c4bb5 (patch) | |
tree | fcbc43d7436cacc63ef7a90e73023135694ddf48 /delegate/src/DelegateUtils.hpp | |
parent | 555dc0982f85f0a146e99189bac523151797a056 (diff) | |
download | armnn-4c231de93b9b7c2af24e155550cb80b96f2c4bb5.tar.gz |
IVGCVSW-7501 Allow constant tensors as inputs for input data in the delegate
In the TLCT tests we were failing many tests because they used
constant tensors as data input for the layers. We had the functionality
in place but we didnt have it spread across the visit functions.
* Check if inputs are constant tensors and attempt to assign them
to input slot of layers.
* Add missing checks to some functions that return a kTfLiteStatus
so we can see if they fail
* Clean up CreateConstTensor function
Signed-off-by: Ryan OShea <ryan.oshea3@arm.com>
Change-Id: I8610b770aea56932a98f91c961d59b3de47c2ab5
Diffstat (limited to 'delegate/src/DelegateUtils.hpp')
-rw-r--r-- | delegate/src/DelegateUtils.hpp | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/delegate/src/DelegateUtils.hpp b/delegate/src/DelegateUtils.hpp index c0bef4f994..3e74225b15 100644 --- a/delegate/src/DelegateUtils.hpp +++ b/delegate/src/DelegateUtils.hpp @@ -545,10 +545,7 @@ armnn::TensorInfo GetTensorInfoForTfLiteTensor(const TfLiteTensor& tfLiteTensor, } armnn::ConstTensor CreateConstTensor(const TfLiteTensor* tfLiteTensor, - armnn::TensorInfo& tensorInfo, - armnn::Optional<armnn::PermutationVector&> - permutationVector = armnn::EmptyOptional(), - void* permutationData = nullptr) + const armnn::TensorInfo& tensorInfo) { if (tfLiteTensor->allocation_type != kTfLiteMmapRo) { @@ -556,28 +553,7 @@ armnn::ConstTensor CreateConstTensor(const TfLiteTensor* tfLiteTensor, "TfLiteArmnnDelegate: Not constant allocation type: " + std::to_string(tfLiteTensor->allocation_type)); } - if(tflite::IsConstantTensor(tfLiteTensor)) - { - tensorInfo.SetConstant(); - } - - if (permutationVector.has_value() && permutationVector.value().GetSize() > 0 && permutationData != nullptr) - { - // Permute tensor info - tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector.value()); - // then permute data using the shape from permuted tensor info - armnnUtils::Permute(tensorInfo.GetShape(), - permutationVector.value(), - tfLiteTensor->data.data, - permutationData, - armnn::GetDataTypeSize(tensorInfo.GetDataType())); - - return armnn::ConstTensor(tensorInfo, permutationData); - } - else - { - return armnn::ConstTensor(tensorInfo, tfLiteTensor->data.data); - } + return armnn::ConstTensor(tensorInfo, tfLiteTensor->data.data); } armnn::ConstTensor* GetConstTensorForTfLiteTensor(const TfLiteTensor* tfLiteTensors, TfLiteNode* tfLiteNode, int index) @@ -611,7 +587,7 @@ void CalcPadding(uint32_t inputSize, } TfLiteStatus ConnectConstant(armnn::IConnectableLayer* layer, - armnn::TensorInfo& constTensorInfo, + const armnn::TensorInfo& constTensorInfo, TfLiteContext* tfLiteContext, const TfLiteTensor& tfLiteTensor, armnnDelegate::DelegateData& data, @@ -633,8 +609,7 @@ TfLiteStatus ConnectConstant(armnn::IConnectableLayer* layer, } auto constantInput = CreateConstTensor(&tfLiteTensor, - constTensorInfo, - armnn::Optional<armnn::PermutationVector&>()); + constTensorInfo); armnn::IConnectableLayer* constantLayer = data.m_Network->AddConstantLayer(constantInput); constantLayer->SetBackendId(setBackend); armnn::IOutputSlot& outputSlot = constantLayer->GetOutputSlot(0); @@ -684,8 +659,7 @@ TfLiteStatus ProcessInputs(armnn::IConnectableLayer* layer, return kTfLiteError; } auto constantInput = CreateConstTensor(&tfLiteInputTensor, - inputTensorInfo, - armnn::Optional<armnn::PermutationVector&>()); + inputTensorInfo); armnn::IConnectableLayer* constantLayer = delegateData.m_Network->AddConstantLayer(constantInput); constantLayer->SetBackendId(setBackend); armnn::IOutputSlot& outputSlot = constantLayer->GetOutputSlot(0); |