IVGCVSW-6584 AddConvolution3dLayer to PyArmNN

Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: I6d09abb75db1875d4d4075b1801fdc46a0f4ae7b
diff --git a/python/pyarmnn/src/pyarmnn/__init__.py b/python/pyarmnn/src/pyarmnn/__init__.py
index a5d5c84..1a71844 100644
--- a/python/pyarmnn/src/pyarmnn/__init__.py
+++ b/python/pyarmnn/src/pyarmnn/__init__.py
@@ -68,7 +68,7 @@
 from ._generated.pyarmnn import DataType_Float16, DataType_Float32, DataType_QAsymmU8, DataType_Signed32, \
     DataType_Boolean, DataType_QSymmS16, DataType_QSymmS8, DataType_QAsymmS8, ShapeInferenceMethod_ValidateOnly, \
     ShapeInferenceMethod_InferAndValidate
-from ._generated.pyarmnn import DataLayout_NCHW, DataLayout_NHWC
+from ._generated.pyarmnn import DataLayout_NCHW, DataLayout_NHWC, DataLayout_NCDHW, DataLayout_NDHWC
 from ._generated.pyarmnn import MemorySource_Malloc, MemorySource_Undefined, MemorySource_DmaBuf, \
     MemorySource_DmaBufProtected
 from ._generated.pyarmnn import ProfilingDetailsMethod_Undefined, ProfilingDetailsMethod_DetailsWithEvents, \
@@ -86,9 +86,10 @@
     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
+from ._generated.pyarmnn import Convolution2dDescriptor, Convolution3dDescriptor, DepthToSpaceDescriptor, \
+    DepthwiseConvolution2dDescriptor, DetectionPostProcessDescriptor, FakeQuantizationDescriptor, FillDescriptor, \
+    FullyConnectedDescriptor, GatherDescriptor, InstanceNormalizationDescriptor, LstmDescriptor, \
+    L2NormalizationDescriptor, MeanDescriptor
 from ._generated.pyarmnn import NormalizationAlgorithmChannel_Across, NormalizationAlgorithmChannel_Within, \
     NormalizationAlgorithmMethod_LocalBrightness, NormalizationAlgorithmMethod_LocalContrast, NormalizationDescriptor
 from ._generated.pyarmnn import PaddingMode_Constant, PaddingMode_Reflect, PaddingMode_Symmetric, PadDescriptor
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
index 6ab7f24..e51c867 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i
@@ -1,5 +1,5 @@
 //
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
 // SPDX-License-Identifier: MIT
 //
 %{
@@ -274,6 +274,48 @@
     bool operator ==(const Convolution2dDescriptor& rhs) const;
 };
 
