diff options
author | Teresa Charlin <teresa.charlinreyes@arm.com> | 2023-07-24 23:42:10 +0100 |
---|---|---|
committer | TeresaARM <teresa.charlinreyes@arm.com> | 2023-07-25 15:53:40 +0000 |
commit | 7f0ff16bf698e34f208622cf2c043c1f34be6be8 (patch) | |
tree | 0299df226be91211befd417a6ba67843276fd681 /ConversionUtils_1_2.hpp | |
parent | 5862bc4beca7cc14636c3fbf46e0ada1778beab0 (diff) | |
download | android-nn-driver-7f0ff16bf698e34f208622cf2c043c1f34be6be8.tar.gz |
IVGCVSW-7888 Add Tile convert function
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: Ic9479be6b3e6cf0e529c685c9b28c642e9dd00d5
Diffstat (limited to 'ConversionUtils_1_2.hpp')
-rw-r--r-- | ConversionUtils_1_2.hpp | 78 |
1 files changed, 78 insertions, 0 deletions
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 @@ -2888,6 +2888,84 @@ bool ConvertLstm(const HalOperation& operation, const HalModel& model, Conversio template<typename HalPolicy, typename HalOperation = typename HalPolicy::Operation, typename HalModel = typename HalPolicy::Model> +bool ConvertTile(const HalOperation& operation, const HalModel& model, ConversionData& data) +{ + using HalOperand = typename HalPolicy::Operand; + + LayerInputHandle input = ConvertToLayerInputHandle<HalPolicy>(operation, 0, model, data); + + if (!input.IsValid()) + { + return Fail("%s: Operation has invalid inputs", __func__); + } + + const HalOperand* output = GetOutputOperand<HalPolicy>(operation, 0, model); + + if (!output) + { + return Fail("%s: Could not read output", __func__); + } + + const HalOperand* multiplesOperand = GetInputOperand<HalPolicy>(operation, 1, model); + if (!multiplesOperand) + { + return Fail("%s: Could not read input 1", __func__); + } + std::vector<int32_t> multiples; + if (!GetTensorInt32Values<HalPolicy>(*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<HalPolicy>(operation, 0, *tileLayer, model, data, nullptr, validateFunc); +} + +template<typename HalPolicy, + typename HalOperation = typename HalPolicy::Operation, + typename HalModel = typename HalPolicy::Model> bool ConvertTransposeConv2d(const HalOperation& operation, const HalModel& model, ConversionData& data) { using HalOperand = typename HalPolicy::Operand; |