From: FrancisMurtagh Date: Mon, 17 Dec 2018 12:11:36 +0000 (+0000) Subject: IVGCVSW-2398 Add no-op factory implementations for all backends for the X-Git-Tag: submit/tizen/20200316.035456~991 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2099595bac339c953bf4291be12703c8845e916e;p=platform%2Fupstream%2Farmnn.git IVGCVSW-2398 Add no-op factory implementations for all backends for the Equal operation * Add QueueDescriptor in WorkloadData.hpp * Add CreateEqual function in WorkloadFactory.hpp * Added stub implementation of the CreateEqual function in RefWorkloadFactory, NeonWorkloadFactory and ClWorkloadFactory Change-Id: Iec6dc2f989c67fa6f0c32cfb93508995c8580783 --- diff --git a/Android.mk b/Android.mk index e4033d5..ad8026a 100644 --- a/Android.mk +++ b/Android.mk @@ -93,6 +93,7 @@ LOCAL_SRC_FILES := \ src/armnn/layers/DebugLayer.cpp \ src/armnn/layers/DepthwiseConvolution2dLayer.cpp \ src/armnn/layers/ElementwiseBaseLayer.cpp \ + src/armnn/layers/EqualLayer.cpp \ src/armnn/layers/FakeQuantizationLayer.cpp \ src/armnn/layers/FloorLayer.cpp \ src/armnn/layers/FullyConnectedLayer.cpp \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 370b94c..2f35e82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,6 +194,8 @@ list(APPEND armnn_sources src/armnn/layers/DepthwiseConvolution2dLayer.cpp src/armnn/layers/ElementwiseBaseLayer.hpp src/armnn/layers/ElementwiseBaseLayer.cpp + src/armnn/layers/EqualLayer.hpp + src/armnn/layers/EqualLayer.cpp src/armnn/layers/FakeQuantizationLayer.hpp src/armnn/layers/FakeQuantizationLayer.cpp src/armnn/layers/FloorLayer.hpp diff --git a/include/armnn/ILayerSupport.hpp b/include/armnn/ILayerSupport.hpp index 71ad50d..e8840cb 100644 --- a/include/armnn/ILayerSupport.hpp +++ b/include/armnn/ILayerSupport.hpp @@ -81,6 +81,11 @@ public: const TensorInfo& output, Optional reasonIfUnsupported = EmptyOptional()) const; + virtual bool IsEqualSupported(const TensorInfo& input0, + const TensorInfo& input1, + const TensorInfo& output, + Optional reasonIfUnsupported = EmptyOptional()) const; + virtual bool IsFakeQuantizationSupported(const TensorInfo& input, const FakeQuantizationDescriptor& descriptor, Optional reasonIfUnsupported = EmptyOptional()) const; diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index 7c88cf0..63fd78b 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -333,6 +333,11 @@ public: /// @ return - Interface for configuring the layer. virtual IConnectableLayer* AddGreaterLayer(const char* name = nullptr) = 0; + /// Add a Equal layer to the network. + /// @param name - Optional name for the layer. + /// @ return - Interface for configuring the layer. + virtual IConnectableLayer* AddEqualLayer(const char* name = nullptr) = 0; + protected: ~INetwork() {} }; diff --git a/include/armnn/LayerSupport.hpp b/include/armnn/LayerSupport.hpp index 5b96bc6..5a5ba98 100644 --- a/include/armnn/LayerSupport.hpp +++ b/include/armnn/LayerSupport.hpp @@ -295,4 +295,11 @@ bool IsGreaterSupported(const BackendId& backend, char* reasonIfUnsupported = nullptr, size_t reasonIfUnsupportedMaxLength = 1024); +/// Deprecated in favor of IBackend and ILayerSupport interfaces +bool IsEqualSupported(const BackendId& backend, + const TensorInfo& input0, + const TensorInfo& input1, + const TensorInfo& output, + char* reasonIfUnsupported = nullptr, + size_t reasonIfUnsupportedMaxLength = 1024); } diff --git a/src/armnn/InternalTypes.cpp b/src/armnn/InternalTypes.cpp index 845ba9e..fe806f1 100644 --- a/src/armnn/InternalTypes.cpp +++ b/src/armnn/InternalTypes.cpp @@ -25,6 +25,7 @@ char const* GetLayerTypeAsCString(LayerType type) case LayerType::Debug: return "Debug"; case LayerType::DepthwiseConvolution2d: return "DepthwiseConvolution2d"; case LayerType::Division: return "Division"; + case LayerType::Equal: return "Equal"; case LayerType::FakeQuantization: return "FakeQuantization"; case LayerType::Floor: return "Floor"; case LayerType::FullyConnected: return "FullyConnected"; diff --git a/src/armnn/InternalTypes.hpp b/src/armnn/InternalTypes.hpp index 27a1359..c6b5c04 100644 --- a/src/armnn/InternalTypes.hpp +++ b/src/armnn/InternalTypes.hpp @@ -25,6 +25,7 @@ enum class LayerType Debug, DepthwiseConvolution2d, Division, + Equal, FakeQuantization, Floor, FullyConnected, diff --git a/src/armnn/LayerSupport.cpp b/src/armnn/LayerSupport.cpp index d1161b6..3c864c5 100644 --- a/src/armnn/LayerSupport.cpp +++ b/src/armnn/LayerSupport.cpp @@ -455,4 +455,14 @@ bool IsGreaterSupported(const BackendId& backend, FORWARD_LAYER_SUPPORT_FUNC(backend, IsGreaterSupported, input0, input1, output); } +bool IsEqualSupported(const BackendId& backend, + const TensorInfo& input0, + const TensorInfo& input1, + const TensorInfo& output, + char* reasonIfUnsupported, + size_t reasonIfUnsupportedMaxLength) +{ + FORWARD_LAYER_SUPPORT_FUNC(backend, IsEqualSupported, input0, input1, output); +} + } diff --git a/src/armnn/LayersFwd.hpp b/src/armnn/LayersFwd.hpp index 39b0b20..c9a12a6 100644 --- a/src/armnn/LayersFwd.hpp +++ b/src/armnn/LayersFwd.hpp @@ -17,6 +17,7 @@ #include "layers/DebugLayer.hpp" #include "layers/DepthwiseConvolution2dLayer.hpp" #include "layers/DivisionLayer.hpp" +#include "layers/EqualLayer.hpp" #include "layers/FakeQuantizationLayer.hpp" #include "layers/FloorLayer.hpp" #include "layers/FullyConnectedLayer.hpp" @@ -81,6 +82,7 @@ DECLARE_LAYER(Convolution2d) DECLARE_LAYER(Debug) DECLARE_LAYER(DepthwiseConvolution2d) DECLARE_LAYER(Division) +DECLARE_LAYER(Equal) DECLARE_LAYER(FakeQuantization) DECLARE_LAYER(Floor) DECLARE_LAYER(FullyConnected) diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index 7a7e180..d798c84 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -722,6 +722,11 @@ IConnectableLayer* Network::AddGreaterLayer(const char* name) return m_Graph->AddLayer(name); } +IConnectableLayer* Network::AddEqualLayer(const char* name) +{ + return m_Graph->AddLayer(name); +} + OptimizedNetwork::OptimizedNetwork(std::unique_ptr graph) : m_Graph(std::move(graph)) { diff --git a/src/armnn/Network.hpp b/src/armnn/Network.hpp index 31e86ac..f36ca4f 100644 --- a/src/armnn/Network.hpp +++ b/src/armnn/Network.hpp @@ -137,6 +137,8 @@ public: IConnectableLayer* AddGreaterLayer(const char* name = nullptr) override; + IConnectableLayer* AddEqualLayer(const char* name = nullptr) override; + private: IConnectableLayer* AddFullyConnectedLayerImpl(const FullyConnectedDescriptor& fullyConnectedDescriptor, const ConstTensor& weights, diff --git a/src/armnn/layers/EqualLayer.cpp b/src/armnn/layers/EqualLayer.cpp new file mode 100644 index 0000000..e0d2e65 --- /dev/null +++ b/src/armnn/layers/EqualLayer.cpp @@ -0,0 +1,34 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "EqualLayer.hpp" + +#include "LayerCloneBase.hpp" + +#include +#include +#include + +namespace armnn +{ + +EqualLayer::EqualLayer(const char* name) + : ElementwiseBaseLayer(2, 1, LayerType::Equal, name) +{ +} + +std::unique_ptr EqualLayer::CreateWorkload(const Graph& graph, + const IWorkloadFactory& factory) const +{ + EqualQueueDescriptor descriptor; + return factory.CreateEqual(descriptor, PrepInfoAndDesc(descriptor, graph)); +} + +EqualLayer* EqualLayer::Clone(Graph& graph) const +{ + return CloneBase(graph, GetName()); +} + +} // namespace armnn diff --git a/src/armnn/layers/EqualLayer.hpp b/src/armnn/layers/EqualLayer.hpp new file mode 100644 index 0000000..956ae3c --- /dev/null +++ b/src/armnn/layers/EqualLayer.hpp @@ -0,0 +1,26 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "ElementwiseBaseLayer.hpp" + +namespace armnn +{ + +class EqualLayer : public ElementwiseBaseLayer +{ +public: + virtual std::unique_ptr CreateWorkload(const Graph& graph, + const IWorkloadFactory& factory) const override; + + EqualLayer* Clone(Graph& graph) const override; + +protected: + EqualLayer(const char* name); + ~EqualLayer() = default; +}; + +} //namespace armnn diff --git a/src/backends/backendsCommon/ILayerSupport.cpp b/src/backends/backendsCommon/ILayerSupport.cpp index 3718df1..1f058af 100644 --- a/src/backends/backendsCommon/ILayerSupport.cpp +++ b/src/backends/backendsCommon/ILayerSupport.cpp @@ -123,6 +123,14 @@ bool ILayerSupport::IsDivisionSupported(const TensorInfo& input0, return DefaultLayerSupport(__func__, __FILE__, __LINE__, reasonIfUnsupported); } +bool ILayerSupport::IsEqualSupported(const armnn::TensorInfo& input0, + const armnn::TensorInfo& input1, + const armnn::TensorInfo& output, + armnn::Optional reasonIfUnsupported) const +{ + return DefaultLayerSupport(__func__, __FILE__, __LINE__, reasonIfUnsupported); +} + bool ILayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, const FakeQuantizationDescriptor& descriptor, Optional reasonIfUnsupported) const diff --git a/src/backends/backendsCommon/WorkloadData.hpp b/src/backends/backendsCommon/WorkloadData.hpp index 88b0d5e..9142d87 100644 --- a/src/backends/backendsCommon/WorkloadData.hpp +++ b/src/backends/backendsCommon/WorkloadData.hpp @@ -217,6 +217,12 @@ struct PadQueueDescriptor : QueueDescriptorWithParameters void Validate(const WorkloadInfo& workloadInfo) const; }; +// Equal layer workload data +struct EqualQueueDescriptor : QueueDescriptor +{ + void Validate(const WorkloadInfo& workloadInfo) const; +}; + // Batch norm layer workload data. struct BatchNormalizationQueueDescriptor : QueueDescriptorWithParameters { diff --git a/src/backends/backendsCommon/WorkloadFactory.cpp b/src/backends/backendsCommon/WorkloadFactory.cpp index d7704ff..3b8a7d8 100644 --- a/src/backends/backendsCommon/WorkloadFactory.cpp +++ b/src/backends/backendsCommon/WorkloadFactory.cpp @@ -240,6 +240,17 @@ bool IWorkloadFactory::IsLayerSupported(const BackendId& backendId, reason); break; } + case LayerType::Equal: + { + const TensorInfo& input0 = layer.GetInputSlot(0).GetConnection()->GetTensorInfo(); + const TensorInfo& input1 = layer.GetInputSlot(1).GetConnection()->GetTensorInfo(); + const TensorInfo& output = layer.GetOutputSlot(0).GetTensorInfo(); + result = layerSupportObject->IsEqualSupported(OverrideDataType(input0, dataType), + OverrideDataType(input1, dataType), + OverrideDataType(output, dataType), + reason); + break; + } case LayerType::FakeQuantization: { auto cLayer = boost::polymorphic_downcast(&layer); diff --git a/src/backends/backendsCommon/WorkloadFactory.hpp b/src/backends/backendsCommon/WorkloadFactory.hpp index 57f6196..e72987f 100644 --- a/src/backends/backendsCommon/WorkloadFactory.hpp +++ b/src/backends/backendsCommon/WorkloadFactory.hpp @@ -145,6 +145,9 @@ public: virtual std::unique_ptr CreatePad(const PadQueueDescriptor& descriptor, const WorkloadInfo& Info) const = 0; + virtual std::unique_ptr CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& Info) const = 0; + virtual std::unique_ptr CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, const WorkloadInfo& Info) const = 0; diff --git a/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp b/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp index dc4f05e..d4c5fe4 100644 --- a/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp +++ b/src/backends/backendsCommon/test/IsLayerSupportedTestImpl.hpp @@ -336,6 +336,8 @@ DECLARE_LAYER_POLICY_2_PARAM(Debug) DECLARE_LAYER_POLICY_2_PARAM(DepthwiseConvolution2d) +DECLARE_LAYER_POLICY_1_PARAM(Equal) + DECLARE_LAYER_POLICY_2_PARAM(FakeQuantization) DECLARE_LAYER_POLICY_1_PARAM(Floor) diff --git a/src/backends/cl/ClWorkloadFactory.cpp b/src/backends/cl/ClWorkloadFactory.cpp index ebd957b..16ca2e6 100644 --- a/src/backends/cl/ClWorkloadFactory.cpp +++ b/src/backends/cl/ClWorkloadFactory.cpp @@ -314,6 +314,12 @@ std::unique_ptr ClWorkloadFactory::CreatePad(const PadQueueDescriptor return MakeWorkload(descriptor, info); } +std::unique_ptr ClWorkloadFactory::CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const +{ + return MakeWorkload(descriptor, info); +} + std::unique_ptr ClWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& info) const { diff --git a/src/backends/cl/ClWorkloadFactory.hpp b/src/backends/cl/ClWorkloadFactory.hpp index 70052c4..2844721 100644 --- a/src/backends/cl/ClWorkloadFactory.hpp +++ b/src/backends/cl/ClWorkloadFactory.hpp @@ -129,6 +129,9 @@ public: virtual std::unique_ptr CreatePad(const PadQueueDescriptor& descriptor, const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& info) const override; diff --git a/src/backends/neon/NeonWorkloadFactory.cpp b/src/backends/neon/NeonWorkloadFactory.cpp index d7de17a..f7b2133 100644 --- a/src/backends/neon/NeonWorkloadFactory.cpp +++ b/src/backends/neon/NeonWorkloadFactory.cpp @@ -282,6 +282,12 @@ std::unique_ptr NeonWorkloadFactory::CreatePad(const PadQueueDescript return MakeWorkloadHelper(descriptor, info); } +std::unique_ptr NeonWorkloadFactory::CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const +{ + return MakeWorkloadHelper(descriptor, info); +} + std::unique_ptr NeonWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& info) const { diff --git a/src/backends/neon/NeonWorkloadFactory.hpp b/src/backends/neon/NeonWorkloadFactory.hpp index 115dfb0..2f7a2db 100644 --- a/src/backends/neon/NeonWorkloadFactory.hpp +++ b/src/backends/neon/NeonWorkloadFactory.hpp @@ -130,6 +130,9 @@ public: virtual std::unique_ptr CreatePad(const PadQueueDescriptor& descriptor, const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& Info) const override; diff --git a/src/backends/reference/RefWorkloadFactory.cpp b/src/backends/reference/RefWorkloadFactory.cpp index b34de86..110a947 100644 --- a/src/backends/reference/RefWorkloadFactory.cpp +++ b/src/backends/reference/RefWorkloadFactory.cpp @@ -282,6 +282,12 @@ std::unique_ptr RefWorkloadFactory::CreatePad(const PadQueueDescripto return MakeWorkload(descriptor, info); } +std::unique_ptr RefWorkloadFactory::CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const +{ + return MakeWorkload(descriptor, info); +} + std::unique_ptr RefWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& info) const { diff --git a/src/backends/reference/RefWorkloadFactory.hpp b/src/backends/reference/RefWorkloadFactory.hpp index 03b349d..f4401cc 100644 --- a/src/backends/reference/RefWorkloadFactory.hpp +++ b/src/backends/reference/RefWorkloadFactory.hpp @@ -147,6 +147,9 @@ public: virtual std::unique_ptr CreatePad(const PadQueueDescriptor& descriptor, const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateEqual(const EqualQueueDescriptor& descriptor, + const WorkloadInfo& info) const override; + virtual std::unique_ptr CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, const WorkloadInfo& info) const override;