From f982deaefbe5fe5814487b27f7099829839b8666 Mon Sep 17 00:00:00 2001 From: Aron Virginas-Tar Date: Fri, 11 Oct 2019 14:07:53 +0100 Subject: IVGCVSW-3973 Add frontend for LOG_SOFTMAX Signed-off-by: Aron Virginas-Tar Change-Id: Ic6acc7176deea3753b32ce6340f642d19dce0e9f --- include/armnn/Descriptors.hpp | 3 +++ include/armnn/DescriptorsFwd.hpp | 12 +++++++----- include/armnn/ILayerSupport.hpp | 5 +++++ include/armnn/ILayerVisitor.hpp | 8 ++++++++ include/armnn/INetwork.hpp | 7 +++++++ include/armnn/LayerVisitorBase.hpp | 4 ++++ 6 files changed, 34 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp index 5bf4043afa..e2e59741a3 100644 --- a/include/armnn/Descriptors.hpp +++ b/include/armnn/Descriptors.hpp @@ -74,6 +74,9 @@ struct SoftmaxDescriptor int m_Axis; }; +/// A LogSoftmaxDescriptor for the LogSoftmaxLayer +using LogSoftmaxDescriptor = SoftmaxDescriptor; + /// @brief An OriginsDescriptor for the ConcatLayer. /// Descriptor to configure the concatenation process. Number of views must be equal to the number of inputs, and /// their order must match - e.g. first view corresponds to the first input, second view to the second input, etc. diff --git a/include/armnn/DescriptorsFwd.hpp b/include/armnn/DescriptorsFwd.hpp index 2cc95828e6..6f1c0e0a6e 100644 --- a/include/armnn/DescriptorsFwd.hpp +++ b/include/armnn/DescriptorsFwd.hpp @@ -7,6 +7,7 @@ namespace armnn { + struct ActivationDescriptor; struct ArgMinMaxDescriptor; struct BatchNormalizationDescriptor; @@ -38,10 +39,11 @@ struct StridedSliceDescriptor; struct TransposeConvolution2dDescriptor; struct ViewsDescriptor; +using ConcatDescriptor = OriginsDescriptor; using DepthToSpaceDescriptor = SpaceToDepthDescriptor; +using LogSoftmaxDescriptor = SoftmaxDescriptor; +// MergerDescriptor is deprecated, use ConcatDescriptor instead +using MergerDescriptor = OriginsDescriptor; +using SplitterDescriptor = ViewsDescriptor; -// MergerDescriptor is deprecated use ConcatDescriptor instead -using MergerDescriptor = OriginsDescriptor; -using ConcatDescriptor = OriginsDescriptor; -using SplitterDescriptor = ViewsDescriptor; -} +} // namespace armnn diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index fef7595b54..31b5e134e9 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -168,6 +168,11 @@ public: const L2NormalizationDescriptor& descriptor, Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsLogSoftmaxSupported(const TensorInfo& input, + const TensorInfo& output, + const LogSoftmaxDescriptor& descriptor, + Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsLstmSupported(const TensorInfo& input, const TensorInfo& outputStateIn, const TensorInfo& cellStateIn, diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp index b9c96d5448..e99e10f800 100644 --- a/include/armnn/ILayerVisitor.hpp +++ b/include/armnn/ILayerVisitor.hpp @@ -224,6 +224,14 @@ public: const L2NormalizationDescriptor& desc, const char* name = nullptr) = 0; + /// Function that a log softmax 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 logSoftmaxDescriptor - LogSoftmaxDescriptor to configure the log softmax. + /// @param name - Optional name for the layer. + virtual void VisitLogSoftmaxLayer(const IConnectableLayer* layer, + const LogSoftmaxDescriptor& logSoftmaxDescriptor, + const char* name = nullptr) = 0; + /// Function an Lstm 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 descriptor - Parameters controlling the operation of the Lstm operation. diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index dc831db864..d12f5c239c 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -344,6 +344,13 @@ public: virtual IConnectableLayer* AddL2NormalizationLayer(const L2NormalizationDescriptor& desc, const char* name = nullptr) = 0; + /// Adds a log softmax layer to the network. + /// @param logSoftmaxDescriptor - LogSoftmaxDescriptor to configure the log softmax. + /// @param name - Optional name for the layer. + /// @return - Interface for configuring the layer. + virtual IConnectableLayer* AddLogSoftmaxLayer(const LogSoftmaxDescriptor& logSoftmaxDescriptor, + const char* name = nullptr) = 0; + /// Adds a layer with no inputs and a single output, which always corresponds to /// the passed in constant tensor. /// @param input - Tensor to be provided as the only output of the layer. The layer will maintain diff --git a/include/armnn/LayerVisitorBase.hpp b/include/armnn/LayerVisitorBase.hpp index 719e59d39c..912f25500c 100644 --- a/include/armnn/LayerVisitorBase.hpp +++ b/include/armnn/LayerVisitorBase.hpp @@ -120,6 +120,10 @@ public: const L2NormalizationDescriptor&, const char*) override { DefaultPolicy::Apply(__func__); } + void VisitLogSoftmaxLayer(const IConnectableLayer*, + const LogSoftmaxDescriptor&, + const char*) override { DefaultPolicy::Apply(__func__); } + void VisitLstmLayer(const IConnectableLayer*, const LstmDescriptor&, const LstmInputParams&, -- cgit v1.2.1