From dd6247f52dcb33bd03391b7ee573d7082e18cca7 Mon Sep 17 00:00:00 2001 From: Aron Virginas-Tar Date: Thu, 19 Sep 2019 14:31:17 +0100 Subject: IVGCVSW-3883 Add frontend for DepthToSpace layer Signed-off-by: Aron Virginas-Tar Change-Id: I18d957af6e988ffb6b9ee46ac836d1f38600e10b --- include/armnn/Descriptors.hpp | 12 ++++++++++-- include/armnn/DescriptorsFwd.hpp | 2 ++ include/armnn/ILayerSupport.hpp | 5 +++++ include/armnn/ILayerVisitor.hpp | 8 ++++++++ include/armnn/INetwork.hpp | 7 +++++++ include/armnn/LayerVisitorBase.hpp | 4 ++++ 6 files changed, 36 insertions(+), 2 deletions(-) (limited to 'include/armnn') diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp index 686536f53e..c973089df6 100644 --- a/include/armnn/Descriptors.hpp +++ b/include/armnn/Descriptors.hpp @@ -589,16 +589,24 @@ struct SpaceToBatchNdDescriptor struct SpaceToDepthDescriptor { SpaceToDepthDescriptor() - : m_BlockSize(1u) - , m_DataLayout(DataLayout::NHWC) + : SpaceToDepthDescriptor(1u, DataLayout::NHWC) + {} + + SpaceToDepthDescriptor(unsigned int blockSize, DataLayout dataLayout) + : m_BlockSize(blockSize) + , m_DataLayout(dataLayout) {} /// Scalar specifying the input block size. It must be >= 1 unsigned int m_BlockSize; + /// The data layout to be used (NCHW, NHWC). DataLayout m_DataLayout; }; +/// A DepthToSpaceDescriptor for the DepthToSpaceLayer +using DepthToSpaceDescriptor = SpaceToDepthDescriptor; + /// An LstmDescriptor for the LstmLayer. struct LstmDescriptor { diff --git a/include/armnn/DescriptorsFwd.hpp b/include/armnn/DescriptorsFwd.hpp index bddb0cad59..e9624f18ce 100644 --- a/include/armnn/DescriptorsFwd.hpp +++ b/include/armnn/DescriptorsFwd.hpp @@ -37,6 +37,8 @@ struct StridedSliceDescriptor; struct TransposeConvolution2dDescriptor; struct ViewsDescriptor; +using DepthToSpaceDescriptor = SpaceToDepthDescriptor; + // MergerDescriptor is deprecated use ConcatDescriptor instead using MergerDescriptor = OriginsDescriptor; using ConcatDescriptor = OriginsDescriptor; diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index cab2df19af..e18b86acfd 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -88,6 +88,11 @@ public: const TensorInfo& output, Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsDepthToSpaceSupported(const TensorInfo& input, + const TensorInfo& output, + const DepthToSpaceDescriptor& descriptor, + Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsDepthwiseConvolutionSupported( const TensorInfo& input, const TensorInfo& output, diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp index 6c0977303c..486a13f847 100644 --- a/include/armnn/ILayerVisitor.hpp +++ b/include/armnn/ILayerVisitor.hpp @@ -115,6 +115,14 @@ public: const Optional& biases, const char* name = nullptr) = 0; + /// Function a depth to space layer should call back to when its Accept(ILayerVisitor&) function is invoked. + /// @param layer - pointer to the layer which is calling back to this visit function. + /// @param depthToSpaceDescriptor - Parameters for the depth to space operation. + /// @param name - Optional name for the layer. + virtual void VisitDepthToSpaceLayer(const IConnectableLayer* layer, + const DepthToSpaceDescriptor& depthToSpaceDescriptor, + const char* name = nullptr) = 0; + /// Function that a 2D depthwise convolution layer with biases should call back to when its /// Accept(ILayerVisitor&) function is invoked. /// @param layer - pointer to the layer which is calling back to this visit function. diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index 09026ad9e6..0e0b99a718 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -141,6 +141,13 @@ public: const ConstTensor& biases, const char* name = nullptr) = 0; + /// Adds a depth to space layer to the network. + /// @param depthToSpaceDescriptor - Parameters for the depth to space operation. + /// @param name - Optional name for the layer. + /// @return - Interface for configuring the layer. + virtual IConnectableLayer* AddDepthToSpaceLayer(const DepthToSpaceDescriptor& depthToSpaceDescriptor, + const char* name = nullptr) = 0; + /// Adds a 2D depthwise convolution layer to the network. /// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer. /// @param weights - Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width]. diff --git a/include/armnn/LayerVisitorBase.hpp b/include/armnn/LayerVisitorBase.hpp index d626c712ba..65d23039b7 100644 --- a/include/armnn/LayerVisitorBase.hpp +++ b/include/armnn/LayerVisitorBase.hpp @@ -69,6 +69,10 @@ public: const Optional&, const char*) override { DefaultPolicy::Apply(__func__); } + void VisitDepthToSpaceLayer(const IConnectableLayer*, + const DepthToSpaceDescriptor&, + const char*) override { DefaultPolicy::Apply(__func__); } + void VisitDepthwiseConvolution2dLayer(const IConnectableLayer*, const DepthwiseConvolution2dDescriptor&, const ConstTensor&, -- cgit v1.2.1