From a6bc52f6b9eeddcdebf4e660b21a4409a592ac4e Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Wed, 26 Jun 2019 09:39:49 +0100 Subject: IVGCVSW-3197 Support SPACE_TO_DEPTH on Android * Added support within 1.0/HalPolicy * Added support within 1.1/HalPolicy * Added support within 1.2/HalPolicy * Updated NnapiSupport.txt Signed-off-by: Keith Davis Change-Id: I2dc2743ee2f858d2b3496aae0f3e3e28a96ee96e --- 1.2/HalPolicy.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1.2/HalPolicy.hpp | 2 ++ 2 files changed, 54 insertions(+) (limited to '1.2') diff --git a/1.2/HalPolicy.cpp b/1.2/HalPolicy.cpp index 836977da..fe0cfbdc 100644 --- a/1.2/HalPolicy.cpp +++ b/1.2/HalPolicy.cpp @@ -669,5 +669,57 @@ bool HalPolicy::ConvertResize(const Operation& operation, return SetupAndTrackLayerOutputSlot(operation, 0, *layer, model, data); } +bool HalPolicy::ConvertSpaceToDepth(const Operation& operation, const Model& model, ConversionData& data) +{ + LayerInputHandle input = ConvertToLayerInputHandle(operation, 0, model, data); + + if (!input.IsValid() ) + { + return Fail("%s: Operation has invalid inputs", __func__); + } + + const armnn::TensorInfo& inputInfo = input.GetTensorInfo(); + unsigned int rank = inputInfo.GetNumDimensions(); + + if (rank != 4) + { + return Fail("%s: Only inputs with rank 4 are supported", __func__); + } + + armnn::SpaceToDepthDescriptor desc; + + GetInputScalar(operation, 1, OperandType::INT32, desc.m_BlockSize, model, data); + + if (desc.m_BlockSize <= 1) + { + return Fail("%s: Block size must be at least 1 in all dimensions"); + } + + desc.m_DataLayout = OptionalDataLayout(operation, 2, model, data); + + const Operand* output = GetOutputOperand(operation, 0, model); + if (!output) + { + return Fail("%s: Could not read output 0", __func__); + } + + const armnn::TensorInfo& outputInfo = GetTensorInfoForOperand(*output); + if (!IsLayerSupportedForAnyBackend(__func__, + armnn::IsSpaceToDepthSupported, + data.m_Backends, + inputInfo, + outputInfo, + desc)) + { + return false; + } + + armnn::IConnectableLayer* const layer = data.m_Network->AddSpaceToDepthLayer(desc); + assert(layer != nullptr); + input.Connect(layer->GetInputSlot(0)); + + return SetupAndTrackLayerOutputSlot(operation, 0, *layer, model, data); +} + } // namespace hal_1_2 } // namespace armnn_driver diff --git a/1.2/HalPolicy.hpp b/1.2/HalPolicy.hpp index 9d6dd497..25aee820 100644 --- a/1.2/HalPolicy.hpp +++ b/1.2/HalPolicy.hpp @@ -43,6 +43,8 @@ private: const Model& model, ConversionData& data, armnn::ResizeMethod resizeMethod); + + static bool ConvertSpaceToDepth(const Operation& operation, const Model& model, ConversionData& data); }; } // namespace hal_1_2 -- cgit v1.2.1