From 988354de127528bdebb98fd25661fbf2f39f17dd Mon Sep 17 00:00:00 2001 From: Tianle Cheng Date: Wed, 28 Jun 2023 13:20:47 +0100 Subject: 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 Change-Id: I805738454421309fda77c44218a8df171d68dc18 --- include/armnn/BackendHelper.hpp | 5 +++++ include/armnn/Descriptors.hpp | 24 ++++++++++++++++++++++++ include/armnn/DescriptorsFwd.hpp | 1 + include/armnn/INetwork.hpp | 7 +++++++ include/armnn/Types.hpp | 1 + include/armnn/backends/WorkloadData.hpp | 7 ++++++- include/armnnTestUtils/TensorHelpers.hpp | 9 ++++++++- 7 files changed, 52 insertions(+), 2 deletions(-) (limited to 'include') 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 reasonIfUnsupported = EmptyOptional()); + bool IsReverseV2Supported(const TensorInfo& input, + const TensorInfo& output, + const ReverseV2Descriptor& descriptor, + Optional reasonIfUnsupported = EmptyOptional()); + bool IsShapeSupported(const TensorInfo& input, const TensorInfo& output, Optional 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 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 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; 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 +{ + 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& 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); -- cgit v1.2.1