From 0e406eed386a4ea015ec703c84a74ea775d88b99 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Wed, 12 Jun 2019 15:42:18 +0100 Subject: IVGCVSW-3267 Add Arm NN front end support for the new Prelu Activation layer * Added new PreluLayer class * Made necessary changes to ILayerSupport, ILayerVisitor, etc. * Added unit tests Change-Id: Ifcfb78e823bb5a245ed1dad15290d2f60115c882 Signed-off-by: Matteo Martincigh --- include/armnn/ILayerSupport.hpp | 5 +++++ include/armnn/ILayerVisitor.hpp | 6 ++++++ include/armnn/INetwork.hpp | 5 +++++ include/armnn/LayerSupport.hpp | 8 ++++++++ include/armnn/LayerVisitorBase.hpp | 3 +++ 5 files changed, 27 insertions(+) (limited to 'include') diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index 4c113d3427..324a9f5a2d 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -234,6 +234,11 @@ public: const PreCompiledDescriptor& descriptor, Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsPreluSupported(const TensorInfo& input, + const TensorInfo& alpha, + const TensorInfo& output, + Optional reasonIfUnsupported = EmptyOptional()) const = 0; + virtual bool IsQuantizeSupported(const TensorInfo& input, const TensorInfo& output, Optional reasonIfUnsupported = EmptyOptional()) const = 0; diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp index ab83dbfb05..9519c8b0c1 100644 --- a/include/armnn/ILayerVisitor.hpp +++ b/include/armnn/ILayerVisitor.hpp @@ -290,6 +290,12 @@ public: const Pooling2dDescriptor& pooling2dDescriptor, const char* name = nullptr) = 0; + /// Function that a PReLU activation 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 name - Optional name for the layer. + virtual void VisitPreluLayer(const IConnectableLayer* layer, + const char* name = nullptr) = 0; + /// Function a quantize 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 name - Optional name for the layer. diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index e5ebbc4e44..cacca33caf 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -427,6 +427,11 @@ public: /// @return - Interface for configuring the layer. virtual IConnectableLayer* AddSwitchLayer(const char* name = nullptr) = 0; + /// Adds a PReLU layer to the network. + /// @param name - Optional name for the layer. + /// @return - Interface for configuring the layer. + virtual IConnectableLayer* AddPreluLayer(const char* name = nullptr) = 0; + virtual void Accept(ILayerVisitor& visitor) const = 0; protected: diff --git a/include/armnn/LayerSupport.hpp b/include/armnn/LayerSupport.hpp index d58aa8731a..673193f330 100644 --- a/include/armnn/LayerSupport.hpp +++ b/include/armnn/LayerSupport.hpp @@ -281,6 +281,14 @@ bool IsPreCompiledSupported(const BackendId& backend, char* reasonIfUnsupported = nullptr, size_t reasonIfUnsupportedMaxLength = 1024); +/// Deprecated in favor of IBackend and ILayerSupport interfaces +bool IsPreluSupported(const BackendId& backend, + const TensorInfo& input, + const TensorInfo& alpha, + const TensorInfo& output, + char* reasonIfUnsupported = nullptr, + size_t reasonIfUnsupportedMaxLength = 1024); + /// Deprecated in favor of IBackend and ILayerSupport interfaces bool IsPooling2dSupported(const BackendId& backend, const TensorInfo& input, diff --git a/include/armnn/LayerVisitorBase.hpp b/include/armnn/LayerVisitorBase.hpp index b4a2ac7870..48fc2bbb0b 100644 --- a/include/armnn/LayerVisitorBase.hpp +++ b/include/armnn/LayerVisitorBase.hpp @@ -151,6 +151,9 @@ public: const Pooling2dDescriptor&, const char*) override { DefaultPolicy::Apply(__func__); } + void VisitPreluLayer(const IConnectableLayer*, + const char*) override { DefaultPolicy::Apply(__func__); } + void VisitQuantizeLayer(const IConnectableLayer*, const char*) override { DefaultPolicy::Apply(__func__); } -- cgit v1.2.1