aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorjosh minor <josh.minor@arm.com>2020-01-06 16:40:46 -0600
committerDerek Lamberti <derek.lamberti@arm.com>2020-01-23 14:29:14 +0000
commit4a3c61091037e7e86e8b03bb060d8c1ab82731a9 (patch)
tree928644023400ad5ac0c26b33dfff2f975567d6e8 /include
parent190a39a4a9598e42b636ae4ab843761884148160 (diff)
downloadarmnn-4a3c61091037e7e86e8b03bb060d8c1ab82731a9.tar.gz
IVGCVSW-4259 Add frontend and reference workload for UnaryOperationLayer
* Added new layer named ElementwiseUnary * Deprecated existing Abs/Rsqrt layer functions * Updated existing Abs/Rsqrt test infrastructure to use new layer * Added boilerplate for new Exp,Neg,Sqrt elemwise op layers * AbsQuantize test removed pending future commit * Serialization support added !android-nn-driver:2550 Change-Id: Ic595c645925e17b45db568187fd05646daf2e87f Signed-off-by: josh minor <josh.minor@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/armnn/Descriptors.hpp20
-rw-r--r--include/armnn/DescriptorsFwd.hpp1
-rw-r--r--include/armnn/ILayerSupport.hpp7
-rw-r--r--include/armnn/ILayerVisitor.hpp10
-rw-r--r--include/armnn/INetwork.hpp9
-rw-r--r--include/armnn/LayerVisitorBase.hpp4
-rw-r--r--include/armnn/Types.hpp9
-rw-r--r--include/armnn/TypesUtils.hpp13
8 files changed, 73 insertions, 0 deletions
diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp
index ba9a56ad38..45c0f421f3 100644
--- a/include/armnn/Descriptors.hpp
+++ b/include/armnn/Descriptors.hpp
@@ -78,6 +78,26 @@ struct ComparisonDescriptor
ComparisonOperation m_Operation;
};
+/// A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer
+struct ElementwiseUnaryDescriptor
+{
+ ElementwiseUnaryDescriptor()
+ : ElementwiseUnaryDescriptor(UnaryOperation::Abs)
+ {}
+
+ ElementwiseUnaryDescriptor(UnaryOperation operation)
+ : m_Operation(operation)
+ {}
+
+ bool operator ==(const ElementwiseUnaryDescriptor &rhs) const
+ {
+ return m_Operation == rhs.m_Operation;
+ }
+
+ /// Specifies the elementwiseUnary operation to execute
+ UnaryOperation m_Operation;
+};
+
/// A PermuteDescriptor for the PermuteLayer.
struct PermuteDescriptor
{
diff --git a/include/armnn/DescriptorsFwd.hpp b/include/armnn/DescriptorsFwd.hpp
index cfdef8a030..d03c61d452 100644
--- a/include/armnn/DescriptorsFwd.hpp
+++ b/include/armnn/DescriptorsFwd.hpp
@@ -16,6 +16,7 @@ struct ComparisonDescriptor;
struct Convolution2dDescriptor;
struct DepthwiseConvolution2dDescriptor;
struct DetectionPostProcessDescriptor;
+struct ElementwiseUnaryDescriptor;
struct FakeQuantizationDescriptor;
struct FullyConnectedDescriptor;
struct InstanceNormalizationDescriptor;
diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp
index 452200291e..1615d3e24e 100644
--- a/include/armnn/ILayerSupport.hpp
+++ b/include/armnn/ILayerSupport.hpp
@@ -27,6 +27,7 @@ protected:
virtual ~ILayerSupport() {}
public:
+ ARMNN_DEPRECATED_MSG("Use IsElementwiseUnarySupported instead")
virtual bool IsAbsSupported(const TensorInfo& input,
const TensorInfo& output,
Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
@@ -133,6 +134,11 @@ public:
const TensorInfo& output,
Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
+ virtual bool IsElementwiseUnarySupported(const TensorInfo& input,
+ const TensorInfo& output,
+ const ElementwiseUnaryDescriptor& descriptor,
+ Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
+
ARMNN_DEPRECATED_MSG("Use IsComparisonSupported instead")
virtual bool IsEqualSupported(const TensorInfo& input0,
const TensorInfo& input1,
@@ -292,6 +298,7 @@ public:
const ResizeDescriptor& descriptor,
Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
+ ARMNN_DEPRECATED_MSG("Use IsElementwiseUnarySupported instead")
virtual bool IsRsqrtSupported(const TensorInfo& input,
const TensorInfo& output,
Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp
index 9669b3a7cb..46f9e5698f 100644
--- a/include/armnn/ILayerVisitor.hpp
+++ b/include/armnn/ILayerVisitor.hpp
@@ -24,6 +24,7 @@ public:
/// function is invoked.
/// @param layer - pointer to the layer which is calling back to this visit function.
/// @param name - Optional name for the layer.
+ ARMNN_DEPRECATED_MSG("Use VisitElementwiseUnaryLayer instead")
virtual void VisitAbsLayer(const IConnectableLayer* layer,
const char* name = nullptr) = 0;
@@ -168,6 +169,14 @@ public:
virtual void VisitDivisionLayer(const IConnectableLayer* layer,
const char* name = nullptr) = 0;
+ /// Function a ElementwiseUnary 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 elementwiseUnaryDescriptor - Description of the layer.
+ /// @param name - Optional name for the layer.
+ virtual void VisitElementwiseUnaryLayer(const IConnectableLayer* layer,
+ const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor,
+ const char* name = nullptr) = 0;
+
/// Function an Equal 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.
@@ -388,6 +397,7 @@ public:
/// function is invoked.
/// @param layer - pointer to the layer which is calling back to this visit function.
/// @param name - Optional name for the layer.
+ ARMNN_DEPRECATED_MSG("Use VisitElementwiseUnaryLayer instead")
virtual void VisitRsqrtLayer(const IConnectableLayer* layer,
const char* name = nullptr) = 0;
diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp
index 647f072804..1b1c874f8c 100644
--- a/include/armnn/INetwork.hpp
+++ b/include/armnn/INetwork.hpp
@@ -196,6 +196,13 @@ public:
const ConstTensor& anchors,
const char* name = nullptr) = 0;
+ /// Add an ElementwiseUnary layer to the network.
+ /// @param name - Optional name for the layer.
+ /// @param desc - Descriptor for the elementwiseUnary operation.
+ /// @ return - Interface for configuring the layer.
+ virtual IConnectableLayer* AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor,
+ const char* name = nullptr) = 0;
+
/// Adds a fully connected layer to the network.
/// @param fullyConnectedDescriptor - Description of the fully connected layer.
/// @param weights - Tensor for the weights data.
@@ -297,6 +304,7 @@ public:
/// Add absolute layer to the network.
/// @param name - Optional name for the layer.
/// @ return - Interface for configuring the layer.
+ ARMNN_DEPRECATED_MSG("Use AddElementwiseUnaryLayer instead")
virtual IConnectableLayer* AddAbsLayer(const char* name = nullptr) = 0;
/// Adds an addition layer to the network.
@@ -474,6 +482,7 @@ public:
/// Add Reciprocal of square root layer to the network.
/// @param name - Optional name for the layer.
/// @ return - Interface for configuring the layer.
+ ARMNN_DEPRECATED_MSG("Use AddElementwiseUnaryLayer instead")
virtual IConnectableLayer* AddRsqrtLayer(const char* name = nullptr) = 0;
/// Add Gather layer to the network.
diff --git a/include/armnn/LayerVisitorBase.hpp b/include/armnn/LayerVisitorBase.hpp
index 388fc6f922..6fd9a66c76 100644
--- a/include/armnn/LayerVisitorBase.hpp
+++ b/include/armnn/LayerVisitorBase.hpp
@@ -94,6 +94,10 @@ public:
void VisitDivisionLayer(const IConnectableLayer*,
const char*) override { DefaultPolicy::Apply(__func__); }
+ void VisitElementwiseUnaryLayer(const IConnectableLayer*,
+ const ElementwiseUnaryDescriptor&,
+ const char*) override { DefaultPolicy::Apply(__func__); }
+
void VisitEqualLayer(const IConnectableLayer*,
const char*) override { DefaultPolicy::Apply(__func__); }
diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp
index 5ea214e1dc..1ab5660109 100644
--- a/include/armnn/Types.hpp
+++ b/include/armnn/Types.hpp
@@ -80,6 +80,15 @@ enum class ComparisonOperation
NotEqual = 5
};
+enum class UnaryOperation
+{
+ Abs = 0,
+ Exp = 1,
+ Sqrt = 2,
+ Rsqrt = 3,
+ Neg = 4
+};
+
enum class PoolingAlgorithm
{
Max = 0,
diff --git a/include/armnn/TypesUtils.hpp b/include/armnn/TypesUtils.hpp
index 8157d4f043..790f57a432 100644
--- a/include/armnn/TypesUtils.hpp
+++ b/include/armnn/TypesUtils.hpp
@@ -66,6 +66,19 @@ constexpr char const* GetComparisonOperationAsCString(ComparisonOperation operat
}
}
+constexpr char const* GetUnaryOperationAsCString(UnaryOperation operation)
+{
+ switch (operation)
+ {
+ case UnaryOperation::Abs: return "Abs";
+ case UnaryOperation::Exp: return "Exp";
+ case UnaryOperation::Sqrt: return "Sqrt";
+ case UnaryOperation::Rsqrt: return "Rsqrt";
+ case UnaryOperation::Neg: return "Neg";
+ default: return "Unknown";
+ }
+}
+
constexpr char const* GetPoolingAlgorithmAsCString(PoolingAlgorithm pooling)
{
switch (pooling)