From f0a6dec75832604d5ab18242dc216852821a8279 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 25 Mar 2021 07:46:55 +0000 Subject: IVGCVSW-5736 and IVGCVSW-5743 'NonConstWeights: Update front-end and TfLiteDelegate support for FullyConnected Operator' * Added front-end support for non-const weights for FULLY_CONNECTED operator * Added FULLY_CONNECTED end-to-end test * Updated FULLY_CONNECTED operator support in TfLite Arm NN Delegate for non-const weights * Updated the version numbers Signed-off-by: Sadik Armagan Change-Id: Iffa5b9aa9297aca4c02d923cce4636c88ac21faa --- include/armnn/BackendHelper.hpp | 10 +++++++++- include/armnn/Descriptors.hpp | 10 +++++++++- include/armnn/INetwork.hpp | 11 +++++++++++ include/armnn/Types.hpp | 10 ++++++++++ include/armnn/Version.hpp | 2 +- include/armnn/backends/IBackendInternal.hpp | 3 +++ 6 files changed, 43 insertions(+), 3 deletions(-) (limited to 'include/armnn') diff --git a/include/armnn/BackendHelper.hpp b/include/armnn/BackendHelper.hpp index a562f60c23..41bb5f9c3a 100644 --- a/include/armnn/BackendHelper.hpp +++ b/include/armnn/BackendHelper.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace armnn { @@ -19,7 +20,10 @@ class LayerSupportHandle { public: explicit LayerSupportHandle(std::shared_ptr layerSupport) - : m_LayerSupport(std::move(layerSupport)) {}; + : m_LayerSupport(std::move(layerSupport)), m_BackendId(Compute::Undefined) {}; + + explicit LayerSupportHandle(std::shared_ptr layerSupport, const BackendId& backendId) + : m_LayerSupport(std::move(layerSupport)), m_BackendId(backendId) {}; bool IsBackendRegistered() const; @@ -422,9 +426,13 @@ public: private: std::shared_ptr m_LayerSupport; + const BackendId m_BackendId; }; /// Convenience function to retrieve the ILayerSupportHandle for a backend LayerSupportHandle GetILayerSupportByBackendId(const armnn::BackendId& backend); +/// Convenience function to check a capability on a backend +bool IsCapabilitySupported(const armnn::BackendId& backend, armnn::BackendCapability capability); + } diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp index 20511ab00f..278c61f7d4 100644 --- a/include/armnn/Descriptors.hpp +++ b/include/armnn/Descriptors.hpp @@ -391,17 +391,25 @@ struct FullyConnectedDescriptor : BaseDescriptor FullyConnectedDescriptor() : m_BiasEnabled(false) , m_TransposeWeightMatrix(false) + , m_ConstantWeights(true) {} bool operator ==(const FullyConnectedDescriptor& rhs) const { - return m_BiasEnabled == rhs.m_BiasEnabled && m_TransposeWeightMatrix == rhs.m_TransposeWeightMatrix; + return m_BiasEnabled == rhs.m_BiasEnabled + && m_TransposeWeightMatrix == rhs.m_TransposeWeightMatrix + && m_ConstantWeights == rhs.m_ConstantWeights; } + /// Get the number of views/inputs. + uint32_t GetNumViews() const; + /// Enable/disable bias. bool m_BiasEnabled; /// Enable/disable transpose weight matrix. bool m_TransposeWeightMatrix; + /// Enable/disable constant weights and biases. + bool m_ConstantWeights; }; /// A Convolution2dDescriptor for the Convolution2dLayer. diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index d1d4744a42..bceb07405a 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -297,6 +297,17 @@ public: IConnectableLayer* AddFillLayer(const FillDescriptor& fillDescriptor, const char* name = nullptr); + /// Adds a fully connected layer to the network. + /// @param fullyConnectedDescriptor - Description of the fully connected layer. + /// @param weights -Optional Tensor for the weights data. + /// @param biases - Optional tensor for the bias data. + /// @param name - Optional name for the layer. + /// @return - Interface for configuring the layer. + IConnectableLayer* AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, + const Optional& weights, + const Optional& biases, + const char* name = nullptr); + /// Adds a fully connected layer to the network. /// @param fullyConnectedDescriptor - Description of the fully connected layer. /// @param weights - Tensor for the weights data. diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp index e1ff46b023..576e67ea18 100644 --- a/include/armnn/Types.hpp +++ b/include/armnn/Types.hpp @@ -196,6 +196,16 @@ public: using IBackendSharedPtr = std::shared_ptr; using IBackendUniquePtr = std::unique_ptr; +/// BackendCapability class +enum class BackendCapability : uint32_t +{ + /// Constant weights can be accessed through the descriptors, + /// On the other hand, non-const weights can be accessed through inputs. + NonConstWeights, + + // add new enum values here +}; + /// Device specific knowledge to be passed to the optimizer. class IDeviceSpec { diff --git a/include/armnn/Version.hpp b/include/armnn/Version.hpp index d8c14ab262..2139637b5b 100644 --- a/include/armnn/Version.hpp +++ b/include/armnn/Version.hpp @@ -10,7 +10,7 @@ #define STRINGIFY_MACRO(s) #s // ArmNN version components -#define ARMNN_MAJOR_VERSION 24 +#define ARMNN_MAJOR_VERSION 25 #define ARMNN_MINOR_VERSION 0 #define ARMNN_PATCH_VERSION 0 diff --git a/include/armnn/backends/IBackendInternal.hpp b/include/armnn/backends/IBackendInternal.hpp index c7ed8efa78..8035cff456 100644 --- a/include/armnn/backends/IBackendInternal.hpp +++ b/include/armnn/backends/IBackendInternal.hpp @@ -164,6 +164,9 @@ public: /// Returns the version of the Backend API static constexpr BackendVersion GetApiVersion() { return BackendVersion(1, 0); } + + /// Returns true if backend support the capability false otherwise + virtual bool HasCapability(BackendCapability /*capabilityClass*/) const { return false; } }; using IBackendInternalUniquePtr = std::unique_ptr; -- cgit v1.2.1