From bd4491b4ba57612b8aa3a9302a4069abe2817fae Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Thu, 19 May 2022 12:32:21 +0100 Subject: IVGCVSW-6550 Synchronize include/armnn and PyArmNN swig modules. * armnn_network.i: IVGCVSW-6127 ConstTensorsAsInput: DepthwiseConvolution2d. * armnn_descriptors.i: IVGCVSW-6127 ConstTensorsAsInput: DepthwiseConvolution2d. MLCE-604 Add Unidirectional Sequence Lstm support to TFLite. MLCE-530 Add support for UnidirectionalSequenceLstm to RefWorkload Signed-off-by: Colm Donelan Change-Id: I0c054db17dbf9a1eb14c12d1fd1337f8003a92d3 --- .../src/pyarmnn/swig/modules/armnn_descriptors.i | 19 +++++++++++++-- .../src/pyarmnn/swig/modules/armnn_network.i | 23 ++++++++++++++---- python/pyarmnn/test/test_network.py | 28 ---------------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i index c64fef3d4f..9374945daf 100644 --- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i +++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_descriptors.i @@ -388,7 +388,9 @@ struct DepthwiseConvolution2dDescriptor bool m_BiasEnabled; DataLayout m_DataLayout; - bool operator ==(const DepthwiseConvolution2dDescriptor& rhs) const; + bool operator ==(const DepthwiseConvolution2dDescriptor& rhs) const; + + uint32_t GetNumInputs() const; }; %feature("docstring", @@ -544,7 +546,13 @@ struct InstanceNormalizationDescriptor m_PeepholeEnabled (bool): Enable/disable peephole. Default: false. m_ProjectionEnabled (bool): Enable/disable the projection layer. Default: false. m_LayerNormEnabled (bool): Enable/disable layer normalization. Default: false. - + m_TimeMajor (bool): Enable/disable time major. Default: false. + m_InputIntermediateScale (float): Input intermediate quantization scale. Default: 0.0. + m_ForgetIntermediateScale (float): Forget intermediate quantization scale. Default: 0.0. + m_CellIntermediateScale (float): Cell intermediate quantization scale. Default: 0.0. + m_OutputIntermediateScale (float): Output intermediate quantization scale. Default: 0.0. + m_HiddenStateZeroPoint (int): Hidden State zero point. Default: 0. + m_HiddenStateScale (float): Hidden State quantization scale. Default: 0.0. ") LstmDescriptor; struct LstmDescriptor { @@ -557,6 +565,13 @@ struct LstmDescriptor bool m_PeepholeEnabled; bool m_ProjectionEnabled; bool m_LayerNormEnabled; + bool m_TimeMajor; + float m_InputIntermediateScale; + float m_ForgetIntermediateScale; + float m_CellIntermediateScale; + float m_OutputIntermediateScale; + int32_t m_HiddenStateZeroPoint; + float m_HiddenStateScale; bool operator ==(const LstmDescriptor& rhs) const; }; diff --git a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i index 74ae8c1cd2..a2f57a3aa9 100644 --- a/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i +++ b/python/pyarmnn/src/pyarmnn/swig/modules/armnn_network.i @@ -532,6 +532,22 @@ public: armnn::IConnectableLayer* AddDepthToSpaceLayer(const armnn::DepthToSpaceDescriptor& depthToSpaceDescriptor, const char* name = nullptr); + %feature("docstring", + " + Adds a 2D Depthwise Convolution layer to the network. + + Args: + convolution2dDescriptor (DepthwiseConvolution2dDescriptor): Description of the 2D depthwise convolution layer. + name (str): Optional name for the layer. + + Returns: + IConnectableLayer: Interface for configuring the layer. + ") AddDepthwiseConvolution2dLayer; + + armnn::IConnectableLayer* AddDepthwiseConvolution2dLayer( + const armnn::DepthwiseConvolution2dDescriptor& convolution2dDescriptor, + const char* name = nullptr); + %feature("docstring", " Adds a Dequantize layer to the network. @@ -544,7 +560,6 @@ public: ") AddDequantizeLayer; armnn::IConnectableLayer* AddDequantizeLayer(const char* name = nullptr); - %feature("docstring", " Adds a Detection PostProcess layer to the network. Detection PostProcess is a custom layer for SSD MobilenetV1. @@ -869,7 +884,6 @@ public: armnn::IConnectableLayer* AddQuantizedLstmLayer(const armnn::QuantizedLstmInputParams& params, const char* name = nullptr); - %feature("docstring", " Adds a Rank layer to the network. @@ -924,7 +938,6 @@ public: armnn::IConnectableLayer* AddResizeLayer(const armnn::ResizeDescriptor& resizeDescriptor, const char* name = nullptr); - %feature("docstring", " Adds a Shape layer to the network. @@ -1184,7 +1197,6 @@ public: } } - %feature("docstring", " Adds a 2D Depthwise Convolution layer to the network. @@ -1205,6 +1217,7 @@ public: const armnn::ConstTensor* biases = nullptr, const char* name = nullptr) { + ARMNN_NO_DEPRECATE_WARN_BEGIN if (biases) { return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, armnn::Optional(*biases), name); @@ -1212,7 +1225,9 @@ public: return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, armnn::Optional(), name); } + ARMNN_NO_DEPRECATE_WARN_END } + } %feature("docstring", diff --git a/python/pyarmnn/test/test_network.py b/python/pyarmnn/test/test_network.py index 5522bf656d..ce1dffb86b 100644 --- a/python/pyarmnn/test/test_network.py +++ b/python/pyarmnn/test/test_network.py @@ -251,34 +251,6 @@ def test_serialize_to_dot_mode_readonly(network_file, get_runtime, tmpdir): def test_network_method_exists(method): assert getattr(ann.INetwork, method, None) -def test_DepthwiseConvolution2d_layer_optional_none(): - net = ann.INetwork() - layer = net.AddDepthwiseConvolution2dLayer(convolution2dDescriptor=ann.DepthwiseConvolution2dDescriptor(), - weights=ann.ConstTensor()) - - assert layer - - -def test_DepthwiseConvolution2d_layer_optional_provided(): - net = ann.INetwork() - layer = net.AddDepthwiseConvolution2dLayer(convolution2dDescriptor=ann.DepthwiseConvolution2dDescriptor(), - weights=ann.ConstTensor(), - biases=ann.ConstTensor()) - - assert layer - - -def test_DepthwiseConvolution2d_layer_all_args(): - net = ann.INetwork() - layer = net.AddDepthwiseConvolution2dLayer(convolution2dDescriptor=ann.DepthwiseConvolution2dDescriptor(), - weights=ann.ConstTensor(), - biases=ann.ConstTensor(), - name='NAME1') - - assert layer - assert 'NAME1' == layer.GetName() - - def test_Convolution2d_layer_optional_none(): net = ann.INetwork() layer = net.AddConvolution2dLayer(convolution2dDescriptor=ann.Convolution2dDescriptor(), -- cgit v1.2.1