From 7f0ff16bf698e34f208622cf2c043c1f34be6be8 Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Mon, 24 Jul 2023 23:42:10 +0100 Subject: IVGCVSW-7888 Add Tile convert function Signed-off-by: Teresa Charlin Change-Id: Ic9479be6b3e6cf0e529c685c9b28c642e9dd00d5 --- ConversionUtils_1_2.hpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'ConversionUtils_1_2.hpp') diff --git a/ConversionUtils_1_2.hpp b/ConversionUtils_1_2.hpp index 2ad14c2f..5b38b075 100644 --- a/ConversionUtils_1_2.hpp +++ b/ConversionUtils_1_2.hpp @@ -2885,6 +2885,84 @@ bool ConvertLstm(const HalOperation& operation, const HalModel& model, Conversio } +template +bool ConvertTile(const HalOperation& operation, const HalModel& model, ConversionData& data) +{ + using HalOperand = typename HalPolicy::Operand; + + LayerInputHandle input = ConvertToLayerInputHandle(operation, 0, model, data); + + if (!input.IsValid()) + { + return Fail("%s: Operation has invalid inputs", __func__); + } + + const HalOperand* output = GetOutputOperand(operation, 0, model); + + if (!output) + { + return Fail("%s: Could not read output", __func__); + } + + const HalOperand* multiplesOperand = GetInputOperand(operation, 1, model); + if (!multiplesOperand) + { + return Fail("%s: Could not read input 1", __func__); + } + std::vector multiples; + if (!GetTensorInt32Values(*multiplesOperand, multiples, model, data)) + { + return Fail("%s: Input 1 has invalid values", __func__); + } + // Convert the multiples from int to unsigned int, + // as values are always going to be positive despite the data type being integer. + TileDescriptor descriptor; + descriptor.m_Multiples.assign(multiples.begin(), multiples.end()); + + const TensorInfo& inputInfo = input.GetTensorInfo(); + const TensorInfo& outputInfo = GetTensorInfoForOperand(*output); + + bool isSupported = false; + armnn::BackendId setBackend; + auto validateFunc = [&](const armnn::TensorInfo& outputInfo, bool& isSupported) + { + FORWARD_LAYER_SUPPORT_FUNC(__func__, + IsTileSupported, + data.m_Backends, + isSupported, + setBackend, + inputInfo, + outputInfo, + descriptor); + }; + + if(IsDynamicTensor(outputInfo)) + { + isSupported = AreDynamicTensorsSupported(); + } + else + { + validateFunc(outputInfo, isSupported); + } + if (!isSupported) + { + return false; + } + + IConnectableLayer* tileLayer = data.m_Network->AddTileLayer(descriptor); + if (!tileLayer) + { + return Fail("%s: AddTileLayer failed", __func__); + } + tileLayer->SetBackendId(setBackend); + + input.Connect(tileLayer->GetInputSlot(0)); + + return SetupAndTrackLayerOutputSlot(operation, 0, *tileLayer, model, data, nullptr, validateFunc); +} + template -- cgit v1.2.1