+%feature("docstring",
+    "
+    A descriptor for the Convolution3d layer.  See `INetwork.AddConvolution3dLayer()`.
+
+    Contains:
+        m_PadLeft (int): Underlying C++ data type is uint32_t. Padding left value in the width dimension. Default: 0.
+        m_PadRight (int): Underlying C++ data type is uint32_t. Padding right value in the width dimension. Default: 0.
+        m_PadTop (int): Underlying C++ data type is uint32_t. Padding top value in the height dimension. Default: 0.
+        m_PadBottom (int): Underlying C++ data type is uint32_t. Padding bottom value in the height dimension. Default: 0.
+        m_PadFront (int): Underlying C++ data type is uint32_t. Padding front value in the depth dimension. Default: 0.
+        m_PadBack (int): Underlying C++ data type is uint32_t. Padding back value in the depth dimension. Default: 0.
+        m_StrideX (int): Underlying C++ data type is uint32_t. Stride value when proceeding through input for the width dimension. Default: 0.
+        m_StrideY (int): Underlying C++ data type is uint32_t. Stride value when proceeding through input for the height dimension. Default: 0.
+        m_StrideZ (int): Underlying C++ data type is uint32_t. Stride value when proceeding through input for the depth dimension. Default: 0.
+        m_DilationX (int): Underlying C++ data type is uint32_t. Dilation along x axis. Default: 1.
+        m_DilationY (int): Underlying C++ data type is uint32_t. Dilation along y axis. Default: 1.
+        m_DilationZ (int): Underlying C++ data type is uint32_t. Dilation along z axis. Default: 1.
+        m_BiasEnabled (bool): Enable/disable bias. Default: false.
+        m_DataLayout (int): The data layout to be used (`DataLayout_NDHWC`, `DataLayout_NCDHW`). Default: 3 `DataLayout_NDHWC`.
+
+    ") Convolution3dDescriptor;
+struct Convolution3dDescriptor
+{
+    Convolution3dDescriptor();
+
+    uint32_t             m_PadLeft;
+    uint32_t             m_PadRight;
+    uint32_t             m_PadTop;
+    uint32_t             m_PadBottom;
+    uint32_t             m_PadFront;
+    uint32_t             m_PadBack;
+    uint32_t             m_StrideX;
+    uint32_t             m_StrideY;
+    uint32_t             m_StrideZ;
+    uint32_t             m_DilationX;
+    uint32_t             m_DilationY;
+    uint32_t             m_DilationZ;
+    bool                 m_BiasEnabled;
+    DataLayout           m_DataLayout;
+
+    bool operator ==(const Convolution3dDescriptor& rhs) const;
+};
 
 %feature("docstring",
     "
diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
index 3e3a365..fe626dc 100644
--- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
+++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i
@@ -1,5 +1,5 @@
 //
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
 // SPDX-License-Identifier: MIT
 //
 %{
@@ -467,7 +467,7 @@
             IConnectableLayer: Interface for configuring the layer.
         ") AddConcatLayer;
     armnn::IConnectableLayer* AddConcatLayer(const armnn::ConcatDescriptor& concatDescriptor,
-                                              const char* name = nullptr);
+                                             const char* name = nullptr);
 
 
     %feature("docstring",
@@ -484,7 +484,24 @@
             IConnectableLayer: Interface for configuring the layer.
         ") AddConstantLayer;
     armnn::IConnectableLayer* AddConstantLayer(const armnn::ConstTensor& input,
-                                                const char* name = nullptr);
+                                               const char* name = nullptr);
+
+
+    %feature("docstring",
+             "
+    Adds a 3D Convolution layer to the network.
+
+            Args:
+    convolution3dDescriptor (Convolution3dDescriptor): Description of the 3D convolution layer.
+            name (str): Optional name for the layer.
+
+            Returns:
+    IConnectableLayer: Interface for configuring the layer.
+    ") AddConvolution3dLayer;
+
+    armnn::IConnectableLayer* AddConvolution3dLayer(const armnn::Convolution3dDescriptor& convolution3dDescriptor,
+    const char* name = nullptr);
+
 
     %feature("docstring",
         "
@@ -498,7 +515,7 @@
             IConnectableLayer: Interface for configuring the layer.
         ") AddDepthToSpaceLayer;
     armnn::IConnectableLayer* AddDepthToSpaceLayer(const armnn::DepthToSpaceDescriptor& depthToSpaceDescriptor,
-                                                    const char* name = nullptr);
+                                                   const char* name = nullptr);
 
     %feature("docstring",
         "
@@ -609,7 +626,7 @@
             IConnectableLayer: Interface for configuring the layer.
         ") AddInstanceNormalizationLayer;
     armnn::IConnectableLayer* AddInstanceNormalizationLayer(const armnn::InstanceNormalizationDescriptor& desc,
-                                                             const char* name = nullptr);
+                                                            const char* name = nullptr);
 
     %feature("docstring",
         "
@@ -1129,9 +1146,9 @@
             IConnectableLayer: Interface for configuring the layer.
         ") AddConvolution2dLayer;
     armnn::IConnectableLayer* AddConvolution2dLayer(const armnn::Convolution2dDescriptor& convolution2dDescriptor,
-                                                     const armnn::ConstTensor& weights,
-                                                     armnn::ConstTensor* biases = nullptr,
-                                                     const char* name = nullptr) {
+                                                    const armnn::ConstTensor& weights,
+                                                    armnn::ConstTensor* biases = nullptr,
+                                                    const char* name = nullptr) {
 
         if (biases) {
             return $self->AddConvolution2dLayer(convolution2dDescriptor, weights,
@@ -1142,6 +1159,7 @@
         }
     }
 
+
     %feature("docstring",
         "
         Adds a 2D Depthwise Convolution layer to the network.
diff --git a/python/pyarmnn/test/test_descriptors.py b/python/pyarmnn/test/test_descriptors.py
index 507afad..54b79d7 100644
--- a/python/pyarmnn/test/test_descriptors.py
+++ b/python/pyarmnn/test/test_descriptors.py
@@ -1,4 +1,4 @@
-# Copyright © 2020 Arm Ltd. All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
 # SPDX-License-Identifier: MIT
 import inspect
 
@@ -101,6 +101,23 @@
     assert desc.m_BiasEnabled == False
     assert desc.m_DataLayout == ann.DataLayout_NCHW
 
+def test_convolution3d_descriptor_default_values():
+    desc = ann.Convolution3dDescriptor()
+    assert desc.m_PadLeft == 0
+    assert desc.m_PadTop == 0
+    assert desc.m_PadRight == 0
+    assert desc.m_PadBottom == 0
+    assert desc.m_PadFront == 0
+    assert desc.m_PadBack == 0
+    assert desc.m_StrideX == 1
+    assert desc.m_StrideY == 1
+    assert desc.m_StrideZ == 1
+    assert desc.m_DilationX == 1
+    assert desc.m_DilationY == 1
+    assert desc.m_DilationZ == 1
+    assert desc.m_BiasEnabled == False
+    assert desc.m_DataLayout == ann.DataLayout_NDHWC
+
 
 def test_depthtospace_descriptor_default_values():
     desc = ann.DepthToSpaceDescriptor()
@@ -486,6 +503,7 @@
                                        'Pooling2dDescriptor',
                                        'FullyConnectedDescriptor',
                                        'Convolution2dDescriptor',
+                                       'Convolution3dDescriptor',
                                        'DepthwiseConvolution2dDescriptor',
                                        'DetectionPostProcessDescriptor',
                                        'NormalizationDescriptor',
@@ -532,6 +550,7 @@
                                        'Pooling2dDescriptor',
                                        'FullyConnectedDescriptor',
                                        'Convolution2dDescriptor',
+                                       'Convolution3dDescriptor',
                                        'DepthwiseConvolution2dDescriptor',
                                        'DetectionPostProcessDescriptor',
                                        'NormalizationDescriptor',
diff --git a/python/pyarmnn/test/test_network.py b/python/pyarmnn/test/test_network.py
index d734f61..04e1b7a 100644
--- a/python/pyarmnn/test/test_network.py
+++ b/python/pyarmnn/test/test_network.py
@@ -1,4 +1,4 @@
-# Copyright © 2020 Arm Ltd. All rights reserved.
+# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
 # SPDX-License-Identifier: MIT
 import os
 import stat
@@ -197,6 +197,7 @@
     'AddConcatLayer',
     'AddConstantLayer',
     'AddConvolution2dLayer',
+    'AddConvolution3dLayer',
     'AddDepthToSpaceLayer',
     'AddDepthwiseConvolution2dLayer',
     'AddDequantizeLayer',