aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTianle Cheng <tianle.cheng@arm.com>2023-06-28 13:20:47 +0100
committerTianle Cheng <tianle.cheng@arm.com>2023-07-04 10:36:43 +0000
commit988354de127528bdebb98fd25661fbf2f39f17dd (patch)
treec06f5250bdd0182055ac9e84e20d6e338518ad08 /include
parent9414936e62ed8cd18cc33c0390bb605a782556c6 (diff)
downloadarmnn-988354de127528bdebb98fd25661fbf2f39f17dd.tar.gz
IVGCVSW-7831: Front end and Reference Implementation for REVERSE_V2
* Descriptors added for ReverseV2 * Layer definition added * Input validation added * Reference workload implementation for ReverseV2 added * Reference layer unit tests made for ReverseV2 * CompareTensors method updated to support comparison between empty tensors * CMake and other build files updated Signed-off-by: Tianle Cheng <tianle.cheng@arm.com> Change-Id: I805738454421309fda77c44218a8df171d68dc18
Diffstat (limited to 'include')
-rw-r--r--include/armnn/BackendHelper.hpp5
-rw-r--r--include/armnn/Descriptors.hpp24
-rw-r--r--include/armnn/DescriptorsFwd.hpp1
-rw-r--r--include/armnn/INetwork.hpp7
-rw-r--r--include/armnn/Types.hpp1
-rw-r--r--include/armnn/backends/WorkloadData.hpp7
-rw-r--r--include/armnnTestUtils/TensorHelpers.hpp9
7 files changed, 52 insertions, 2 deletions
diff --git a/include/armnn/BackendHelper.hpp b/include/armnn/BackendHelper.hpp
index ddf2308da2..6f804cbbed 100644
--- a/include/armnn/BackendHelper.hpp
+++ b/include/armnn/BackendHelper.hpp
@@ -360,6 +360,11 @@ public:
const ResizeDescriptor& descriptor,
Optional<std::string&> reasonIfUnsupported = EmptyOptional());
+ bool IsReverseV2Supported(const TensorInfo& input,
+ const TensorInfo& output,
+ const ReverseV2Descriptor& descriptor,
+ Optional<std::string&> reasonIfUnsupported = EmptyOptional());
+
bool IsShapeSupported(const TensorInfo& input,
const TensorInfo& output,
Optional<std::string&> reasonIfUnsupported = EmptyOptional());
diff --git a/include/armnn/Descriptors.hpp b/include/armnn/Descriptors.hpp
index 9ff894f1b0..27ca50123f 100644
--- a/include/armnn/Descriptors.hpp
+++ b/include/armnn/Descriptors.hpp
@@ -1620,4 +1620,28 @@ struct BatchMatMulDescriptor : BaseDescriptor
const TensorShape& tensorShape);
};
+struct ReverseV2Descriptor : BaseDescriptor
+{
+ ReverseV2Descriptor()
+ : m_Axis()
+ , m_MaxDimension(4)
+ {}
+
+ ReverseV2Descriptor(std::vector<int32_t> axis)
+ : m_Axis(axis)
+ , m_MaxDimension(4)
+ {}
+
+ bool operator ==(const ReverseV2Descriptor& rhs) const
+ {
+ return m_Axis == rhs.m_Axis;
+ }
+
+ /// The indices of the dimensions to reverse
+ std::vector<int32_t> m_Axis;
+ /// The max dimension supported in the lower levels of code
+ uint32_t m_MaxDimension;
+
+};
+
} // namespace armnn
diff --git a/include/armnn/DescriptorsFwd.hpp b/include/armnn/DescriptorsFwd.hpp
index 2c25a49f00..4e9621d020 100644
--- a/include/armnn/DescriptorsFwd.hpp
+++ b/include/armnn/DescriptorsFwd.hpp
@@ -42,6 +42,7 @@ struct QLstmDescriptor;
struct ReshapeDescriptor;
struct ResizeDescriptor;
struct ReduceDescriptor;
+struct ReverseV2Descriptor;
struct SliceDescriptor;
struct SoftmaxDescriptor;
struct SpaceToBatchNdDescriptor;
diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp
index 819f5cb1a3..9b8c3b0b7b 100644
--- a/include/armnn/INetwork.hpp
+++ b/include/armnn/INetwork.hpp
@@ -825,6 +825,13 @@ public:
IConnectableLayer* AddBatchMatMulLayer(const BatchMatMulDescriptor& descriptor,
const char* name = nullptr);
+ /// Add a ReverseV2 layer to the network
+ /// @param descriptor - Parameters for the ReverseV2 operation
+ /// @param name - Optional name for the layer
+ /// @return - Interface for configuring the layer
+ IConnectableLayer* AddReverseV2Layer(const ReverseV2Descriptor& descriptor,
+ const char* name = nullptr);
+
void ExecuteStrategy(IStrategy& strategy) const;
protected:
diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp
index 117a679973..f05f05b2a0 100644
--- a/include/armnn/Types.hpp
+++ b/include/armnn/Types.hpp
@@ -473,6 +473,7 @@ using InferenceTimingPair = std::pair<HighResolutionClock, HighResolutionClock>;
X(GatherNd) \
X(BatchMatMul) \
X(ElementwiseBinary) \
+ X(ReverseV2) \
// New layers should be added at last position to minimize instability.
diff --git a/include/armnn/backends/WorkloadData.hpp b/include/armnn/backends/WorkloadData.hpp
index 2abd26740a..fe59fca795 100644
--- a/include/armnn/backends/WorkloadData.hpp
+++ b/include/armnn/backends/WorkloadData.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2021-2022 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -750,4 +750,9 @@ struct BatchMatMulQueueDescriptor : QueueDescriptorWithParameters<BatchMatMulDes
void Validate(const WorkloadInfo& workloadInfo) const;
};
+struct ReverseV2QueueDescriptor : QueueDescriptorWithParameters<ReverseV2Descriptor>
+{
+ void Validate(const WorkloadInfo& workloadInfo) const;
+};
+
} // namespace armnn
diff --git a/include/armnnTestUtils/TensorHelpers.hpp b/include/armnnTestUtils/TensorHelpers.hpp
index ca17e621c3..fa9c97032c 100644
--- a/include/armnnTestUtils/TensorHelpers.hpp
+++ b/include/armnnTestUtils/TensorHelpers.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017, 2021-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -88,6 +88,13 @@ armnn::PredicateResult CompareTensors(const std::vector<T>& actualData,
return res;
}
+ // Support for comparison between empty tensors
+ if (actualData.size() == 0 && expectedData.size() == 0)
+ {
+ armnn::PredicateResult comparisonResult(true);
+ return comparisonResult;
+ }
+
if (actualShape.GetNumDimensions() != expectedShape.GetNumDimensions())
{
armnn::PredicateResult res(false);