aboutsummaryrefslogtreecommitdiff
path: root/src/armnn
diff options
context:
space:
mode:
authorTeresa Charlin <teresa.charlinreyes@arm.com>2020-06-29 16:27:03 +0100
committerTeresaARM <teresa.charlinreyes@arm.com>2020-07-01 08:26:47 +0000
commit526647333571169076f5e72c9fb18c71025bf7c0 (patch)
tree6dc559a7b0fae3705172b09a88fa552926652040 /src/armnn
parentcbd2c230b7ce5f26e2ccccf36b7ad450f6e1ad09 (diff)
downloadarmnn-526647333571169076f5e72c9fb18c71025bf7c0.tar.gz
IVGCVSW-4903 Connect axis parameter in Gather from android to ACL.
!android-nn-driver:3302 Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com> Change-Id: Ifbc49acb5272f8a36719bb68676e44817190537d
Diffstat (limited to 'src/armnn')
-rw-r--r--src/armnn/LayerSupport.cpp17
-rw-r--r--src/armnn/Network.cpp11
-rw-r--r--src/armnn/Network.hpp6
-rw-r--r--src/armnn/layers/GatherLayer.cpp27
-rw-r--r--src/armnn/layers/GatherLayer.hpp11
-rw-r--r--src/armnn/test/OptimizerTests.cpp5
-rw-r--r--src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp9
-rw-r--r--src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp3
-rw-r--r--src/armnn/test/TestNameOnlyLayerVisitor.cpp3
-rw-r--r--src/armnn/test/TestNameOnlyLayerVisitor.hpp3
10 files changed, 69 insertions, 26 deletions
diff --git a/src/armnn/LayerSupport.cpp b/src/armnn/LayerSupport.cpp
index fe5b542867..197e1afe18 100644
--- a/src/armnn/LayerSupport.cpp
+++ b/src/armnn/LayerSupport.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -305,6 +305,7 @@ bool IsFullyConnectedSupported(const BackendId& backend,
FORWARD_LAYER_SUPPORT_FUNC(backend, IsFullyConnectedSupported, input, output, weights, biases, descriptor);
}
+ARMNN_DEPRECATED_MSG("Use IsGatherSupported with descriptor instead")
bool IsGatherSupported(const BackendId& backend,
const TensorInfo& input0,
const TensorInfo& input1,
@@ -312,7 +313,19 @@ bool IsGatherSupported(const BackendId& backend,
char* reasonIfUnsupported,
size_t reasonIfUnsupportedMaxLength)
{
- FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output);
+ const GatherDescriptor descriptor{};
+ FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output, descriptor);
+}
+
+bool IsGatherSupported(const BackendId& backend,
+ const TensorInfo& input0,
+ const TensorInfo& input1,
+ const TensorInfo& output,
+ const GatherDescriptor& descriptor,
+ char* reasonIfUnsupported,
+ size_t reasonIfUnsupportedMaxLength)
+{
+ FORWARD_LAYER_SUPPORT_FUNC(backend, IsGatherSupported, input0, input1, output, descriptor);
}
bool IsGreaterSupported(const BackendId& backend,
diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp
index 180c00b0c3..6c7314feb2 100644
--- a/src/armnn/Network.cpp
+++ b/src/armnn/Network.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -1724,7 +1724,14 @@ IConnectableLayer* Network::AddRsqrtLayer(const char * name)
IConnectableLayer* Network::AddGatherLayer(const char* name)
{
- return m_Graph->AddLayer<GatherLayer>(name);
+ GatherDescriptor gatherDescriptor{};
+ return AddGatherLayer(gatherDescriptor, name);
+}
+
+IConnectableLayer* Network::AddGatherLayer(const GatherDescriptor& gatherDescriptor,
+ const char* name)
+{
+ return m_Graph->AddLayer<GatherLayer>(gatherDescriptor, name);
}
IConnectableLayer* Network::AddMergeLayer(const char* name)
diff --git a/src/armnn/Network.hpp b/src/armnn/Network.hpp
index cac2b3a0e6..53bf3115f1 100644
--- a/src/armnn/Network.hpp
+++ b/src/armnn/Network.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -116,8 +116,12 @@ public:
const ConstTensor& biases,
const char* name = nullptr) override;
+ ARMNN_DEPRECATED_MSG("This AddGatherLayer overload is deprecated")
IConnectableLayer* AddGatherLayer(const char* name = nullptr) override;
+ IConnectableLayer* AddGatherLayer(const GatherDescriptor& gatherDescriptor,
+ const char* name = nullptr) override;
+
IConnectableLayer* AddPermuteLayer(const PermuteDescriptor& permuteDescriptor,
const char* name = nullptr) override;
diff --git a/src/armnn/layers/GatherLayer.cpp b/src/armnn/layers/GatherLayer.cpp
index a99913073f..3e85d25dac 100644
--- a/src/armnn/layers/GatherLayer.cpp
+++ b/src/armnn/layers/GatherLayer.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -13,8 +13,8 @@
namespace armnn
{
-GatherLayer::GatherLayer(const char* name)
- : Layer(2, 1, LayerType::Gather, name)
+GatherLayer::GatherLayer(const GatherDescriptor& param, const char* name)
+ : LayerWithParameters(2, 1, LayerType::Gather, param, name)
{
}
@@ -26,7 +26,7 @@ std::unique_ptr<IWorkload> GatherLayer::CreateWorkload(const armnn::IWorkloadFac
GatherLayer* GatherLayer::Clone(Graph& graph) const
{
- return CloneBase<GatherLayer>(graph, GetName());
+ return CloneBase<GatherLayer>(graph, m_Param, GetName());
}
void GatherLayer::ValidateTensorShapesFromInputs(ShapeInferenceMethod shapeInferenceMethod)
@@ -44,11 +44,22 @@ void GatherLayer::ValidateTensorShapesFromInputs(ShapeInferenceMethod shapeInfer
std::vector<unsigned int> dimSizes;
- for (unsigned int i = 0; i < indicesDim; ++i)
+ unsigned int axis = static_cast<unsigned int>(m_Param.m_Axis);
+ if (m_Param.m_Axis < 0)
{
- dimSizes.push_back(indices.GetShape()[i]);
+ int32_t axis_aux = static_cast<int32_t>(paramsDim) + m_Param.m_Axis;
+ axis = static_cast<unsigned int> (axis_aux);
}
- for (unsigned int i = 1; i < paramsDim; ++i)
+
+ for (unsigned int i = 0; i < axis; ++i)
+ {
+ dimSizes.push_back(params.GetShape()[i]);
+ }
+ for (unsigned int i = axis; i < indicesDim + axis; ++i)
+ {
+ dimSizes.push_back(indices.GetShape()[i - axis]);
+ }
+ for (unsigned int i = 1 + axis; i < paramsDim; ++i)
{
dimSizes.push_back(params.GetShape()[i]);
}
@@ -63,7 +74,7 @@ void GatherLayer::ValidateTensorShapesFromInputs(ShapeInferenceMethod shapeInfer
void GatherLayer::Accept(ILayerVisitor& visitor) const
{
- visitor.VisitGatherLayer(this, GetName());
+ visitor.VisitGatherLayer(this, GetParameters(), GetName());
}
} // namespace armnn
diff --git a/src/armnn/layers/GatherLayer.hpp b/src/armnn/layers/GatherLayer.hpp
index 598ca44dc4..d8737adbee 100644
--- a/src/armnn/layers/GatherLayer.hpp
+++ b/src/armnn/layers/GatherLayer.hpp
@@ -1,17 +1,17 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
-#include "Layer.hpp"
+#include "LayerWithParameters.hpp"
namespace armnn
{
/// This layer represents a Gather operator.
-class GatherLayer : public Layer
+class GatherLayer : public LayerWithParameters<GatherDescriptor>
{
public:
/// Makes a workload for the Gather type.
@@ -24,7 +24,7 @@ public:
/// @param [in] graph The graph into which this layer is being cloned.
GatherLayer* Clone(Graph& graph) const override;
- /// Check if the input tensor shape(s)
+ /// Check if the input tensor shape(s).
/// will lead to a valid configuration of @ref GatherLayer.
/// @param [in] shapeInferenceMethod Indicates if output shape shall be overwritten or just validate.
void ValidateTensorShapesFromInputs(
@@ -34,8 +34,9 @@ public:
protected:
/// Constructor to create a GatherLayer.
+ /// @param [in] param GatherDescriptor to configure the stack operation.
/// @param [in] name Optional name for the layer.
- GatherLayer(const char* name);
+ GatherLayer(const GatherDescriptor& param, const char* name);
/// Default destructor
~GatherLayer() = default;
diff --git a/src/armnn/test/OptimizerTests.cpp b/src/armnn/test/OptimizerTests.cpp
index 65ea91d402..3af50ecf3a 100644
--- a/src/armnn/test/OptimizerTests.cpp
+++ b/src/armnn/test/OptimizerTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -458,7 +458,8 @@ void CreateGatherGraph(Graph& graph, const armnn::TensorInfo& paramsInfo, const
Layer* input1 = graph.AddLayer<InputLayer>(1, "indices");
input1->GetOutputSlot().SetTensorInfo(indicesInfo);
- GatherLayer* layer = graph.AddLayer<GatherLayer>("gather");
+ GatherDescriptor descriptor;
+ GatherLayer* layer = graph.AddLayer<GatherLayer>(descriptor, "gather");
layer->GetOutputSlot().SetTensorInfo(outputInfo);
Layer* output = graph.AddLayer<OutputLayer>(0, "output");
diff --git a/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp b/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
index e07e497ab8..6ab9f9e1e4 100644
--- a/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
+++ b/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "TestNameAndDescriptorLayerVisitor.hpp"
@@ -98,6 +98,12 @@ armnn::FillDescriptor GetDescriptor<armnn::FillDescriptor>()
}
template<>
+armnn::GatherDescriptor GetDescriptor<armnn::GatherDescriptor>()
+{
+ return armnn::GatherDescriptor();
+}
+
+template<>
armnn::InstanceNormalizationDescriptor GetDescriptor<armnn::InstanceNormalizationDescriptor>()
{
armnn::InstanceNormalizationDescriptor descriptor;
@@ -271,6 +277,7 @@ TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(Comparison)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(Concat)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(ElementwiseUnary)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(Fill)
+TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(Gather)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(InstanceNormalization)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(L2Normalization)
TEST_SUITE_NAME_AND_DESCRIPTOR_LAYER_VISITOR(LogSoftmax)
diff --git a/src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp b/src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
index c8df505db0..df0e055157 100644
--- a/src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
+++ b/src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -50,6 +50,7 @@ DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(Concat)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(DepthToSpace)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(ElementwiseUnary)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(Fill)
+DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(Gather)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(InstanceNormalization)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(L2Normalization)
DECLARE_TEST_NAME_AND_DESCRIPTOR_LAYER_VISITOR_CLASS(LogSoftmax)
diff --git a/src/armnn/test/TestNameOnlyLayerVisitor.cpp b/src/armnn/test/TestNameOnlyLayerVisitor.cpp
index 0653b39e58..945afa8ff5 100644
--- a/src/armnn/test/TestNameOnlyLayerVisitor.cpp
+++ b/src/armnn/test/TestNameOnlyLayerVisitor.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -42,7 +42,6 @@ TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Addition)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Dequantize)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Division)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Floor)
-TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Gather)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Maximum)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Merge)
TEST_SUITE_NAME_ONLY_LAYER_VISITOR(Minimum)
diff --git a/src/armnn/test/TestNameOnlyLayerVisitor.hpp b/src/armnn/test/TestNameOnlyLayerVisitor.hpp
index 84dfdd6539..0e1ea8eac7 100644
--- a/src/armnn/test/TestNameOnlyLayerVisitor.hpp
+++ b/src/armnn/test/TestNameOnlyLayerVisitor.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -29,7 +29,6 @@ DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Addition)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Dequantize)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Division)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Floor)
-DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Gather)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Maximum)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Merge)
DECLARE_TEST_NAME_ONLY_LAYER_VISITOR_CLASS(Minimum)