aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorCathal Corbett <cathal.corbett@arm.com>2021-11-18 18:17:38 +0000
committerCathal Corbett <cathal.corbett@arm.com>2021-11-22 16:01:45 +0000
commitf0836e0d7efa947f7589c476b531944078cc02d2 (patch)
treeb179d953e9ad7d44b2d2146b5e74cd48cff4e637 /python
parent8dd77d2093b00f195a94eb909abb526190ae6a55 (diff)
downloadarmnn-f0836e0d7efa947f7589c476b531944078cc02d2.tar.gz
IVGCVSW-6591 AddLogicalBinaryLayer to PyArmNN
* AddLogicalBinaryLayer to PyArmNN armnn_network.i * LogicalBinaryDescriptor to PyArmNN armnn_descriptors.i * Add layer to test_network_method_exists() in test_network.py * Add descriptor unit tests to test_descriptors.py Signed-off-by: Cathal Corbett <cathal.corbett@arm.com> Change-Id: I2f6288987332e1556235a9c16582e96b3a0fb641
Diffstat (limited to 'python')
-rw-r--r--python/pyarmnn/src/pyarmnn/__init__.py2
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i19
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i13
-rw-r--r--python/pyarmnn/test/test_descriptors.py10
-rw-r--r--python/pyarmnn/test/test_network.py1
5 files changed, 43 insertions, 2 deletions
diff --git a/python/pyarmnn/src/pyarmnn/__init__.py b/python/pyarmnn/src/pyarmnn/__init__.py
index 44992522c0..5f3e5ff521 100644
--- a/python/pyarmnn/src/pyarmnn/__init__.py
+++ b/python/pyarmnn/src/pyarmnn/__init__.py
@@ -84,6 +84,8 @@ from ._generated.pyarmnn import ComparisonDescriptor, ComparisonOperation_Equal,
ComparisonOperation_LessOrEqual, ComparisonOperation_NotEqual
from ._generated.pyarmnn import UnaryOperation_Abs, UnaryOperation_Exp, UnaryOperation_Sqrt, UnaryOperation_Rsqrt, \
UnaryOperation_Neg, ElementwiseUnaryDescriptor
+from ._generated.pyarmnn import LogicalBinaryOperation_LogicalAnd, LogicalBinaryOperation_LogicalOr, \
+ LogicalBinaryDescriptor
from ._generated.pyarmnn import Convolution2dDescriptor, DepthToSpaceDescriptor, DepthwiseConvolution2dDescriptor, \
DetectionPostProcessDescriptor, FakeQuantizationDescriptor, FillDescriptor, FullyConnectedDescriptor, \
GatherDescriptor, InstanceNormalizationDescriptor, LstmDescriptor, L2NormalizationDescriptor, MeanDescriptor
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
index a050722bb9..8844cea81a 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
@@ -1036,6 +1036,25 @@ struct TransposeConvolution2dDescriptor
bool operator ==(const TransposeConvolution2dDescriptor& rhs) const;
};
+%feature("docstring",
+ "
+ A descriptor for the LogicalBinary layer. See `INetwork.AddLogicalBinaryLayer()`.
+
+ Contains:
+ m_Operation (int): Specifies the logical operation to execute.
+ (0: `LogicalBinaryOperation_LogicalAnd`, 1: `LogicalBinaryOperation_LogicalOr`)
+ Default: 0: `LogicalBinaryOperation_LogicalAnd`.
+
+ ") LogicalBinaryDescriptor;
+struct LogicalBinaryDescriptor
+{
+ LogicalBinaryDescriptor();
+ LogicalBinaryDescriptor(LogicalBinaryOperation operation);
+
+ LogicalBinaryOperation m_Operation;
+
+ bool operator ==(const LogicalBinaryDescriptor &rhs) const;
+};
using ConcatDescriptor = OriginsDescriptor;
using LogSoftmaxDescriptor = SoftmaxDescriptor;
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
index b114edd7c4..c978e14c80 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
@@ -993,6 +993,19 @@ public:
armnn::IConnectableLayer* AddFullyConnectedLayer(const armnn::FullyConnectedDescriptor& fullyConnectedDescriptor,
const char* name = nullptr);
+ %feature("docstring",
+ "
+ Adds a LogicalBinary layer to the network.
+
+ Args:
+ logicalBinaryDescriptor (LogicalBinaryDescriptor): Description of the LogicalBinary layer.
+ name (str): Optional name for the layer.
+
+ Returns:
+ IConnectableLayer: Interface for configuring the layer.
+ ") AddLogicalBinaryLayer;
+ armnn::IConnectableLayer* AddLogicalBinaryLayer(const armnn::LogicalBinaryDescriptor& logicalBinaryDescriptor,
+ const char* name = nullptr);
};
%extend INetwork {
diff --git a/python/pyarmnn/test/test_descriptors.py b/python/pyarmnn/test/test_descriptors.py
index 663abc6ea9..0360196614 100644
--- a/python/pyarmnn/test/test_descriptors.py
+++ b/python/pyarmnn/test/test_descriptors.py
@@ -403,6 +403,10 @@ def test_elementwise_unary_descriptor_default_values():
assert desc.m_Operation == ann.UnaryOperation_Abs
+def test_logical_binary_descriptor_default_values():
+ desc = ann.LogicalBinaryDescriptor()
+ assert desc.m_Operation == ann.LogicalBinaryOperation_LogicalAnd
+
def test_view_descriptor_incorrect_input():
desc = ann.SplitterDescriptor(2, 3)
with pytest.raises(RuntimeError) as err:
@@ -493,7 +497,8 @@ generated_classes_names = list(map(lambda x: x[0], generated_classes))
'TransposeConvolution2dDescriptor',
'ElementwiseUnaryDescriptor',
'FillDescriptor',
- 'GatherDescriptor'])
+ 'GatherDescriptor',
+ 'LogicalBinaryDescriptor'])
class TestDescriptorMassChecks:
def test_desc_implemented(self, desc_name):
@@ -537,7 +542,8 @@ generated_classes_names = list(map(lambda x: x[0], generated_classes))
'TransposeConvolution2dDescriptor',
'ElementwiseUnaryDescriptor',
'FillDescriptor',
- 'GatherDescriptor'])
+ 'GatherDescriptor',
+ 'LogicalBinaryDescriptor'])
class TestDescriptorMassChecks:
def test_desc_implemented(self, desc_name):
diff --git a/python/pyarmnn/test/test_network.py b/python/pyarmnn/test/test_network.py
index 4f37c473ac..1792041e11 100644
--- a/python/pyarmnn/test/test_network.py
+++ b/python/pyarmnn/test/test_network.py
@@ -208,6 +208,7 @@ def test_serialize_to_dot_mode_readonly(network_file, get_runtime, tmpdir):
'AddGatherLayer',
'AddInputLayer',
'AddInstanceNormalizationLayer',
+ 'AddLogicalBinaryLayer',
'AddLogSoftmaxLayer',
'AddL2NormalizationLayer',
'AddLstmLayer',