diff options
author | Mike Kelly <mike.kelly@arm.com> | 2020-02-28 18:11:58 +0000 |
---|---|---|
committer | mike.kelly <mike.kelly@arm.com> | 2020-03-02 16:44:09 +0000 |
commit | c9ea45adefdde2890e9aa191a5b31563a3dd35ea (patch) | |
tree | 2ea65c972d24cc2d823ea39eb105d4062db54934 /include/armnn | |
parent | 510f6183d289b176702a18f020449c68be6f1075 (diff) | |
download | armnn-c9ea45adefdde2890e9aa191a5b31563a3dd35ea.tar.gz |
IVGCVSW-4375 Add support for Transpose
* Added TransposeLayer
* Added CL, Neon and Ref Workloads
* Added Transpose utilities
* Added Serializer and Deserializer support
* Added Quantizer support
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Change-Id: I04c755ba7cb5b1edf72b3c9f3c0314878032e3c7
Diffstat (limited to 'include/armnn')
-rw-r--r-- | include/armnn/Descriptors.hpp | 21 | ||||
-rw-r--r-- | include/armnn/DescriptorsFwd.hpp | 1 | ||||
-rw-r--r-- | include/armnn/ILayerSupport.hpp | 5 | ||||
-rw-r--r-- | include/armnn/ILayerVisitor.hpp | 8 | ||||
-rw-r--r-- | include/armnn/INetwork.hpp | 8 | ||||
-rw-r--r-- | include/armnn/LayerVisitorBase.hpp | 4 |
6 files changed, 46 insertions, 1 deletions
diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp index 2d7b17edbb..f1b29cc6c7 100644 --- a/include/armnn/Descriptors.hpp +++ b/include/armnn/Descriptors.hpp @@ -1119,4 +1119,25 @@ struct TransposeConvolution2dDescriptor DataLayout m_DataLayout; }; +/// A TransposeDescriptor for the TransposeLayer. +struct TransposeDescriptor +{ + TransposeDescriptor() + : m_DimMappings{} + {} + + TransposeDescriptor(const PermutationVector& dimMappings) + : m_DimMappings(dimMappings) + {} + + bool operator ==(const TransposeDescriptor &rhs) const + { + return m_DimMappings.IsEqual(rhs.m_DimMappings); + } + + /// @brief Indicates how to translate tensor elements from a given source into the target destination, when + /// source and target potentially have different memory layouts e.g. {0U, 3U, 1U, 2U}. + PermutationVector m_DimMappings; +}; + } // namespace armnn diff --git a/include/armnn/DescriptorsFwd.hpp b/include/armnn/DescriptorsFwd.hpp index d03c61d452..144c1ef7fd 100644 --- a/include/armnn/DescriptorsFwd.hpp +++ b/include/armnn/DescriptorsFwd.hpp @@ -40,6 +40,7 @@ struct StackDescriptor; struct StandInDescriptor; struct StridedSliceDescriptor; struct TransposeConvolution2dDescriptor; +struct TransposeDescriptor; struct ViewsDescriptor; using ConcatDescriptor = OriginsDescriptor; diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index d1bbf99d5e..af91e87376 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -369,6 +369,11 @@ public: const Optional<TensorInfo>& biases, Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsTransposeSupported(const TensorInfo& input, + const TensorInfo& output, + const TransposeDescriptor& descriptor, + Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; + }; // class ILayerSupport using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>; diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp index 46f9e5698f..972915dc0f 100644 --- a/include/armnn/ILayerVisitor.hpp +++ b/include/armnn/ILayerVisitor.hpp @@ -494,6 +494,14 @@ public: const Optional<ConstTensor>& biases, const char* name = nullptr) = 0; + /// Function that a transpose 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 transposeDescriptor - TransposeDescriptor to configure the transpose. + /// @param name - Optional name for the layer. + virtual void VisitTransposeLayer(const IConnectableLayer* layer, + const TransposeDescriptor& transposeDescriptor, + const char* name = nullptr) = 0; + virtual void StartVisit() {} virtual void FinishVisit() {} diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index 1b1c874f8c..71eb9ff802 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -511,6 +511,13 @@ public: const Optional<ConstTensor>& biases, const char* name = nullptr) = 0; + /// Adds a transpose layer to the network. + /// @param transposeDescriptor - TransposeDescriptor to configure the transpose. + /// @param name - Optional name for the layer. + /// @return - Interface for configuring the layer. + virtual IConnectableLayer* AddTransposeLayer(const TransposeDescriptor& transposeDescriptor, + const char* name = nullptr) = 0; + /// Adds a stack layer to the network. /// @param descriptor - Description of the stack layer. /// @param name - Optional name for the layer. @@ -518,7 +525,6 @@ public: virtual IConnectableLayer* AddStackLayer(const StackDescriptor& descriptor, const char* name = nullptr) = 0; - /// Add a stand-in layer for a type unknown to the Arm NN framework. /// Note: Due to the nature of this layer, no validation can be performed by the framework. /// Furthermore, Any model containing this layer cannot make use of dynamic tensors since the diff --git a/include/armnn/LayerVisitorBase.hpp b/include/armnn/LayerVisitorBase.hpp index 6fd9a66c76..511917cd19 100644 --- a/include/armnn/LayerVisitorBase.hpp +++ b/include/armnn/LayerVisitorBase.hpp @@ -246,6 +246,10 @@ public: const Optional<ConstTensor>&, const char*) override { DefaultPolicy::Apply(__func__); } + void VisitTransposeLayer(const IConnectableLayer*, + const TransposeDescriptor&, + const char*) override { DefaultPolicy::Apply(__func__); } + }; } // namespace armnn |